public:t-622-arti-11-1:lab_2_materials
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| public:t-622-arti-11-1:lab_2_materials [2011/01/19 12:00] – angelo | public:t-622-arti-11-1:lab_2_materials [2024/04/29 13:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | === Lab 2: Comparing Agent Programs | + | === Lab 2: Comparing Agent Programs === | 
| In this lab session we will finish [[public: | In this lab session we will finish [[public: | ||
| - | - **Getting Started**: | + | - **Getting Started**: | 
| - In order to run the experiments later, you can use both functions: **random-agent-program** and **random-agent-measure** from lab 1 (that means you can copy them in the new file **agents2.lisp** =)); | - In order to run the experiments later, you can use both functions: **random-agent-program** and **random-agent-measure** from lab 1 (that means you can copy them in the new file **agents2.lisp** =)); | ||
| - You only have to change the **random-agent-program** declaration in order to accommodate a small change in the way the function is called during experiments.< | - You only have to change the **random-agent-program** declaration in order to accommodate a small change in the way the function is called during experiments.< | ||
| Line 11: | Line 11: | ||
| (defun random-agent-program (agent percept) | (defun random-agent-program (agent percept) | ||
| </ | </ | ||
| - | - **Creating | + | - **Creating | 
| - | * Uses the STATE field of the agent struct to remember what squares has already visited (and eventually cleaned). Remember you can use this field in this way: <code lisp> | + | * Uses the **STATE** field of the agent struct to remember what squares has already visited (and eventually cleaned). Remember you can use this field in this way: <code lisp> | 
| ;; HINT: getting the value of the state field in the agent structure | ;; HINT: getting the value of the state field in the agent structure | ||
| (agent-state agent) | (agent-state agent) | ||
| Line 18: | Line 18: | ||
| (setf (agent-state agent) <new value>) | (setf (agent-state agent) <new value>) | ||
| </ | </ | ||
| - | * The agent should walk randomly, but it should avoid revisiting squares that has already visited (and the are already | + | * The agent should walk **randomly**, but it should avoid revisiting squares that has already visited (and then already | 
| * The agent' | * The agent' | ||
| - | * If the agent is sure everything is clean, it should return the action **''' | + |  | 
| - | * Be careful not to be to strict, e.g. if you make it absolutely impossible for the agent to travel through clean squares | + |  | 
| - | - Use the functions at the bottom of agents2.lisp to run experiments and evaluate your agent. | + | * Be careful | 
| + | * **NOTE 1**: when you are ready to fill in the agent program code you'll see that the agent stores the state as a list of squares id that it has seen (and clean) already. It would be useful for you to remember the following regarding lists:< | ||
| + | ;; 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 | ||
| + | </ | ||
| + | * **NOTE 2**: in order to keep track of the squares already seen, you can use two helper | ||
| + | - **Running Experiments**: | ||
| + | ;; HINT: remember to load the definitions in " | ||
| (run-experiment (generate-environments 3 3 2) | (run-experiment (generate-environments 3 3 2) | ||
| - | (lambda () (make-agent :program #'random-agent-with-state-program)) | + | (lambda () (make-agent :program #'example-agent-program)) | 
| - | #'perf-measure | + | #'example-measure | 
| 1000) | 1000) | ||
| - | </ | + | </ | 
| - | - Try different agents (e.g. stateless | + | - **Comparing Different Agents**: | 
| - | - **BONUS** If you finish the stateful agent and running the experiments, | + | - **Building an Orderly Agent (EXTRA)**:\\ Try to create | 
/var/www/cadia.ru.is/wiki/data/attic/public/t-622-arti-11-1/lab_2_materials.1295438418.txt.gz · Last modified: 2024/04/29 13:32 (external edit)
                
                