I'm trying to figure out the best way to handle this situation.
My program has two "modes". In the first, the program collects "instructions",
and in the second, the instructions are "processed". Now the program shouldn't
go into the second mode until all the instructions are received. There are X
number of people (represented by facts), and each one should have an instruction
(also represented by a fact). So the program should wait in the first mode
until all X instructions have been received, then it should go process them.
The number of people can change from run to run of the program, and the
instructions can be asserted in any order.
This won't work. (assuming all deftemplates are already stated) :
(current-mode (mode collect))
(defrule count-instruction ""
(person (name ?Name))
(instruction (name ?Name) (counted false))
?Instruction <- (instruction (name ?Name) (counted false))
=>
(modify ?Instruction (counted true))
)
(defrule got-all-instructions ""
?Mode <- (current-mode (mode collect))
(person (name ?Name))
(instruction (name ?Name) (counted true))
=>
(modify ?Mode (mode process))
)
(defrule not-all-instructions-in-yet ""
?Mode <- (current-mode (mode collect))
(person (name ?Name))
; This should catch a missing instruction and one that has not been
"counted" yet.
(not (instruction (name ?Name) (counted true)))
=>
(modify ?Mode (mode collect))
)
And I have yet to come up with a good mechanism. What pattern have other people
used for this situation?
-Chuck.
---------------------------------------------------------------------
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]
---------------------------------------------------------------------