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 *)
Hi Ernest.


I took a short look at this problem yesterday and noticed: If you perform a (reset) -- and create an initial-fact -- before performing (run) this problem does NOT appear. Here's what I ran (a very slightly modified form of the original list of commands):

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

(defmodule mod)

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

(watch all)
(reset) ;; added by Win Carus
(assert (a))
(facts *) ;; added by Win Carus
(run)
(retract 1) ;; (retract (b))
(run)
(facts *) ;; added by Win Carus
(retract 0) ;; (retract (a))
(focus mod)
(run)
(facts *)

Regards,

Win

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