CSE472/572 KNOWLEDGE-BASED ARTIFICIAL INTELLIGENCE
Spring, 2000

HOMEWORK 1
(9 Points)
Due: February 1, 2000

Background

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

4. Read and try out the examples in the file agents/test-agents.lisp. For example, evaluate the following forms in order and observe the results:
```	(setf vw (make-vacuum-world))
(initialize vw)
(display-environment vw)
(run-environment vw)
(run-environment (make-vacuum-world))
(run-environment (make-vacuum-world :max-steps 10))
(run-environment (make-vacuum-world :stream nil))
(run-environment (make-vacuum-world :aspec '(random-vacuum-agent)))
(run-environment
(make-vacuum-world :aspec '(random-vacuum-agent) :max-steps 10))
(run-environment
(make-vacuum-world :aspec '(reactive-vacuum-agent) :max-steps 10))
(run-environment
(make-vacuum-world :cspec '((at all (P 0.9 dirt)))
:max-steps 10))
(agent-trials 'make-vacuum-world
'(reactive-vacuum-agent random-vacuum-agent)
:n 10)
```

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

Homework Exercises

1. (3 points) Evaluate the form
```(run-environment (make-vacuum-world :aspec '(ask-user-agent)))
```
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. Perform every action at least once, in an interesting variety of situations, and vacuum up at least some dirt.

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]
Do this by writing a `defstructure` based on and using the structure `vacuum-world` from the file `agents/environments/vacuum.lisp` but changing the `size` and `cspec` slots. Turn in this `defstructure` definition, and the printing of several instances of the environment showing some random variations.
(The Lisp function (random n) returns a random integer i, 0 <= i < n.)

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
```(defstructure (furniture (:include obstacle (name "@"))))
```
Then, we need to define a vacuum world with furniture as well as dirt:
```(defstructure
(vacuum-world-with-furniture
(:include vacuum-world
(cspec '((at all (P 0.25 dirt))
(at all (P 0.25 furniture)))))))
```

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.

Turn in this homework set by submitting an edited version of the following file before 2:00 PM, Tuesday, February 1, 2000.
```-------------------------------- cut here --------------------------------
;;; CSE 4/572 Homework 1
;;; Name:
;;; Course:
;;; Recitation:
;;;
;;; 1. (3 points) A transcript of the ask-user-agent in the vacuum world:

;;; 2. (3 points) The defstructure for the rectangular vacuum world:

;;;    Several rectangular vacuum worlds are:

;;; 3. (3 points) The defstructure for the rectangular vacuum world
;;;    with each room having a 10% chance of containing dirt and a 5%
;;;    chance of containing furniture:

;;;    Several rectangular vacuum worlds with furniture are:

-------------------------------- cut here --------------------------------
```

Back to CSE4/572 Syllabus.

Stuart C. Shapiro <shapiro@cse.buffalo.edu>