> Note the test to check that lower-legs isn't already there, if the
> test is not there the rule will run forever; maybe Ernest can
> provide a way to change the value without having the resulting
> modified fact retrigger the rule.
I'm sorry, I didn't understand this part at 1st. Why would the rule keep
triggering when the RHS fact is changed?
But I think I finally experience the problem with my code, the prog just
keep running
Attached below is my code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gym machine and the body part it worksout
(deftemplate gym-station
(slot ident)
(multislot purpose) );;close
(deffacts gym-station-data
(gym-station (ident station1) (purpose arms-upperfront back))
(gym-station (ident station2) (purpose legs))
(gym-station (ident station3) (purpose abs shoulders arms-upperfront))
(gym-station (ident station4) (purpose abs shoulders legs)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;; to find the gym machine that worksout specific
body part
(deftemplate station-matcher
(slot ident)
(multislot station))
(deffacts station-matcher-data
(station-matcher (ident arms-upperfront) (station))
(station-matcher (ident legs) (station))
(station-matcher (ident abs) (station)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;to find which machine helps to
workout arms-upperfront
(defrule detect-arms-upperfront
(gym-station (ident ?name) (purpose $?purpose))
?a <-(station-matcher (ident ?body-part) (station $?station))
(test (eq arms-upperfront ?body-part))
(test (not(member$ ?name $?station)))
(test (member$ arms-upperfront $?purpose))
=> (modify ?a (station (create$ ?name))) );close
(reset)
(run)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I have added the codeX
(test (not(member$ ?name $?station)))
but why would the rule trigger again? After the rule ran once, at the 2nd
run, shouldn't codeX stop it? Since the gym-station ident "station3" will be
added into the station-matcher multislot "station". So the codeX test at the
2nd run should be "false" which shouldn't trigger the rule again.
I'm not a bright student, so if its too messy to explain, then its ok : )
I guess the indirect question I'm asking is - do I really need to get
Jess70p1 to solve this prob?
thanks again, rgds
Rick
Ernest Friedman-Hill wrote:
>
> On Mar 14, 2007, at 11:33 AM, David Corsar wrote:
>>
>> Note the test to check that lower-legs isn't already there, if the
>> test is not there the rule will run forever; maybe Ernest can
>> provide a way to change the value without having the resulting
>> modified fact retrigger the rule.
>
> Nothing you can do in Jess 6, really; that's why Jess 7 added the "no-
> loop" rule declaration. Add "(declare (no-loop TRUE))" to a rule in
> Jess 7, and no modifies on the RHS will cause the rule to reactivate.
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Advanced Software Research Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> PO Box 969, MS 9012 [EMAIL PROTECTED]
> Livermore, CA 94550 http://www.jessrules.com
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
>
>
--
View this message in context:
http://www.nabble.com/Compare-the-2nd-slot-of-all-facts-tf3401443.html#a9489937
Sent from the Jess mailing list archive at Nabble.com.
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------