Computer Science 315
Round round get around
Assignment 1 - AIMIA Chapter 2
I get around
Get around round round I get around
The Beach Boys,
"I Get Around" (1962)
Due Monday, 17 September
Reading Assignment: Artificial Intelligence: A Modern
Approach Chapter 2
In this problem set, you will write a Python implementation of the vacuum-cleaner agent described
in Exercise 2.7 (page 57) of the textbook. Your "vacuuum cleaner" will actually
be a Quagents bot, and the "dust balls" will be packages of tofu (health), but
otherwise the task is the same. Lucky for you, all the code for the simulation of the
vacuum-cleaner world has been written already. You'll re-use the
quagent_client.py code from Assignment 0.
All you need to do for the current assignment is download
hoover.py and write a little HooverAgent
class to take the appropriate actions. This class should be defined in a file called
At minimum, HooverAgent should contain a takeAction method.
This method should take self and a HooverWorld object as its argument
and should return one of the following characters:
Programming Assignment: Vacuum World
In other words:
- 'l': turn left
- 'r': turn right
- 'f': go forward
- 's': suck up dirt
- 'o': turn off vacuum
def takeAction(self, world):
# your code here
HooverAgent may contain whatever constructor, private methods and internal state (instance)
like; however, the only information it can get from HooverWorld is through the
following HooverWorld methods, which take no arguments:
Typing python hooover.py in Linux will launch everything and give you a
view of your agent in action. (There's no need to look at hoover.py unless you're interested
in how it works internally.)
Once you turn the vacuum off (by returning 'o' from takeAction), you will be shown
your final score. This score differs somewhat from the scoring in the book: in our implementation, you
get 100 points for each piece of dirt picked up, you lose one point for each action taken, and you
get 500 extra points for ending up at home base.
To get started, just have takeAction return 'l' so that your agent always turns
Note that you do not need a very complicated agent (takeAction method) to
solve the problem.
My hoover_agent.py was only 36 lines of code, about half of it comments.
Because the simulator is nondeterministic (noisy, somewhat random), you may find it useful
to add some nondeterminism of your own; e.g., by making a random move every now and then
if the agent gets stuck.
- touchSensor: returns True if agent has hit a wall, False otherwise
- photoSensor: returns True if agent is over a patch of dirt, False otherwise
- infraSensor: returns True if agent is at home base, False otherwise
- isClean: returns True if all dirt has been picked up, False otherwise
You should turn in exactly one file hoover_agent.py,
as an email attachment
to me. I encourage you to add comments at the top of the file explaining
how your solution works.
Good luck, and please remember to clean under the sofa.
1"Hoover" is easier to spell than "Vacuum", and sounds funnier too.
While you're at it, check out Roomba:
these guys are laughing all the way to the bank! For an earlier version of
the project, look