回到剪辑中的上述规则

时间:2015-03-24 03:56:11

标签: clips expert-system

当我尝试拨打已经使用过的defrule时,剪辑会停止..

某些defrule需要使用多次,有没有办法呢

这是一个例子

(

defrule choice-in-powerPlant2
(powerPlant2-question)
=>
(printout t "Are Filter and Carburetor Air working fine(y/n)?" crlf)
(bind ?response (check-YNoptions-input)); Get user input on type of questions
(if (eq ?response y)
    then
    (assert (powerPlant1-question)
    )
)

(if (or(eq ?response q) (eq ?response Q))
    then 
(output-exitmessage)

)

(if (eq ?response n)
    then
        (printout t "Have you fixed this(y/n)?" crlf)
        (bind ?response (check-YNoptions-input)); Get user input on type of questions
        (if (eq ?response y)
            then
            (assert (powerPlant1-question)
            )
        )
        (if (eq ?response n)
            then
            (printout req "Please replace Filter and Carburetor Air " crlf)
            (assert (powerPlant3-question))
    )
)
)
规则2中的

当我输入" y" =是

时,我想回到规则1

"我输入" y" "

1 个答案:

答案 0 :(得分:0)

如果要重新触发与特定事实匹配的规则,请将该事实作为规则操作的一部分收回。如果另一条规则断言该特定事实,则该规则将被重新触发。例如:

(defrule choice-in-powerPlant2
   ?f <- (powerPlant2-question)
   =>
   (retract ?f)
   (printout t "Are Filter and Carburetor Air working fine(y/n)?" crlf)
      .
      .
      .
)