CS 327: Artificial Intelligence

Assignment 2: Vacuum World

I discovered Henry at  http://www.henryvac.co.uk/.

Overview

For this assignment, you will develop code for Vacuum-World. Vacuum-World is an environment where a vacuum cleaner agent moves around, vacuuming up pieces of dirt. I have written the basic framework of Vacuum-World - you will enhance it and extend it.

Change Log

1/12/01: I Added directions to parts 1 and 2 indicating details on header comments to be added to the Lisp files.

Setting up

Whenever you start up CLISP to work on this assignment, you should always enter the following first:

(load "/Accounts/courses/cs327/aima/aima.lisp")

This loads the utilities that come with our textbook, Artificial Intelligence: A Modern Approach (AIMA).

Next, you should copy the Vacuum-World code into whichever directory you are doing your Lisp programming. Here is one example:

cp /Accounts/courses/cs327/assign2/vacuum.lisp ~

The "~" is shorthand for your own home directory.

You can now further copy or modify this program at will.

Getting started

After setting up as above, load the Vacuum-World into CLISP by typing

(load "vacuum.lisp")

You can then run the environment by typing

(run-vacuum 5 7) ; Put whatever numbers here you like

where 5 is the size of the x-axis, and 7 is the size of the y-axis. (Try varying these). You should then see a diagram of Vacuum-World, with the agent indicated by an "A", and dirt indicated by "#". Every time you press the Enter key, the agent will suck up dirt if there is some in the current position, or move forward in the direction in which the agent points. Above the grid, the recent percept list and action taken are shown. The percept list contains three positions:

(bump-sensor dirt-sensor home-sensor)

bump-sensor is T if the agent has just bumped into a wall.
dirt-sensor is T if there is a piece of dirt underneath the agent.
home-sensor is T of the agent is in its home location (bottom left).

If you continue to press Enter, the agent will slide up the left hand side of the room, then back down the left side again until it reaches its home position again. For more information on Vacuum-World, checkout out Problem 2.5 on page 51 in your text - I've modelled this Vaccum-World closely after the ideas presented there. The performance measurement, for example, is the same.

Your assignment

1. Copy the file "vacuum.lisp" to "vacuum_reflex.lisp". The function choose-action is a pure reflex agent. Why? Change the function choose-action so that it obtains a better performance measure. Why is it impossible, in general, to have a reflex agent that returns home when finished and shuts itself off? What prevents a reflex agent from doing very well? Include in the header documentation for vacuum_reflex.lisp an overview description of how your agent approaches the problem, and what parts of code you modified (if you change something other than choose-action which is not recommended).

2. Copy the file "vacuum.lisp" to "vacuum_state.lisp". Again change the function choose-action (and other aspects of the Lisp code if necessary) to add some form of internal state to the agent so that it performs better than your reflex agent above. How close does your agent come to the ideal agent for this environment? Is the environment:

Provide one sentence or so for each of the above justifying your answer. Include in the header documentation for vacuum_state.lisp an overview description of how your agent approaches the problem, and what parts of code you modified.

What to turn in

Turn in two Lisp files: vacuum_reflex.lisp, and vacuum_state.lisp. I should be able to test your code by starting CLISP and typing:

> (load "vacuum_reflex.lisp")  ; similarly with vacuum_state

> (run-vacuum 3 7)  ; or whatever values I choose

You should also turn in a flat file called hw2.txt, which contains the answers to all questions asked above.