(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))
)
(assert (choices (meat ?answer2)))