Race The Rabbit

Race the Rabbit is a simple predator-pray game where hunters is chasing a rabbit.

In the simplest version of Race the Rabbit, the world consists of an n x n discrete grid where each cell is either open or, with probability p, contains an obstacle. Assume without loss of generality that the border cells of the world contain only obstacles. At each time step the hunter may move north, south, east or west into an open cell followed by the rabbit doing likewise. The rabbit moves randomly though it will stay at its current position if it attempts to enter an obstacle cell. There is no bound placed on the amount of computational resources the Hunter may apply at each time step. The game ends when the hunter overtakes the rabbit.

Rules

The world

The chance takes place in a two-dimensional grid world which may contain obstacles in form of holes in the ground.

  1. Obstacles are randomly distributed over the world
  2. Only one Hunter at a time can occupy a position in the world. Any Hunter trying to move to a position where another hunter or an obstacle is located will simply not move and louse its turn

Rabbit and Hunters

One Rabbit and one or two Hunters take part in Race the Rabbit. The goal for the Hunters is to catch the rabbit by moving to the same position as the rabbit. The Rabbit moves around randomly. Rabbit and Hunters moves in turns with fixed order, Rabbit, Hunter 1, Hunter 2, Rabbit and so on.

There are two types of hunters:

Search Hunter

Has complete information about the world, the position of the rabbit and the position of any opponents in the game. Information is retrieved via a map that is automatically updated as the games goes on.

Perception Hunter

Has incomplete information about the world and positions of rabbit and opponents. However, it can retrieve partial information via its senses. Any obstacles that are in front of the agent or to any of its sides can be seen at a distance of 5 squares from the hunter. Obstacles behind the hunter or positioned diagonally to the hunter is not seen. The visual field is illustrated bellow.

visual-field

Exact information about the rabbit's position can only be obtained if the rabbit are within the visual field, similar to obstacles. However, even if the hunter can not see the rabbit, he can still smell it and estimate an approximate position. The quality of this approximation is better if the rabbit is near the hunter.  Formally, the smell percept is normally distributed with a mean at the true distance to the rabbit, and a variance of 0.1*d, where d is the Euclidian distance to the rabbit.

The Perception Hunter can also smell other hunters, in exactly the same way as he can smell the rabbit.

Implementation

The game is implemented in Java and hunters can be created as java-classes extending one of the abstract classes SearchHunter or PerceptionHunter.

Download

Source code for race the rabbit is available here:

Compile

Unpack the downloaded zip-file. Open a command shell, go to the folder where the source is stored and execute

javac *.java

Run

Execute the following command to run Race the Rabbit

java RunRabbit <hunter1> <hunter2> <Config.xml>

Race the Rabbit works on any system with standard Java VM 6.0 or later. <hunter1> and <hunter2> should be names of class-files implementing the Hunter interface. At least one hunter class must be specified, but the second one is optional. As a test hunter, you can specify ExampleHunter which comes with the source package.

<Config.xml> is an optional argument specifying the configuration file. If omitted, RaceTheRabbit.xml is used and will be created if missing. This file may specify many properties about the game, including the size of the map, where obstacles are placed, starting positions for the rabbit and hunters, game speed and so on. The xml file must follow racetherabbit.xsd. Another example configuration can be found in TestMap.xml.

Documentation

See also Race the Rabbit API

Have fun!

Institutionen för Datavetenskap
Umeå Universitet
Informationen ändrades
Ansvarig för sidan: Webmaster