我正试图用Clips制作一个专家系统,但是当一个植物只触发一次规则时,它触发的次数与规则中所指定的特征相一致时,是否有办法使该规则在事实中每个植物只触发一次?
我尝试使用test() (通过将包含在测试中的所有条件或())语句,但是它没有工作,这会给我处理工厂模板带来麻烦。
规则示例
(defrule ruleexp
(or
(Plant (grownt normal))
(Plant (leaf purple))
(Plant (roots burned))
(Plant (fruit dry)))
=>
(printout t "this should print only once" crlf))发布于 2020-01-19 00:03:06
您可以使用存在条件元素只创建一个激活:
CLIPS (6.31 6/12/19)
CLIPS>
(deftemplate Plant
(slot growth)
(slot leaf)
(slot roots)
(slot fruit))
CLIPS>
(defrule ruleexp
(exists
(or (Plant (growth normal))
(Plant (leaf purple))
(Plant (roots burned))
(Plant (fruit dry))))
=>
(printout t "this should print only once" crlf))
CLIPS>
(assert (Plant (growth normal)
(leaf blue)
(roots burned)
(fruit wet)))
<Fact-1>
CLIPS> (run)
this should print only once
CLIPS> https://stackoverflow.com/questions/59805839
复制相似问题