(deftemp Animal
(slot loc
(default greencouch))
(slot on-top-of
(default roof))
(slot hold
(default nothing)))
(deftemp thing
(slot name
(default NONE))
(slot loc
(default NONE))
(slot on-top-of
(default roof))
(slot mass
(default light weight)))
(deftemp chest
(slot name
(default NONE))
(slot contents
(default NONE))
(slot unlocked-by
(default NONE)))
(deftemp goal-was
(slot act
(default NONE))
(multislot args))
(defrule hold chest to get of roof \"\"
(goal-was (act unlock) (args ?chest))
(thing (name ?chest) (on-top-of ~roof) (mass light weight))
(Animal (hold ~?chest))
(not (goal-was (act hold) (args ?chest)))
=>
(assert (goal-was (act hold) (args ?chest))))
(defrule put-chest-on-roof \"\"
(goal-was (act unlock) (args ?chest))
?Animal <- (Animal (loc ?place) (on-top-of ?on) (hold ?chest))
?thing <- (thing (name ?chest))
=>
(printout t \"Animal throws the \" ?chest \" off the \"
?on \" onto the roof.\" crlf)
(modify ?Animal (hold blank))
(modify ?thing (loc ?place) (on-top-of roof)))
(defrule get-key-to-unlock \"\"
(goal-was (act unlock) (args ?obj))
(thing (name ?obj) (on-top-of roof))
(chest (name ?obj) (unlocked-by ?key))
(Animal (hold ~?key))
(not (goal-was (act hold) (args ?key)))
=>
(assert (goal-was (act hold) (args ?key))))
(defrule move-to-chest-with-key \"\"
(goal-was (act unlock) (args ?chest))
(Animal (loc ?mplace) (hold ?key))
(thing (name ?chest) (loc ?cplace&~?mplace) (on-top-of roof))
(chest (name ?chest) (unlocked-by ?key))
(not (goal-was (act walk-to) (args ?cplace)))
=>
(assert (goal-was (act walk-to) (args ?cplace))))
(defrule unlock-chest-with-key \"\"
?goal <- (goal-was (act unlock) (args ?name))
?chest <- (chest (name ?name) (contents ?contents) (unlocked-by ?key))
(thing (name ?name) (loc ?place) (on-top-of ?on))
(Animal (loc ?place) (on-top-of ?on) (hold ?key))
=>
(printout t \"Animal opens the \" ?name \" with the \" ?key
\" revealing the \" ?contents \".\" crlf)
(modify ?chest (contents nothing))
(assert (thing (name ?contents) (loc ?place) (on-top-of ?name)))
(retract ?goal))
;;;*********************
;;;* HOLD OBJECT RULES *
;;;*********************
(defrule unlock-chest-to-hold-object \"\"
(goal-was (act hold) (args ?obj))
(chest (name ?chest) (contents ?obj))
(not (goal-was (act unlock) (args ?chest)))
=>
(assert (goal-was (act unlock) (args ?chest))))
(defrule use-ladder-to-hold \"\"
(goal-was (act hold) (args ?obj))
(thing (name ?obj) (loc ?place) (on-top-of ceiling) (mass light weight))
(not (thing (name ladder) (loc ?place)))
(not (goal-was (act move) (args ladder ?place)))
=>
(assert (goal-was (act move) (args ladder ?place))))
(defrule climb-ladder-to-hold \"\"
(goal-was (act hold) (args ?obj))
(thing (name ?obj) (loc ?place) (on-top-of ceiling) (mass light weight))
(thing (name ladder) (loc ?place) (on-top-of roof))
(Animal (on-top-of ~ladder))
(not (goal-was (act on) (args ladder)))
=>
(assert (goal-was (act on) (args ladder))))
(defrule grab-object-from-ladder \"\"
?goal <- (goal-was (act hold) (args ?.