(defrule start (initial-fact) => (assert (door start room1)) (assert (door room1 room2)) (assert (door room2 room3)) (assert (door room3 room4)) (assert (location crate room4 middle)) (assert (location bananas room4 bottom top)) (assert (location monkey start)) (assert (push goal "monkey full" 0 0)) (assert (stacktop goal 0)) ) (defrule move1 ?lm <- (location monkey start) (door start room1) => (assert (location monkey room1)) (retract ?lm) (printout t "move from start to 1" crlf) ) (defrule move2 ?lm <- (location monkey room1)(door room1 room2) => (assert (location monkey room2)) (retract ?lm) (printout t "move from 1 to 2" crlf) ) (defrule move2a ?lm <- (location monkey room2)(door room1 room2) => (assert (location monkey room1)) (retract ?lm) (printout t "move from 2 to 1" crlf) ) (defrule move3 ?lm <- (location monkey room2) (door room2 room3) => (assert (location monkey room3)) (retract ?lm) (printout t "move from 2 to 3" crlf) ) (defrule move4 ?lm <- (location monkey room3)(door room3 room4) => (assert (location monkey room4)) (retract ?lm) (printout t "move from 3 to 4" crlf) ) (defrule moveCrate (location monkey room4) ?lc <- (location crate room4 middle) (location bananas room4 bottom top) => (assert (location crate room4 bottom)) (retract ?lc) (printout t "move crate" crlf) ) (defrule climbCrate ?lm <- (location monkey room4) (location crate room4 bottom) (location bananas room4 bottom top) => (assert (location monkey room4 onCrate)) (retract ?lm) (printout t "climb" crlf) ) (defrule getBananas (location monkey room4 onCrate) ?lb <- (location bananas room4 bottom top) => (assert (location bananas withMonkey)) (retract ?lb) (printout t "get" crlf) ) (defrule eatBananas ?lb <- (location bananas withMonkey) => (assert (monkey full)) (retract ?lb) (printout t "eat" crlf) )