1

次のようなルールがあるとしましょう。

(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)))

新しい「and」を追加するにはどうすればよいですか? ありがとうございました。

4

1 に答える 1

1

実装しようとしているロジックによって異なります。既存のものあなたが持っているものはとにかく冗長ですが、2番目のものが必要な場合は、最後の終わりの後に追加するだけです:

 (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)))))
于 2012-05-20T22:37:34.787 に答える