我已将 CLIPS 嵌入到 C 语言中。我有这样的情况:在 .clp 文件中,我有事实清单
(deftemplate sensor
(slot name)
(slot status))
(deffacts FRONTSENSOR
(sensor (name 1) (status 1))
(sensor (name 2) (status 1))
(sensor (name 3) (status 0))
(sensor (name 4) (status 0))
(sensor (name 5) (status 1))
(sensor (name 6) (status 0))
(sensor (name 7) (status 0))
(sensor (name 8) (status 0)))
现在我想取消这些事实并在列表中声明新的事实。我Retract(factPtr);
用来取消事实并AssertString("(sensor (name 1) (status 0))");
用来断言事实。我打印事实清单,结果是
f-0 (initial-fact)
f-11 (sensor (name 1) (status 0))
f-12 (sensor (name 2) (status 0))
f-13 (sensor (name 3) (status 1))
f-14 (sensor (name 4) (status 0))
f-15 (sensor (name 5) (status 0))
f-16 (sensor (name 6) (status 0))
f-17 (sensor (name 7) (status 1))
f-18 (sensor (name 8) (status 1))
For a total of 9 facts.
fact-index 是从 11 开始而不是 1,我想知道是否有新断言的事实可以从 f-1 开始的功能或解决方案。Ps:<code>Clear()函数可以重置fact-index,但是规则也会被清理。似乎没有帮助。
感谢您的回答或任何想法。