;deftemplates (deftemplate trip (slot payment) (slot interest) (slot destination)) (deffacts ourfacts (ask-question)) (deffunction ask-question (?question $?allowed-values) (bind ?ans (get-text-from-user ?question)) (bind ?answer none) (if (eq ?ans "") then (halt) else (bind ?answer (string-to-symbol (lowcase ?ans))) (while (and (not (member ?answer ?allowed-values)) (neq ?ans "")) do (bind ?ans (get-text-from-user ?question)) (bind ?answer (string-to-symbol (lowcase ?ans))) ) ) ?answer) (defrule question-1 "" ?rem <- (ask-question) => (retract ?rem) (bind ?response (ask-question "Do you prefer sun or snow? " sun snow)) (assert (trip (payment blank) (interest ?response)))) (defrule question-2 "" ?rem <- (trip (payment blank)) => (bind ?response (ask-question "Are you paying with cash, check, or charge? " cash check charge)) (modify ?rem (payment ?response))) ;(deffunction app-on-init () ; (unwatch all) ; (show-ide-window) ; (reset) ; (run) ; (return 0) ;) ;defrules (defrule Huntington-Beach (trip (payment cash) (interest sun)) => (assert (trip (destination Huntington))) (printout t " You are going to Huntington Beach" crlf) (bind ?word(message-box "You are going to Huntington beach"))) (defrule Hawaii-Beach (trip (payment check) (interest sun)) => (assert (trip (destination Hawaii))) (printout t " You are going to Hawaii" crlf) (message-box "You are going to Hawaii")) (defrule Hawaii-Beach2 (trip (payment charge) (interest sun)) => (assert (trip (destination Hawaii))) (message-box "You are going to Hawaii") (printout t " You are going to Hawaii" crlf)) (defrule Aspen-Mtn (trip (payment cash) (interest snow)) => (assert (trip (destination Aspen))) (message-box "You are going to Aspen") (printout t " You are going to Aspen" crlf)) (defrule Aspen-Mtn2 (trip (payment check) (interest snow)) => (assert (trip (destination Aspen))) (message-box "You are going to Aspen") (printout t " You are going to Aspen" crlf)) (defrule Alpes-Mtn (trip (payment charge) (interest snow)) => (assert (trip (destination Alpes))) (message-box "You are going to Alpes") (printout t " You are going to the Swiss Alpes" crlf))