0
我非常感謝我的CLIPS項目的一些幫助。CLIPS遞增變量沒有無限循環
好吧,我試圖創建一個狗品種顧問。在自定義模板看起來是這樣的:
(deftemplate breed
(multislot name)
(slot size)
(slot type-owner)
(slot Living_Space)
(slot children)
(slot grooming)
(slot exercise)
(slot noisiness)
(slot trainability)
(slot aggression)
(slot playfulness)
(slot excitability)
(slot score))
一個deffacts看起來是這樣的:
(deffacts dog-breeds
(breed (name Great_Dane)
(size 5)
(type-owner No)
(Living_Space 5)
(children 5)
(grooming 1)
(exercise 4)
(noisiness 2)
(trainability 1)
(aggression 2)
(playfulness 2)
(excitability 3)
(score 0))
所以我寫兩種類型defrules:一是收回不符合(用戶指定的)事實標準和其他每次事實符合標準時,類型都會增加「分數」值。只有少數規則可以收回,因此對增量規則起作用是很重要的。用戶輸入和每個插槽的標準可以從1到5.
我的問題是:如何更改以下代碼而不進入無限循環?最後,我想用最高分找出事實並展示它。
(defrule children
(input 1)
?children <- (breed (name ?)(size ?)(type-owner ?)(Living_Space ?) (children 1|2)(grooming ?)(exercise ?)(noisiness ?)
(trainability ?)(aggression ?)(playfulness ?)(excitability ?)(score ?score)
=>
(bind ?sc (+ ?score 1))
(modify ?children (score ?sc))
感謝,作品像一個魅力! –