首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CLIPS规则触发多次

CLIPS规则触发多次
EN

Stack Overflow用户
提问于 2020-01-18 23:37:14
回答 1查看 246关注 0票数 1

我正试图用Clips制作一个专家系统,但是当一个植物只触发一次规则时,它触发的次数与规则中所指定的特征相一致时,是否有办法使该规则在事实中每个植物只触发一次?

我尝试使用test() (通过将包含在测试中的所有条件或())语句,但是它没有工作,这会给我处理工厂模板带来麻烦。

规则示例

代码语言:javascript
复制
(defrule ruleexp
   (or
   (Plant (grownt normal))
   (Plant (leaf purple))
   (Plant (roots burned))
   (Plant (fruit dry)))
   =>
   (printout t "this should print only once" crlf))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-19 00:03:06

您可以使用存在条件元素只创建一个激活:

代码语言:javascript
复制
         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> 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59805839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档