CS472/572 INTRODUCTION TO ARTIFICIAL INTELLIGENCE Spring, 1996

HOMEWORK 1
Due: February 2, 1996

Background

1. Run acl in the directory "/projects/shapiro/AIclass/Aimacode/".

4. Read and try out the examples in the file agents/test.lisp. For example, evaluate the following forms in order and observe the results:
```	(setq vw (make-vacuum-world))
(print-environment-map vw)
(run-eval-environment vw)
(run-vacuum)
(run-vacuum :display t :max-steps 10)
(vacuum-trials)
```

5. Study the definitions of random-vacuum-agent and reactive-vacuum-agent in the file agents/vacuum.lisp.

Homework Exercises

1. (3 points) Run the function
```(defun run-human-agent ()
(let* ((sag (vacuum-agent 'Me))
(senv (make-vacuum-world :p 0.75 :x-size 4 :y-size 4
:display t
:agents (list sag))))
(print-environment-map senv)
(run-vacuum :display t :max-steps 20 :agent sag :env senv)))
```
You will be asked to input the actions yourself. You should be able to determine what to enter by studying the code for random-vacuum-agent and reactive-vacuum-agent.

Turn in a copy of the interaction.

2. (3 points)
``Implement an environment for a n x m rectangular room, where each square has a 5% chance of containing dirt, and n and m are chosen at random from the range of 8 to 15, inclusive.''
[Exercise 2.7, p. 52, of the text]
One convenient way to do this is to define a function that takes a list of agents as an optional argument, and returns an environment as described above containing those agents. Turn in this function definition, and the printing of several instances of the environment showing some random variations.

3. (3 points) Exercise 2.11 in the text calls for adding furniture to the room. To do this, we first need to define furniture with
```(defstruct (furniture (:include obstacle (name "@"))))
```
Then, we need to write a function for making vacuum worlds with furniture as well as dirt:
```(defun make-vacuum-world-with-furniture
(&key (p-dirt .25) (p-furniture .25) (x-size 8) (y-size x-size)
(display nil) (agents (list (reactive-vacuum-agent 'A))))
"Generate a random vacuum world.
P-DIRT is the probability of dirt in a square.
P-FURNITURE is the probability of furniture in a square."
;; based on the funcion make-vacuum-world in Aimacode/agents/vacuum.lisp.
(init-environment
:name "Vacuum World"
:agents agents
:object-specs `((edge wall) (all (,p-dirt dirt))
(all (,p-furniture furniture)))
:x-size x-size :y-size y-size
:display display
:update-fn #'simple-grid-update-fn
:performance-fn #'vacuum-performance-fn
:percept-fn #'vacuum-world-percept))
```

Repeat Exercise 2 above, but make each square in the rooms have a 10% chance of containing dirt and a 5% chance of containing furniture.

Stuart C. Shapiro <shapiro@cs.buffalo.edu>
Thu Jan 25 16:32:27 EST 1996