;; Jess version of Jackson, fig. 5.3 ;; ;; Implementation of a simple STRIPS planning system, which sets a goal ;; of moving a box and then executes operations to satisfy that goal. ;; TEMPLATES (deftemplate goal "Perform ACTION on OBJECT FROM location TO location" (slot action (type ATOM)) (slot object (type ATOM)) (slot from (type ATOM)) (slot to (type ATOM))) (deftemplate in "Where an object is" (slot object (type ATOM)) (slot location (type ATOM))) ;; FACTS (deffacts world "Initial state of the world" (in (object robot) (location RoomA)) (in (object box) (location RoomB)) (goal (action push) (object box) (from RoomB) (to RoomA))) ;; RULES (defrule stop "Stop when a goal has been achieved" (goal (object ?X) (to ?Y)) (in (object ?X) (location ?Y)) => (halt)) (defrule move "Move robot to the goal object's location" (goal (object ?X) (from ?Y)) (in (object ?X) (location ?Y)) ?robot-position <- (in (object robot) (location ?Z&~?Y)) => (modify ?robot-position (location ?Y))) (defrule push "If robot at goal object's location, push to destination" (goal (object ?X) (from ?Y) (to ?Z)) ?object-position <- (in (object ?X) (location ?Y)) ?robot-position <- (in (object robot) (location ?Y)) => (modify ?robot-position (location ?Z)) (modify ?object-position (location ?Z)))