Hi Win,

That's an interesting result. On my machine with Jess 7.0p1, the problem still arises even with an initial reset:

Jess, the Rule Engine for the Java Platform
Copyright (C) 2006 Sandia Corporation
Jess Version 7.0p1 12/21/2006

==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::a)
==> Activation: MAIN::r :  f-1,
FIRE 1 MAIN::r f-1,
==> f-2 (MAIN::b)
==> Activation: mod::bad-rule :  f-2
<== Focus MAIN
<== f-2 (MAIN::b)
==> Activation: MAIN::r :  f-1,
<== Activation: mod::bad-rule :  f-2
FIRE 1 MAIN::r f-1,
==> f-3 (MAIN::b)
==> Activation: mod::bad-rule :  f-3
<== f-1 (MAIN::a)
<== f-2 (MAIN::b)
<== Focus MAIN
==> Focus mod
FIRE 1 mod::bad-rule f-3
BAD!!!
<== Focus mod
==> Focus MAIN
f-0   (MAIN::initial-fact)
For a total of 1 facts in all modules.

~~Aaron

Hi Aaron.


Correct. I did a quick cut-and-paste from the original memo and forgot to change the offsets. The original point stands, however.

Win

Aaron Novstrup wrote:

Asserting the initial-fact shifts the fact-ids by 1, so you have to make the corresponding changes in the code:

    (defrule r
       (logical (a))
       (not (b))
       =>
       (assert (b)))

    (defmodule mod)

    (defrule bad-rule
       (b)
       =>
       (printout t "BAD!!!" crlf))

    (watch all)
    (reset)
    (assert (a))
    (run)
    (retract 2) ;; (retract (b))
    (run)
    (retract 1) ;; (retract (a))
    (focus mod)
    (run)
    (facts *)
begin:vcard
fn:Aaron Novstrup
n:Novstrup;Aaron
org:Stottler Henke Associates Inc.
adr;dom:;;1107 NE 45th St;Seattle;WA;98105
email;internet:[EMAIL PROTECTED]
title:AI Software Engineer
tel;work:206.545.2941
tel;cell:805.701.9786
x-mozilla-html:FALSE
url:www.stottlerhenke.com
version:2.1
end:vcard

Reply via email to