A simple rules AI that was developed in early 2012 for an AI course. A 'game' is defined and this AI is intended to solve any arbitrary solvable map generated for the game world.

Game Definition

The following definition is taken from here and was written by Alan Blair

For this project you will be implementing an agent to play a simple text-based adventure game. The agent is required to move around a rectangular environment, collecting tools and avoiding (or removing) obstacles along the way. The obstacles and tools within the environment are represented as follows:

Obstacles  Tools

T  tree       a  axe
* wall d dynamite
~ water B boat
g gold

The agent will be represented by one of the characters ^, v, <  or  >, depending on which direction it is pointing. The agent is capable of the following instructions:

L   turn left
R   turn right
F   (try to) move forward
C   (try to) chop down a tree, using an axe
B   (try to) blast a wall, door or tree, using dynamite

When it executes an L or R instruction, the agent remains in the same location and only its direction changes. When it executes an F instruction, the agent attempts to move a single step in whichever direction it is pointing. The F instruction will fail (have no effect) if there is a wall or tree directly in front of the agent.

When the agent moves to a location occupied by a tool, it automatically picks up the tool. The agent may use a C or B instruction to remove an obstacle immediately in front of it, if it is carrying the appropriate tool. A tree may be removed with a C (chop) instruction, if an axe is held. A wall or tree may be removed with a B (blast) instruction, if dynamite is held.

If the agent moves forward into the water, it will drown unless it is in a boat. Boats behave a bit differently from the other tools, because they always remain in the water. When the agent moves from the water back to the land, it automatically drops the boat. The boat will then remain where it was dropped, ready to be picked up again at a later time.

If the agent attempts to move off the edge of the environment, it dies.

To win the game, the agent must pick up the gold and then return to its initial location.


Details Page with project overview, assignment specifications, and instructions for running. All credit goes to Alan Blair and the UNSW Computer Science and Engineering faculty for writing the assignment.
Download .zip of project source. All credit goes to Alan Blair for writing the game simulation unit (Bounty.java). All I did was write the game playing agent.