我有一个专家系统可以找出相应的动物。我已经插入了所有事实,但是当我尝试(运行)专家系统时,不问任何问题,何时第一个问题应显示为“动物大吗?”请问有人有什么想法。 预先致谢
(deffacts startup (animal mouse) (animal squirrel) (animal hamster) (animal giraffe) (animal elephant) (animal hippo)
(animal rhino) (animal big) (neck-long giraffe) (nose-long elephant) (swim-alot hippo) (animal-squeak mouse) (tail-bushy squirrel))
=>
(defrule is-animal-big
(not (animal-big ?))
=> (printout t "Is the animal big (yes or no)?")
(assert (animal-big (read))))
(defrule yes-big-check-neck
(animal-big yes)
(not (neck-long ?))
=>
(printout t "Is the animals neck long (yes or no)?")
(assert (neck-long (read))
)
(defrule neck-long-yes
(neck-long yes)
=>
(printout t "your animal is a giraffe" crlf)
(bind ?animal giraffe)
(assert (animal-is ? animal))
)
;;;========================================
(defrule neck-long-no-check-nose
(neck-long no)
(not (nose-long ?))
=>
(printout t "Is the animals nose long (yes or no)?")
(assert (nose-long (read))
)
(defrule nose-long-yes
(nose-long yes)
=>
(printout t "your animal is an elephant" crlf)
(bind ?animal elephant)
(assert (animal-is ? animal))
)
;;;=======================================
(defrule nose-long-no-check-swim
(nose-long no)
(not (swim-alot ?))
=>
(printout t "Does the animal swim a lot (yes or no)?")
(assert swim-alot (read((
)
(defrule swim-alot-yes
(swim-alot yes)
=>
(printout t "your animal is a hippo" crlf)
(bind ?animal hippo)
(assert (animal-is ? animal))
)
;;;=====================================
(defrule swim-alot-no
(swim-alot no)
=>
(printout t "your animal is a rhino" crlf)
(bind ?animal rhino)
(assert (animal-is ? animal))
)
;;;======================================
(defrule no-big-check-squeak
(animal-big no)
(not (animal-squeak ?))
=>
(printout t "Does the animal squeak (yes or no)?")
(assert animal-squeak (read))
)
(defrule animal-squeak-yes
(animal-squeak yes)
=>
(printout t "your animal is a mouse" crlf)
(bind ?animal mouse)
(assert (animal-is ? animal))
)
;;;=======================================
(defrule squeak-no-check-tail
(animal-squeak no)
(not (tail-bushy ?))
=>
(printout t "Is the animals tail bushy (yes or no)?")
(assert tail-bushy (read))
)
(defrule tail-bushy-yes
(tail-bushy yes)
=>
(printout t "your animal is a squirrel" crlf)
(bind ?animal squirrel)
(assert (animal-is ? animal))
)
;;;=======================================
(defrule tail-bushy-no
(tail-bushy no)
=>
(printout t "your animal is a hamster" crlf)
(bind ?animal hamster)
(assert (animal is ? animal)))
;;;==============================
;;;******************************
答案 0 :(得分:0)
您的代码充满语法错误,但是启动出现问题,而 is-animal-big 进行编译却没有错误。您可能没有在发出(运行)命令之前发出(重置)命令来断言您的事实中的事实。