BeeperHunt specification

BeeperHunt specification

"Regulus" design

public class BeeperHunt

Runs the GUI and controls the application. This uses the default constructor.

public static void main(String[] args)
Sets up the GUI and runs the application via an instance of BeeperHunt. To do this, it will need to create a new Maze and a MazeView which observes the Maze.

Beeperhunt will also need to implement these GUI controls, even though they are not publicly accessible.

New Maze Button
Creates a new maze simulation
Start Button
Starts the simulation.
Pause/Resume Button
Pauses the simulation, or, if already paused, resumes it.
Stop Button
Halts the simulation.
Speed Slider
Adjusts the speed of the simulation.

public class MazeView extends Container implements Observer

Displays the current state of the maze, including the robot and beepers. This should also show the number of beepers collected so far. This uses the default constructor.

public void update()
Redraws the maze or number of beepers collected.

public class Model implements Observable

This is the simulation itself. It should be observed by a MazeView. It holds the maze as a graph of Nodes and keeps track of the robot and beepers within the maze. The robot's and the beepers' behavior is determined by advance. The manner in which this does so is implementation-specific. For example, the robot and the beepers could be their own objects, or they could simply be stored as references to Nodes within the maze.

public Maze()
The constructor makes a new maze and randomly locates a robot and two beepers.
public int countBeepers()
Counts the number of beepers collected so far.
public void advance()
Advances the simulation one turn. To do this,
  1. Find the shortest paths between the robot and each beeper.
  2. Choose the best path, taking into account the expiration date on each beeper.
  3. Move the robot to the next node on the best path, or let the robot stand still if there is no reason to move.
  4. If either of the beepers is knocking on death's door, eliminate it and create a new beeper in a random location.
public Node findBeeper(int beeper) throws IllegalArgumentException
Finds beeper number beeper. Right now, beeper should be 1 or 2. Otherwise, an IllegalArgumentException is thrown.
public Node findRobot()
Finds the location of the robot.
public Node getMaze()
Returns the entrance to the maze. Since the maze is an undirected, connected graph, the entrance alone is sufficient to draw the whole maze. Note that the entrance is just an arbitrary node, and is not necessarily on the outside of the maze.
public void notifyObservers()
Lets the MazeView know when a robot or beeper has moved.

public class Node

A Node is one point in a graph. It is linked to 4 other Nodes. At least one of these must not be null so that a graph of Nodes is always connected. This also means that single Node mazes are impossible.

public Iterator getIterator()
Returns an Iterator which moves through this Node's neighbors.