# JESS: Goal in each action

```Thank you Ernest,
I have more questions about it...The first one is that I'd read that Jess
memorizes each rule that it passes and so Jess doesn't pass two times in the
same rule. Am I right? ```
```
If yes, in Monkey and Bananas example, I do not understand why it changes
the goal in some actions, because for me the goal in a planner should be
allways the same, for example eat bananas and as the planner is running and
passing to into rules, it will not fire that rule again.

If a rule has the OR operator, then as you said it creates another rule, and
see below what it does. Actually, I thought that changing the goal in each
action is the only way to make sure Jess will fire this rule only one time,
but...how about the others solutions, how can I get them? Imagine that we
have these rules:
(clear)
(deffacts start
(fermetureFenetre pose)
(fermeturePorte pose)
(fauxPlafond pose)
(exist cloison)
)
(reset)

(defrule peindre-murs-et-plafonds
(fermetureFenetre pose)
(fermeturePorte pose)
(fauxPlafond pose)
(exist cloison)
=>
(assert (murPlafond peint))
(printout t "Peint murs et plafonds" crlf)
)

(defrule fournir-poser-papier-peint
(murPlafond peint)
=>
(assert (papierPeint pose))
(printout t "Fourniture et pose des Papiers Peint" crlf)
)

(defrule peindre-sol
(or (murPlafond peint) (papierPeint pose))
=>
(assert (sol peint))
(printout t "Peint le sol" crlf)
)

(defrule fournir-poser-moquette
(sol peint)
(or (murPlafond peint) (papierPeint pose))
=>
(assert (moquette pose))
(printout t "Fourniture et pose de moquette" crlf)
)
(run)

Peint murs et plafonds
Fourniture et pose des Papiers Peint
Peint le sol
Fourniture et pose de moquette
Fourniture et pose de moquette
Peint le sol
6

And then as Jess consider &1 as another rule, it did not stop at the first
"Fourniture et pose de moquette" but it tries to execute the OR operator and
fire the rule "Fourniture et pose de moquete" and "Peint le sol" two times.

Thus is it the reason that I should change the goals in each rule to assure
that Jess will fire only one time each rule even if I have an OR operator?
Thus my answer in the first planner would be like that:
Peint murs et plafonds
Fourniture et pose des Papiers Peint
Peint le sol
Fourniture et pose de moquette

This order is fixed based on the preconditions, but imagine that X can be
executed before Y or before Z. Thus how can I force that the first plan
shows me X before Y and than another plan shows me X before Z. How can I get
the other plan?

Here is the watch all from
Jess> (batch peinture.clp)
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::fermetureFenetre pose)
==> f-2 (MAIN::fermeturePorte pose)
==> f-3 (MAIN::fauxPlafond pose)
==> f-4 (MAIN::exist cloison)
==> Activation: MAIN::peindre-murs-et-plafonds :  f-1, f-2, f-3, f-4
MAIN::peindre-murs-et-plafonds: +1+1+1+1+1+1+1+2+1+1+1+2+1+1+1+2+t
MAIN::fournir-poser-papier-peint: +1+1+1+1+t
MAIN::peindre-sol: =1=1=1=1+t
MAIN::peindre-sol&1: +1+1+1+1+t
MAIN::fournir-poser-moquette: +1+1+1+1=1=1=1+2+t
MAIN::fournir-poser-moquette&1: =1=1=1=1=1=1=1+2+t
FIRE 1 MAIN::peindre-murs-et-plafonds f-1, f-2, f-3, f-4
==> f-5 (MAIN::murPlafond peint)
==> Activation: MAIN::fournir-poser-papier-peint :  f-5
==> Activation: MAIN::peindre-sol :  f-5
Peint murs et plafonds
FIRE 2 MAIN::fournir-poser-papier-peint f-5
==> f-6 (MAIN::papierPeint pose)
==> Activation: MAIN::peindre-sol :  f-6
Fourniture et pose des Papiers Peint
FIRE 3 MAIN::peindre-sol f-6
==> f-7 (MAIN::sol peint)
==> Activation: MAIN::fournir-poser-moquette :  f-7, f-5
==> Activation: MAIN::fournir-poser-moquette :  f-7, f-6
Peint le sol
FIRE 4 MAIN::fournir-poser-moquette f-7, f-6
==> f-8 (MAIN::moquette pose)
Fourniture et pose de moquette
FIRE 5 MAIN::fournir-poser-moquette f-7, f-5
Fourniture et pose de moquette
FIRE 6 MAIN::peindre-sol f-5
Peint le sol
<== Focus MAIN
6
Jess>

Thank you!!!
Daniela

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list