- assigned_to: nobody --> youngde
- status: open --> closed
This code illustrates the problem. It's output is at
the bottom.
(in-package :lisa-user)
(deftemplate territory ())
(deftemplate territory-type-num-bots-intended ()
(slot bot-class))
(deftemplate sector-initialized ())
(defrule retreat ()
(?territory (territory))
(?initfact (sector-initialized))
=>
(format t "Retracting territory in this RHS should
prevent
maintain-bot-count from firing~%")
(retract ?initfact)
(retract ?territory)) ;these retractions can be in
either order- the
problem still exists
(defrule maintain-bot-count ()
(territory)
(territory-type-num-bots-intended (bot-class ?bot-class))
(not (sector-initialized))
=>
(format t "This rule shouldnt fire~%"))
(defrule startup ()
=>
(assert (territory))
(assert (sector-initialized))
(assert (territory-type-num-bots-intended (bot-class
assault)))
(assert (territory-type-num-bots-intended (bot-class
collector)))
(assert (territory-type-num-bots-intended (bot-class
guardian))))
Here is the complete output of the snippet, annotated
to indicate the
activations:
FIRE 1: STARTUP (F-0)
==> F-1 (TERRITORY)
==> F-2 (SECTOR-INITIALIZED)
==> Activation: RETREAT : (F-1 F-2)
==> F-3 (TERRITORY-TYPE-NUM-BOTS-INTENDED (BOT-CLASS
ASSAULT))
==> F-4 (TERRITORY-TYPE-NUM-BOTS-INTENDED (BOT-CLASS
COLLECTOR))
==> F-5 (TERRITORY-TYPE-NUM-BOTS-INTENDED (BOT-CLASS
GUARDIAN))
FIRE 2: RETREAT (F-1 F-2)
Retracting territory in this RHS should prevent
maintain-bot-count from firing
<== F-2 (SECTOR-INITIALIZED)
;The following 3 activations are added to the agenda,
but only the
first is removed, whereas all three should be.
==> Activation: MAINTAIN-BOT-COUNT : (F-1 F-3)
==> Activation: MAINTAIN-BOT-COUNT : (F-1 F-4)
==> Activation: MAINTAIN-BOT-COUNT : (F-1 F-5)
<== F-1 (TERRITORY)
<== Activation: MAINTAIN-BOT-COUNT : (F-1 F-3)
FIRE 3: MAINTAIN-BOT-COUNT (F-1 F-4)
This rule shouldnt fire
FIRE 4: MAINTAIN-BOT-COUNT (F-1 F-5)
This rule shouldnt fire