[Clips]规则一次触发更多棕褐色

问题描述 投票:0回答:1

您好,我想在Clips中建立一个专家系统,但是当Plant只触发一次规则时,它触发的次数是该规则所指定的特征内重合的次数,有没有办法让此规则仅触发事实中每个植物一次?

我尝试使用test()(通过放入测试中包含的所有条件or())的语句,但是它不起作用,这会给我工厂模板带来麻烦

规则示例


(defrule ruleexp
   (or
   (Plant (grownt normal))
   (Plant (leaf purple))
   (Plant (roots burned))
   (Plant (fruit dry)))
   =>
   (printout t "this should print only once" crlf))

system rules clip clips
1个回答
0
投票

您可以使用exists条件元素来创建一个激活:

         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> 
© www.soinside.com 2019 - 2024. All rights reserved.