CLIPS使用规则递增变量

时间:2011-04-19 14:44:33

标签: clips

我希望在运行规则时增加安全性。现在它什么都没改变。事实(human_resources n)确实存在。

(defglobal? security = 0)

(defrule rule1     (human_resources n)     =>     (defglobal? security =(+? security 1)) )

这导致?* security = 1: (defglobal?安全 = 0) (defglobal? security =(+? security 1))

1 个答案:

答案 0 :(得分:6)

CLIPS> (defglobal ?*security* = 0)
CLIPS> 
(defrule rule1
   (human_resources n)
   =>
   (bind ?*security* (+ ?*security* 1)))
CLIPS> (reset)
CLIPS> ?*security*
0
CLIPS> (assert (human_resources n))
<Fact-1>
CLIPS> (run)
CLIPS> ?*security*
1
CLIPS>