2016-05-04 16 views
0

これがなぜ機能しないのか分かりません。クリップOR発言が発砲しない

(defrule contain-red? 
(initial-fact) 
=> 
(bind ?reply (get-text-from-user "Does it contain x (y/n?")) 
(assert (existing-text ?reply))) 

(defrule partOne 
(existing-text "y") 
=> 
(bind ?reply (get-text-from-user "give me a number")) 
(assert (credit-value-bsc-first-result (explode$ ?reply)))) 

(defrule partTwo 
(existing-text "n") 
=> 
(bind ?reply (get-text-from-user "give me a number")) 
(assert (credit-value-bsc-second-result (explode$ ?reply)))) 

(defrule learn-about-120? 
(credit-value-bsc-first-result ?n) 
(credit-value-bsc-second-result ?x) 
(test (or (<= ?n 20) (<= ?x 20))) 
=> 
(bind ?reply (get-text-from-user "Reponse here)")) 
(assert (learn-about-120-response ?reply))) 

別のシナリオでは、とを使用して作業する最終ルールを取得できます。これをwxCLIPSにロードするときにエラーは表示されませんが、実行して関連するデータを入力すると、最終ルールは起動しません。

答えて

0

実際のcredit-value-bc-first-resultは、existing-textが "y"の場合にのみ作成されます。事実credit-value-bc-second-resultは、existing-textが "n"の場合にのみ作成されます。既存のテキストファクトが1つだけ存在する場合、これらの条件は相互に排他的です。 rule learn-about-120?これらの事実の両方が発射されないことが必要である。ルールをこのように書く

は、あなたが望むものはおそらくです:

(defrule learn-about-120? 
    (or (credit-value-bsc-first-result ?n) 
     (credit-value-bsc-second-result ?n)) 
    (test (<= ?n 20)) 
    => 
    (bind ?reply (get-text-from-user "Reponse here)")) 
    (assert (learn-about-120-response ?reply))) 
+0

はありがとうございました!私は、変数が空である可能性があると感じていました。 – Joe

関連する問題