【问题标题】:Rule Doesn't Execute规则不执行
【发布时间】:2020-04-02 01:02:26
【问题描述】:

我目前正在创建一个专家系统来询问用户问题,这些问题的答案将决定

【问题讨论】:

  • 我认为您的问题可能不够具体。您能否提供一些代码示例,说明您试图使其更清晰?

标签: rules clips expert-system


【解决方案1】:

我想,您希望在回答第一个问题后触发 big-no 或 big-yes 规则。但是,回答第一个问题将断言 (animal-big yes) 或 (animal-big no)。与此相反,big-no 和 big-yes 的前提条件是检查 (big ?) 而不是 (animal-big ?)。所以这些规则永远不会触发。

此外,我建议您重构代码以便更清楚地分离不同的规则。判断你发布的代码,它无论如何都不会工作。您是否尝试在另一个规则的 RHS 中创建新规则? 例如:

(defrule yes-big 
(big yes) 
=>
(defrule is-neck-long (not (neck-long ?)) => (printout t "Is the animals neck long (yes or no)?") (assert neck-long (read))))
(defrule neck-long-yes
(neck-long yes) 
=>
(printout t "your animal is a giraffe" crlf)
(bind ?animal giraffe)
(assert (animal-is ? animal)))

我会改写成

(defrule yes-big-check-neck 
   (animal-big yes)
   (not (neck-long ?)) 
=>
   (printout t "Is the animals neck long (yes or no)?") 
   (assert neck-long (read))
)

(defrule neck-long-yes
  (neck-long yes) 
=>
  (printout t "your animal is a giraffe" crlf)
  (bind ?animal giraffe)
  (assert (animal-is ? animal))
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多