1 / 18

01/09/98 LISP Agent Continued

01/09/98 LISP Agent Continued. Administrative PS0 out, PS1 assigned next Monday Last time agent design and demo the top-level agent loop LISP concepts Symbols, including T and NIL Conditionals, including IF and WHEN Lexical variables, including LET and LET*

ehudson
Download Presentation

01/09/98 LISP Agent Continued

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 01/09/98 LISP Agent Continued • Administrative • PS0 out, PS1 assigned next Monday • Last time • agent design and demo • the top-level agent loop • LISP concepts • Symbols, including T and NIL • Conditionals, including IF and WHEN • Lexical variables, including LET and LET* • Side-effecting and “pure” functions • This time • high-level architecture: percepts, behaviors, macros • code for percepts and behaviors

  2. Matching Agent Behaviors Macro-actions Percepts Truckworld Architecture Overview Behavior selection and execution Macro expansion Action execution Sensing Primitive actions and sensing

  3. Perception • A percept is a record of everything the agent knows about the world at the present time • obviously depends both on the world and on the agent’s sensing capabilities • Truckworld: agent can perceive certain features of • the objects at its current location • the objects it is holding and in its cargo bays • its internal status (fuel, heading, speed, status) • Truckworld sensors return raw sensing reports which must be coalesced into one percept

  4. A Truckworld Sensing Report (SENSOR TRUCK-SENSOR ( ((POSITION 0) (KIND ROADSIGN) (DIRECTION E) ...) ((POSITION 2) (KIND GARBAGE) (VALUE 10)) ((POSITION 3) (KIND GLASS) (COLOR GREEN)) ((POSITION 4) (KIND FUEL-DRUM-DISPENSER)) ((POSITION 5) (KIND ATM)) ((POSITION 6) (KIND GARBAGE-CAN)) ((POSITION 7) (KIND GLASS-RECYCLER)) ((POSITION 8) (KIND FUEL-DRUM-CONSUMER)) ((POSITION 9) (KIND TRUCK) (TRUCK-ID TRUCK-5))) an object an attribute and value a sensor report

  5. Sensor Reports to Percepts • A percept is a collection of sensor reports from • the truck sensor • the two cargo bays • the fuel tank all packaged into one data structure • Support routines we need for percepts • create one from a set of sensor reports • find a fuel-drum-consumer outside • find an empty space in BAY-1 • return the current fuel level

  6. The Percept Data Structure (defstruct percept location-contents bay-1-contents bay-2-contents fuel-level) (defun find-objects (percept kinds location) (case location ((:OUTSIDE) (find-objects-at kinds (percept-location-contents percept))) ((BAY-1) (find-objects-at kinds (percept-bay-1-contents percept))) ((BAY-2) (find-objects-at kinds (percept-bay-2-contents percept))) (OTHERWISE (error "Don't understand location ~a" location))))

  7. Processing Percepts (cont.) (defun find-objects-at (kinds percept-list) (mapcar 'object-position (remove-if-not #'(lambda (object) (member (object-kind object) kinds)) percept-list))) ’(glass garbage) ’((POSITION 0) (KIND ROADSIGN) (DIRECTION E)) ((POSITION 2) (KIND GARBAGE) (VALUE 10)) ((POSITION 3) (KIND GLASS) (COLOR GREEN)) ((POSITION 4) (KIND FUEL-DRUM-DISPENSER)) ((POSITION 5) (KIND ATM)) ((POSITION 6) (KIND GARBAGE-CAN)) ((POSITION 7) (KIND GLASS-RECYCLER)) ((POSITION 8) (KIND FUEL-DRUM-CONSUMER)) ((POSITION 9) (KIND TRUCK) (TRUCK-ID TRUCK-5))))

  8. Definition of object-kind

  9. Summary of percept • A single data structure that captures all sense data • Supports operations like • find me all objects with this kind at this location • find me an empty position at this location • tell me what the fuel level is • Will be created by the sense behavior • Will be examined • in deciding what behavior to do next • in deciding what a chosen behavior should do

  10. Behaviors • A behavior is a mapping from a percept to a (macro)action. • a macro-action is a fixed sequence of Truckworld primitives, like • pick up the object at position 3 outside using ARM-1 • pour the fuel drum currently being held by ARM-1 • Behaviors must be selected and executed • selection by name • selection by “contention”

  11. Behavior Structure Definition (defstruct (behavior (:print-function print-behavior)) name test action) (defun print-behavior (self stream indent) (declare (ignore indent)) (format stream "{B ~a}" (behavior-name self))) (defvar *behaviors*) (defun define-behavior (&key name test action) (setf *behaviors* (add-to-end (make-behavior :name name :test test :action action) *behaviors*)))

  12. Definition of add-to-end

  13. Choosing and Executing Behavior (defun find-behavior (name) (find name *behaviors* :key 'behavior-name)) (defun choose-behavior (percept) (first (remove-if-not #'(lambda (b) (funcall (behavior-test b) percept)) *behaviors*))) (defun execute-behavior (b percept) (funcall (behavior-action b) percept))

  14. Defining Behaviors • We now know that a behavior is a test and an action, both functions of a percept. • What are reasonable behaviors for the collection world? • Must depend only on the current percept • Goal is to have them as “low level” as possible while still having them “functional” • recycle all garbage and glass in the world • recycle the piece of glass at position 3, using ARM-1 and the recycler at position 4 • pick up the object at position 3 using ARM-2 • move ARM-2 to position 3

  15. Behavior definitions to accomplish our goals • Recycle all glass, garbage, and empty fuel drums • recycle objects when you have them and there is an appropriate recycler at hand • move from place to place • refuel when necessary

  16. Behavior for picking up a recyclable (define-behavior :name 'pickup-recyclable :test #'(lambda (percept) (and (find-empty-position percept 'BAY-1) (find-object percept '(glass garbage) :OUTSIDE))) :action #'(lambda (percept) (let ((bay-position (find-empty-position percept 'BAY-1)) (obj-position (find-object percept '(glass garbage) :OUTSIDE))) (execute-macrop `(pickup-from-outside ARM-1 ,obj-position)) (execute-macrop `(put-in-bay ARM-1 BAY-1 ,bay-position)))))

  17. Behavior for recycling an object (define-behavior :name 'recycle-object :test #'(lambda (percept) (some #'(lambda (kind) (and (find-object percept kind 'BAY-1) (find-object percept (recycler-for kind) :OUTSIDE))) (kinds-to-recycle))) :action #'(lambda (percept) (do ((kinds (kinds-to-recycle) (cdr kinds)) (done NIL)) (done) (let ((obj-position (find-object percept (car kinds) 'BAY-1)) (recycler-position (find-object percept (recycler-for (car kinds)) :OUTSIDE))) (when (and obj-position recycler-position) (execute-macrop `(pickup-from-bay ARM-1 BAY-1 ,obj-position)) (execute-macrop `(put-inside ARM-1 ,recycler-position)) (setf done T))))))

  18. Summary of behaviors • A behavior is a test and an action • both of functions (only) of the current percept • Behaviors are defined and placed on a global ordered list • Retrieval is either by name, or the first whose test is true given the current percept • Behaviors take action by executing macro-actions (macrops)

More Related