【发布时间】:2016-05-05 02:47:04
【问题描述】:
不确定为什么这不起作用。
(defrule contain-red?
(initial-fact)
=>
(bind ?reply (get-text-from-user "Does it contain x (y/n?"))
(assert (existing-text ?reply )))
(defrule partOne
(existing-text "y")
=>
(bind ?reply (get-text-from-user "give me a number"))
(assert (credit-value-bsc-first-result (explode$ ?reply ))))
(defrule partTwo
(existing-text "n")
=>
(bind ?reply (get-text-from-user "give me a number"))
(assert (credit-value-bsc-second-result (explode$ ?reply ))))
(defrule learn-about-120?
(credit-value-bsc-first-result ?n)
(credit-value-bsc-second-result ?x)
(test (or (<= ?n 20) (<= ?x 20)))
=>
(bind ?reply (get-text-from-user "Reponse here)"))
(assert (learn-about-120-response ?reply )))
我可以让最终规则在不同的场景中使用 and 来工作。将其加载到 wxCLIPS 时不会出现错误,但是当我运行它并输入相关数据时,最终规则不会触发。
【问题讨论】:
-
不需要在没有其他条件的情况下将初始事实添加到规则中;它会在 6.3 版之前的 CLIPS 版本中自动添加。最初的事实功能在 6.3 版本中已被弃用;它仍然由复位断言,但没有条件的规则不再依赖它。在 6.4 版本中,initial-fact 不再被断言,因此明确匹配该事实的规则将不再被激活。
标签: clips