Table of Contents

Lab 1 - Agents

Problem Description

Implement the control program for a vacuum cleaner agent. The environment is a rectangular grid of cells which may contain dirt or an obstacle. The agent is located in this grid and facing in one of the four directions: north, south, east or west. The agent can execute the following actions:

The robot is equipped with a dust sensor and a touch sensor. If there is dirt at current location of the robot, the agent will sense “DIRT”. If the robot is bumping into an obstacle, the agent will sense “BUMP”. The goal is to clean all cells and return to the initial location before turning the robot off. Note, a full charge of the battery of the robot will only last for 100 actions.

Tasks

  1. Develop a simple reflex vacuum cleaner agent. Is it rational? (Ok, this is a bit of a trick task. You should find out, that it is not actually possible to implement this with a simple reflex agent.)
  1. Develop a model-based reflex agent that is able to clean every cell. Is it rational?

To make it a bit easier you can use the following assumptions:

Material

The file contains code for implementing an agent in the src directory. The agent is actually a server process which listens on some port and waits for the real robot or a simulator to send a message. It will then reply with the next action the robot is supposed to execute.

The zip file also contains the description of an example environment (vacuumcleaner.gdl) a simulator (gamecontroller-gui.jar). To test your agent:

  1. Start the simulator (execute gamecontroller-gui.jar with either double-click or using the command “java -jar gamecontroller-gui.jar” on the command line).
  2. Setup the simulator as shown in this picture:

  1. Run the “Main” class in the project. If you added your own agent class, make sure that it is used in the main method of Main.java. You can also execute the “ant run” on the command line, if you have Ant installed.

The output of the agent should say “NanoHTTPD is listening on port 4001”, which indicates that your agent is ready and waiting for messages to arrive on the specified port.

  1. Now push the “Start” button in the simulator and your agent should get some messages and reply with the actions it wants to execute. At the end, the output of the simulator tells you how many points your agent got: “Game over! results: 0”. In the given environment you will only get non-zero points if you manage to clean everything, return to the initial location, and turn off the robot within 100 steps. If the output of the simulator contains any line starting with “SEVERE”, something is wrong. The two most common problems are the network connection (e.g., due to a firewall) between the simulator and the agent or the agent sending illegal moves.

You can see here, what the example environment looks like. Of course, you shouldn't assume any fixed size, initial location or locations of the dirt in your implementation. This is just an example environment.

Here I described how you visualise what your agent is doing.

Hints

For implementing your agent:

As a last and general hint: “Days of programming can save you minutes of thinking.” Think of a strategy, the rules to implement it and the information you need to decide on the actions before you start implementing it.