Hello everyone,

I'm new to Jess and struggling with making one example work, based on
problem from http://en.wikipedia.org/wiki/Backward_chaining

The goal is to find the pet's color if given that pet is a frog or a
canary.

I have defined such rules:

===============
(do-backward-chaining color)

(do-backward-chaining kind)

(defrule print-Fritz-color
 (color ?name ?val) =>
 (printout t "Color of " ?name " is " ?val crlf)
)

(defrule frog-color
 (need-color ?name ?)
 (kind ?name frog)
 =>
 (printout t "firing frog-color" crlf)
 (assert (color ?name "green"))
)


(defrule pet-kind
 (need-kind ?name ?type) =>
 (printout t "Pet name? ")
 (bind ?name (read))
 (printout t "Pet kind? ")
 (bind ?type (read))
 (assert (kind ?name ?type))
)


TRUE
Jess> TRUE
Jess> TRUE
Jess> TRUE
Jess> TRUE
Jess> (reset)
TRUE
Jess> (agenda)
[Activation: MAIN::pet-kind  f-2, ; time=3 ; salience=0]
For a total of 1 activations.
Jess> (run)
Pet name? Fritz
Pet kind? frog
1
Jess> (facts)
f-0   (MAIN::initial-fact)
f-1   (MAIN::need-color nil nil)
f-2   (MAIN::need-kind nil frog)
f-3   (MAIN::kind Fritz frog)
For a total of 4 facts.
Jess>


===================

Note that pet-kind rule fires, because it asks me about the pet name and
 type.

What I don't get is why frog-color rule doesn't fire -- after all, it
clearly has following facts asserted:

f-1   (MAIN::need-color nil nil)
f-3   (MAIN::kind Fritz frog)

..and the rule conditions defined:

(defrule frog-color
 (need-color ?name ?)
 (kind ?name frog)



Why doesn't the damn thing fire??

Regards,
Marcin




--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to