(defrule get-first-name
=>
(printout t "What is your first name ?? ")
(bind ?response (read))
(assert (users-name ?response))
(printout t "Oh Hello " ?response crlf )
)
(defrule add-sum
?di <- (data-item ?value&:(numberp ?value))
?old-total <- (total ?total)
=>
(retract ?old-total)
(retract ?di)
(assert (total (+ ?total ?value ) ) )
)
(deftemplate take-sticks
(slot how-many)
(slot for-remainder)
)
(deffacts take-sticks-information
(take-sticks (how-many 1 ) (for-remainder 1 ))
(take-sticks (how-many 1 ) (for-remainder 2 ))
(take-sticks (how-many 2 ) (for-remainder 3 ))
(take-sticks (how-many 3 ) (for-remainder 0))
)
(defrule computer-move
?whose-turn <- (player-move c)
?pile <- (pile-size ?size)
(test (> ?size 1))
(take-sticks (how-many ?number)
(for-remainder =(mod ?size 4)))
=>
(retract ?whose-turn ?pile)
(assert (pile-size (- ?size ?number)))
(assert (player-move h))
)