質問

href="http://clipsrules.sourceforge.net/" rel="nofollow noreferrer">クリップに

これが有効なクリップコードでないとはいえ、私は、このような何かをしたい:

(defrule score-state ""
    ?score <- (score (value ?value))
    =>
    (modify ?score (value (+ (exists (goal-1)) (exists (goal-2)) (exists (goal-3))))))

だから、目標状態の何も存在しない場合は、その後、実際に(スコア(値0を))が存在するだろうと。逆に、すべてのゴール状態が存在する場合、その事実が存在することになる(スコア(値3))。

リファレンスマニュアルは、関数事実-existpに言及したが、これは、それが実際のアドレスを渡された必要のようです。私は(事実existp(目標-1))のようにそれを使用してみましたが、クリップは私に構文エラーを与えます。

役に立ちましたか?

解決

(deftemplate score
   (slot value))

(deftemplate goal-1)

(deftemplate goal-2)

(deftemplate goal-3)

(deffacts start
   (score (value undefined))
   (goal-1)
   (goal-3))

(deffunction ecount (?g)
   (if (any-factp ((?f ?g)) TRUE)
      then (return 1)
      else (return 0)))

(defrule score-state ""
    ?score <- (score (value undefined))
    =>
    (modify ?score (value (+ (ecount goal-1) (ecount goal-2) (ecount goal-3)))))
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top