【问题标题】:CLIPS multiple andCLIPS 多个和
【发布时间】:2012-05-02 21:25:45
【问题描述】:

假设我有这样的规则:

(defrule get_next_N_poz
    ?id <- (get_next_poz $?)
    (world (limit $?) (ball ?b1 ?b2) (men $? ?x ?y - $?) (id ?))

    (and
    (test (= ?x ?b1))
    (test (= ?y (- ?b2 1))))
        => 
        (printout t "north ready position:" ?x ?y)
        (modify ?id (get_next_poz 1)))

如何添加新的“和”? 谢谢。

【问题讨论】:

    标签: clips


    【解决方案1】:

    这取决于您尝试实现的逻辑。你现有的 和 无论如何都是多余的,但如果你想要第二个,你只需在最后一个结束后添加它:

     (and
        (test (= ?x ?b1))
        (test (= ?y (- ?b2 1))))
    
     (and
        (test (= ?x ?b2))
        (test (= ?y (+ ?b1 1))))
    

    如果您想要以下条件中的一个或另一个,您可以这样做:

     (or (and
           (test (= ?x ?b1))
           (test (= ?y (- ?b2 1))))
    
        (and
           (test (= ?x ?b2))
           (test (= ?y (+ ?b1 1)))))
    

    您可以在单个测试条件元素中使用和/或布尔函数,而不是使用和/或条件元素:

     (test (or (and (= ?x ?b1)
                    (= ?y (- ?b2 1)))
               (and (= ?x ?b2)
                    (= ?y (+ ?b1 1)))))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多