;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; EATING WITHIN A 2-POINT GRIDWORLD ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; We define a small Gridworld with 2 places (home, grove1) connected ;; by path1. The robot ME is initially at home, and there is a banana ;; (banana1) at home, and bananas are known to be edible. There is a ;; tree (apple-tree1) at grove1, which has an apple (apple1), and apples ;; are also known to be edible. The robot is initially hungry, and it ;; has 3 operators: eat, sleep, and walk. Eating something edible, ;; located at the same place as the robot, makes the robot not-hungry ;; (and makes the thing eaten be not-edible, and not at the current ;; location). Sleeping is only possible if ME is not hungry, and its ;; effect is to make ME hungry. Walking from ?x to ?y on road ?z ;; requires that both ?x and ?y are on ?z, and that ME is initially ;; at ?x. Its effect is to place ME at ?y, and to make ME hungry. ;; First (load "gridworld-definitions.lisp") ;; and (load "gridworld-planning.lisp") ;; and then (load "eg-eating-world3.lisp") ;; (which is this file) ;; Possible continuation: ;; (initialize-state) ;; (go!) ;; (go!) ;; (go!) ;; etc. The interesting thing here is that when ME first plans ahead, ;; it foresees eating the banana (at home), sleeping (& waking up ;; hungry), then going to grove1 (because there's nothing else it ;; can foresee doing), AND THEN GOING BACK HOME WITHOUT EATING THE ;; APPLE AT GROVE1, THEN GOING BACK TO GROVE, ETC. (A positive value ;; has been attached to walking, so ME will walk back & forth forever, ;; hungry but unfazed -- no provision has been made for exhaustion). ;; THE REASON IT DOESN'T YET PLAN TO EAT THE APPLE IS BECAUSE IT DOESN'T ;; KNOW YET IT'S THERE. But when it gets to grove1, it learns all the ;; "local facts" (those attached as a property to the `grove1' symbol, ;; under indicator `facts') (def-roadmap '(home grove1) '((path1 home grove1))); 2 points, 1 road (def-object 'robot '(is_animate can_talk)) (def-object 'tree '(is_alive is_inanimate)) ; (def-object 'apple '(edible)); no good -- it's no longer edible when eaten! ; (def-object 'banana '(edible)); ----------------ditto ------------------ (place-object 'ME 'robot 'home 0 nil ; no associated-things '((hungry me)) nil) ; no propositional attitudes (place-object 'apple-tree1 'tree 'grove1 0 nil ; We'll supply apple separately nil nil ) ; no other current-state facts or prop. attitudes (place-object 'apple1 'apple 'grove1 0 nil ; no associated-things '((edible apple1) (has apple-tree1 apple1)) nil ) ; no prop. att.'s (place-object 'banana1 'banana 'home 0 nil ; no associated-things '((edible banana1)) nil ) ; no prop. attitudes (setq eat (make-op :name 'eat :pars '(?x ?y ?z); ?x eats ?y at ?z :preconds '((is_at ?x ?z) (is_at ?y ?z) (edible ?y) (hungry ?x)) :effects '((not (is_at ?y ?z)) (not (edible ?y)) (not (hungry ?x)) ) :value 2 )); NB: happiness independent of eater (setq sleep (make-op :name 'sleep :pars '() :preconds '((not (hungry me))) :effects '((hungry me)) :value 2 )) (setq walk (make-op :name 'walk :pars '(?x ?y ?z); walk from point ?x to :preconds '((is_at ME ?x) ; point ?y on road ?z (is_on ?x ?z) (is_on ?y ?z) ) :effects '((is_at ME ?y) (not (is_at ME ?x)) (hungry ME) ) :value 1 )) (setq *operators* '(eat sleep walk)) (setq *search-beam* (list (cons 4 *operators*) (cons 3 *operators*) (cons 3 *operators*) )) ;; The state-value function here is presumed to be the generic one ;; in `develop.lisp'. ;; A SAMPLE RUN IS SHOWN IN "eg-eating-world3-output.lisp". ;;==========================================================