【问题标题】:Get back to above rule in clips回到剪辑中的上述规则
【发布时间】:2015-03-28 16:08:44
【问题描述】:

当我尝试调用已使用的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"=yes 时,我想回到规则 1

" 输入 "y" 后停止运行"

【问题讨论】:

    标签: clips expert-system


    【解决方案1】:

    如果您想重新触发与特定事实匹配的规则,请将该事实作为规则操作的一部分撤回。如果另一个规则随后断言该特定事实,则将重新触发该规则。例如:

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

    【讨论】:

    • 现在可以工作了!!非常感谢你 ^____^ 谢谢加里 ^____________^
    • 我只是想知道这是否适用于只写一次的所有 defrule ?还是我必须为每个规则编写该代码?
    • 您必须为要重复执行的每个规则执行此操作。
    • 格雷先生,我还有个问题,当我输入“否”时,我想显示“消息”,然后直接进入另一个规则............ ...................... (if (eq ?response n) then (printout t "Please register level1 and go to case 6" crlf) (assert (case46 )))
    • 发布您的代码,以便重现您所描述的行为。
    猜你喜欢
    • 2012-05-15
    • 2012-05-15
    • 1970-01-01
    • 1970-01-01
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    相关资源
    最近更新 更多