不确定为什么这不起作用。
(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 )))
我可以使用和在不同的场景中使用最终规则。将此加载到wxCLIPS时不会出现错误,但是当我运行它并输入相关数据时,最终规则不会触发。
答案 0 :(得分:0)
只有当现有文本为&#34; y&#34;时才会创建信用值-bc-first-result。只有当现有文本是&#34; n&#34;时才会创建信用值-bc-second-result。如果只存在一个现有文本事实,则这些条件是互斥的。规则学习约120?要求这两个事实都不会触发。
以这种方式编写规则可能就是你想要的:
countTrailingZeros