In this lab session we will finish lab 1 and write a new kind of agent program mantaining a state.
;; OLD declaration (defun random-agent-program (percept) ;; NEW declaration (defun random-agent-program (agent percept)
;; HINT: getting the value of the state field in the agent structure (agent-state agent) ;; HINT: setting a new value for the state field (setf (agent-state agent) <new value>)
'suck
action when visiting a dirty square otherwise one of the following actions: 'right
, 'left
, 'up
or 'down
.'idle
(i.e. forever).;; HINT: getting the first item in a list CL-USER> (first '(a b c)) A
;; HINT: adding an element to a list. ;; cons takes an item and a list, and returns a new list consisting of ;; the old list with the item tacked on the front. CL-USER> (setf my-list '(a b c)) (A B C) CL-USER> (setf my-list (cons 'item my-list)) (ITEM A B C)
;; HINT: checking for a list argument. ;; consp is a predicate which is true if its argument is a list... CL-USER> (consp '(4 3 8)) T ;; ...but is not nil CL-USER> (consp nil) NIL
;; HINT: remember to load the definitions in "agent2.lisp" as shown in step 7 of Lab 1. (run-experiment (generate-environments 3 3 2) (lambda () (make-agent :program #'example-agent-program)) #'example-measure 1000)
This will return the number of experiments performed, and the average performance value.