CLIPS Program - rules

66 views
Skip to first unread message

ChucklesWK

unread,
Jul 26, 2012, 12:07:42 AM7/26/12
to clip...@googlegroups.com
I am unable to figure out why these won't fire from one rule to the next.  Can anyone help me?



(deftemplate choices "attributes to like or dislike"

(slot groceries (type STRING))

(slot prepackaged (type STRING))

(slot meat (type STRING))

(slot bulk (type STRING))

)


(defrule startrule "first rule to fire"

(initial-fact)

=>


  (printout t crlf)

  (printout t "What is the main item that you are looking to purchase?" crlf)

  (printout t "Is the main item that you purchasing meat, dairy, produce, cereal, or international food?" calf)

  (printout t "(type meat, dairy, produce, cereal, or international)" crlf)

  (bind ?answer1 (readline))

  (assert (choices (groceries ?answer1)) )

  (assert (secondquestion))

)




(defrule secondquestion "get meat type"

?temp <- (secondquestion)

(choices (groceries "meat") )

=>

  (retract ?temp)

  (printout t crlf)

  (printout t "Do you want your meat to be organic, kosher, or neither?" crlf)

  (printout t "(type organic, kosher, neither)" crlf)

  (bind ?answer2 (readline))

  (assert (choices (meat ?answer2))

  (assert (thirdquestion))

)


(defrule thirdquestion "get bulk answer"

?temp <- (thirdquestion)

(choices (meat "organic") )

=>

  (retract ?temp)

  (printout t crlf)

  (printout t "Do you want to purchase your meat from an butcher or prepackaged?" crlf)

  (printout t "(type butcher or prepackaged)" crlf)

  (bind ?answer3 (readline))

  (assert (choices (prepackaged ?answer3))

  (assert (fourthquestion))

)


Artem Novikov

unread,
Jul 26, 2012, 3:38:31 AM7/26/12
to clip...@googlegroups.com
Typo here:

(assert (choices (meat ?answer2))

add  ')':
 

(assert (choices (meat ?answer2)))


четверг, 26 июля 2012 г., 12:07:42 UTC+8 пользователь ChucklesWK написал:
Reply all
Reply to author
Forward
0 new messages