Vacuum World

Henry the Vacuum

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. The basic framework for Vacuum-World has been provided for you - you will enhance it and extend it.

Setting up

Set up CLISP so that it has access to the the textbook libraries. To do this, use your favorite text editor to create a file named .clisprc.lisp in your home directory. This file should have three lines, which are:

(load "/Accounts/courses/cs327/aima/aima.lisp")
(unuse-package 'EXT)
(aima-load 'agents)

(If you're working from home, you'll have to install the textbook libraries. Here are instructions on how to do so. You'll then need to modify the .clisprc.lisp accordingly.)

Start CLISP. If you have done this correctly, you should see a series of "Loading file..." comments when CLISP starts up. This loads the utilities that come with our textbook, Artificial Intelligence: A Modern Approach (AIMA). Next, save this sample vacuum lisp code into whichever directory you are doing your Lisp programming.

Getting started

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

(load "silly-vacuum-agent.lisp")

You can then run the environment by typing

(run-environment (make-vacuum-world :size '(5 7) :aspec '(silly-vacuum-agent)))

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 a "1", 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 BUMP if the agent has just bumped into a wall, and NIL otherwise.
dirt-sensor is DIRT if there is a piece of dirt underneath the agent, and NIL otherwise.
home-sensor is HOME if the agent is in its home location (bottom left), and NIL otherwise.

If you continue to press Enter, the agent will slide across the bottom side of the room, then back across the bottom side again until it reaches its home position again.

Your assignment

  1. (Due Wednesday) Experiment with the agent that I gave you, and play with different environment sizes. In your own words, explain what this agent does. After each move, the simulator will give a performance measure that looks like [1 = -789]. This states that agent 1, your vacuum, has a current performance measure of -789. How is performance measured? What events cause positive and negative rewards, and how much?
  2. (Due Wednesday) Copy the file "silly-vacuum-agent.lisp" to "reflex-vacuum-agent.lisp" and make a similar appropriate name change in your Lisp code for the structure definition. This agent is essentially a simple reflex agent, but technically not quite. Why? Modify the agent so that it obtains a better performance measure, without adding any additional state storage (don't change that let statement). Why is it impossible, in general, to have a simple reflex agent that returns home when finished and shuts itself off? Is a simple reflex agent the most rational one that can be placed into this environment? Why or why not? Include in the header documentation for reflex-vacuum-agent.lisp an overview description of how your agent approaches the problem.

    Can a simple reflex agent with a randomized agent function outperform a simple reflex agent? Describe circumstances where randomization would help improve the performance of your agent in part 1.

    Provide your answers to all of these questions in header documentation for your submitted Lisp code.

  3. (Due Saturday) Copy the file "reflex-vacuum-agent.lisp" to "state-vacuum-agent.lisp" and make a similar appropriate name change in your Lisp code for the structure definition. Change the agent to add some form of internal state so that it performs as close to perfectly rational as you can. Is the task environment:
    • Fully observable or partially observable?
    • Deterministic, stochastic, or strategic?
    • Episodic or sequential?
    • Static or dynamic?
    • Discrete or continuous?
    • Single agent or multiagent?
    Provide one sentence or so for each of the above justifying your answer in header documentation to your code. Also include in the header documentation for state-vacuum-agent.lisp an overview description of how your agent approaches the problem.

How we will test

I should be able to test your code by starting CLISP and typing:

> (load "reflex-vacuum-agent.lisp")  ; similarly with vacuum_state

> (run-environment (make-vacuum-world :size '(3 9) :aspec '(reflex-vacuum-agent)))  ; or whatever size I choose

FAQs

Q: How do I get the program to not make me hit Enter after every move?

A: Comment out the function read-line.

Q: How much information does the agent have about the environment? For example, does it know its dimensions? Does it know that it is always in the bottom left corner at the beginning?

It has no information at all apart from what comes via the percept parameter. So it doesn't know dimensions, which change depending on the environment.

The starting position of the agent can also be changed with the :start parameter, like so:

(run-environment (make-vacuum-world :size '(5 7) :start '(2 2) :aspec '(silly-vacuum-agent)))

We won't use that in testing your code, however, unless you tell us to. So go ahead and just assume your agent starts in the lower left corner, unless you'd like an extra challenge (which I encourage you to do!).

Q: Is it possible for the agent to take two actions in response to a percept? For example, can we make the agent suck and then turn left when it encounters dirt?

A: No, one action per percept. But you might use internal state to remember that you're trying to do something.