剪辑或声明未触发
Clips OR Statement not firing
不确定为什么这不起作用。
(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 时没有出现错误,但是当我 运行 它并输入相关数据时,最终规则不会触发。
事实 credit-value-bc-first-result 仅在 existing-text 为 "y" 时创建。事实 credit-value-bc-second-result 仅在 existing-text 为 "n" 时创建。如果只有一个现存文本事实存在,那么这些条件是互斥的。由于规则 learn-about-120?需要这两个事实它不会触发。
这样写规则可能就是你想要的:
(defrule learn-about-120?
(or (credit-value-bsc-first-result ?n)
(credit-value-bsc-second-result ?n))
(test (<= ?n 20))
=>
(bind ?reply (get-text-from-user "Reponse here)"))
(assert (learn-about-120-response ?reply )))
不确定为什么这不起作用。
(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 时没有出现错误,但是当我 运行 它并输入相关数据时,最终规则不会触发。
事实 credit-value-bc-first-result 仅在 existing-text 为 "y" 时创建。事实 credit-value-bc-second-result 仅在 existing-text 为 "n" 时创建。如果只有一个现存文本事实存在,那么这些条件是互斥的。由于规则 learn-about-120?需要这两个事实它不会触发。
这样写规则可能就是你想要的:
(defrule learn-about-120?
(or (credit-value-bsc-first-result ?n)
(credit-value-bsc-second-result ?n))
(test (<= ?n 20))
=>
(bind ?reply (get-text-from-user "Reponse here)"))
(assert (learn-about-120-response ?reply )))