问题
I want to increment security when the rule is run. Right now it changes nothing. The fact (human_resources n) does exist.
(defglobal ?security = 0)
(defrule rule1 (human_resources n) => (defglobal ?security = (+ ?security 1)) )
This results in ?*security = 1: (defglobal ?security = 0) (defglobal ?security = (+ ?security 1))
回答1:
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>
来源:https://stackoverflow.com/questions/5718243/clips-incrementing-a-variable-with-a-rule