Introduction
Our project is going to be a simulation of the "capture the flag" game that is played by robots in a maze.
- We have a rectangular maze divided into cells, where each cell is either
a wall or an open space. The maze is closed, meaning that it is not possible
to pass through its outer bounds.
- The "capture the flag" game is played with one or more robots. Each
robot starts on a different cell; this initial cell is the robot's home-base.
- A robot can move to the cells next to him (north, south, east, west)
if there is no blocking object, like another robot or a wall.
- Somewhere in the maze on one of the cells, is a flag that the robots
are trying to capture. To capture the flag, a robot must be standing on the
same cell as the flag. Once a robot captures the flag, all the other robots
are informed. The robot that brings the flag back to his home base is the
winner of the game.
- The only chance to take the flag away from a robot is the earthquake
button. Like the flag, the button is located on a random cell somewhere in
the maze and can be pressed by a robot standing on that cell. When the earthquake
button is pressed, the flag and the earthquake button positions are changed
to new random positions and all robots return to their home-base. The earthquake
button only works after the flag has been captured.
- The robots have a special feature that allows them to pass an inner
wall in the maze: They can build a bridge. Building a bridge allows the robots
to transform a wall cell into a cell that the robot can walk through, but
it can only be used by the robot that built it. Since building a bridge is
a hard task, the world starts off with an initial number of pre-built bridges
and when this limit is used, a robot is delayed for a certain amount of time
while the requested bridge it built.
- In order to navigate, a robot is able to sense the cells next to him
in each of the four directions (north, south, east, west) and for the cell
he is standing on (center) the following information:
- The type of the cell (if it is a wall, a robot, a bridge of
another robot, his own bridge, the earthquake button, or the flag).
- The direct distance to the flag (not necessarily an actual path to the flag).
- The direct distance to the earthquake button (not necessarily an actual path to the button).
Implementation
The start-up and the GUI (graphical user interface) of the game will be given
to you. What you need to do is to model and implement (in part) two Java classes:
- WorldService: This interface defines the game administration methods; it is implemented by the WorldServiceActivator class. The WorldServiceActivator class not only provides WorldService methods, but it acts as the core of the World interface implementation. WorldServiceActivator
contains all of the game state information and the methods for the actions
that the robots can perform. There is only one instance of the WorldServiceActivator class in the game, but every robot has its own instance of the World implementation. The robots do not use the shared WorldServiceActivator object directly, instead they call methods on their own World object; in this case, the World
implementation is merely a wrapper where all World methods delegate their
calls to the WorldServiceActivator instance. This approach keeps the interfaces
clean since robots do not need to pass in an identifier or anything to WorldServiceActivator
and they also cannot access the the adminstrative methods in the WorldService
interface.
-
Robot: This interface defines the methods used to manipulate a
robot. The robot implementation also contains the algorithm that makes the
robot perform its actions on its World. The main goal of
the robot algorithm is to find the flag and return it to the robot's home,
but it may also define some strategy for dealing with the earthquake button
and building bridges. A robot implementation is notified when another robot
captures the flag; this occurs when the Robot.flagCapturedHandler() callback
method is invoked; this gives your robot the possibility to react on such
an event. You may want will most likely need to keep track of internal data
about the maze to help it navigate and make decisions.