CS430/530 Program 2 (Due October 16, 1999)

In this assignment, you will design and implement a rule-based agent for the vacuum-cleaner world. The full vacuum-cleaner world is described in Chapter 2 problem 2.5. The world has already been implemented in an extensive package of code described below. You will need to become familiar with this code during the course.

1. Assignment

Implement an environment for an m by n rectangular room where each square has a 20% chance of containing dirt. Each time an instance of this environment is created, m and n should be chosen uniformly from the range 8 to 15 inclusive. This means that the agent will not know the size of the room when it first starts up. You can implement this by specializing the existing vacuum-world environment along the following lines:
(defstructure (nxm-vacuum-world (:include vacuum-world
   ;; your code goes here
  ))
  "An mxn grid with dirty rooms.")

Then implement an agent with internal state that sucks up all of the dirt, returns to its home position, and shuts off. You will need to decide what state information the agent needs to maintain. You can define your agent by specializing the existing general agent agent. The general structure of the code should look like the following:

(defstructure (state-vacuum-agent  ; name of this agent
   (:include agent                 ; specializes the AGENT class
    (program 
     (let ((location '(1 1))       ; state variables with their initial values
	   (heading 'east))

        #'(lambda (percept)
            ;; use percept to update state
            ;; choose action
            ;; use chosen action to update the state
            ;; return chosen action
          ))))))
In this code, the let special form is used to define two state variables location and heading. You may decide to use different state variables or to include additional state variables. The lambda expression defines a function that is closed over these state variables. This makes these state variables act like static variables in C or C++. Any expression in the body of this lambda expression can access the location and heading variables. The agent's program entry must be a function of one argument (the percept), and it must return the chosen action.

In the vacuum-world environment, the percept is a list of three elements: (bump dirt home). Each of these elements is a boolean indicating whether the bump sensor, dirt sensor, and home sensor are returning true. Please note that it is possible to have more than one "unit" of dirt within a cell. Hence, after doing a "suck" action, there may still be dirt in the cell.

While debugging your agent, I suggest that you constrain the world to be fairly small (e.g., 4 by 4, which means 6 by 6 when you count the walls). To test your agent, use

(run-environment (make-nxm-vacuum-world :max-steps 100))

This will run the default agent for up to 100 steps on the nxm-vacuum-world.

When you have your agent debugged, you should compare its performance to the agent called reactive-vacuum-agent that is provided by Russell and Norvig. You do this using the following:

(agent-trials 'make-nxm-vacuum-world
              '(state-vacuum-agent reactive-vacuum-agent)
              :n 10) 

where the 10 specifies that each agent will be run on 10 random nxm-vacuum-world's and the results averaged and reported.

2. What to turn in

You should turn in your code, a trace of your agent running on a small (e.g., 4 by 4) environment, and a trace of the agent-trials run. Your code should clearly explain what it is doing. In particular, please explain the meaning of each of your state variables. You should try to get a good score on the performance criterion (which gives 100 points for each dirt object you vacuum up, -1 point for each action, and -1000 points if the agent is not in its home location when it shuts off. Please email your solution to the TA {wangha@cs.orst.edu) and also turn in a hardcopy at the start of class.


Last updated Fri Oct 6 23:06:11 2000 bda