CLIPS让我非常困惑。我在.clp文件中定义了一个deftemplate和一个规则。CLIPS deftemplate错误插槽类型
(deftemplate basic-ch "Basic characteristics template"
(slot ch-name
(type SYMBOL)
(default ?DERIVE)
)
(slot score
(type INTEGER)
(default 1)
(range 1 5)
)
)
(defrule make-ch
?get-ch <- (get-ch TRUE)
=>
(printout t "Enter ch name" crlf)
(bind ?name (read))
(printout t "Enter ch score" crlf)
(bind ?score (read))
(assert (basic-ch (ch-name ?name) (score ?score)))
(retract ?get-ch)
)
当我(断言(get-ch真))和(运行),它会提示我ch名和得分。但是,如果我为分数输入字符串,则字符串分数会被规则断言!例如:
Enter ch name
hello
Enter ch score
hello
;(basic-ch (ch-name hello)(score hello)) get asserted?!
这怎么可能?我将分数定义为INTEGER,甚至提供了范围。我怎样才能阻止呢?