Interface MazeModel

All Known Implementing Classes:
Maze

public interface MazeModel

The model for a maze. Known implementations: Maze


Field Summary
static byte MARK
          Bitmap value for an "I've been here" mark.
static byte WALLS
          Bitmap value for all walls (no passages).
static byte XMI
          Bitmap value for an exit in the X- direction.
static byte XPL
          Bitmap value for an exit in the X+ direction.
static byte YMI
          Bitmap value for an exit in the Y- direction.
static byte YPL
          Bitmap value for an exit in the Y+ direction.
static byte ZMI
          Bitmap value for an exit in the Z- direction.
static byte ZPL
          Bitmap value for an exit in the Z+ direction.
 
Method Summary
 void addMazeListener(MazeListener l)
          Add a MazeListener.
 Coordinate3D getCurrent()
          Get the current player co-ordinate.
 Coordinate3D getFinish()
          Get the finish cell location.
 Coordinate3D getSize()
          Get the size of the maze.
 byte grid(Coordinate3D c)
          Get the contents of a cell.
 byte grid(int x, int y, int z)
          Get the contents of a cell.
 boolean isMarked(Coordinate3D position)
          Check if the given cell has an "I've been here" marker.
 boolean isOpen(Coordinate3D current, byte direction)
          Check and see if movement is possible.
 void removeMazeListener(MazeListener l)
          Remove a MazeListener.
 void setCurrent(Coordinate3D current)
          Set the current player co-ordinate.
 void setFinish(Coordinate3D finish)
          Set the position of the finish or goal cell.
 void setMark(Coordinate3D position, boolean mark)
          Set an "I've been here" mark in the given cell.
 void setRandomFinish()
          Set a random position for the finish cell.
 Stack solve(Coordinate3D start)
          Solve the maze from a given start position.
 

Field Detail

WALLS

public static final byte WALLS
Bitmap value for all walls (no passages).

XPL

public static final byte XPL
Bitmap value for an exit in the X+ direction.

XMI

public static final byte XMI
Bitmap value for an exit in the X- direction.

YPL

public static final byte YPL
Bitmap value for an exit in the Y+ direction.

YMI

public static final byte YMI
Bitmap value for an exit in the Y- direction.

ZPL

public static final byte ZPL
Bitmap value for an exit in the Z+ direction.

ZMI

public static final byte ZMI
Bitmap value for an exit in the Z- direction.

MARK

public static final byte MARK
Bitmap value for an "I've been here" mark.
Method Detail

getSize

public Coordinate3D getSize()
Get the size of the maze.
Returns:
The 3D size of the maze.

setMark

public void setMark(Coordinate3D position,
                    boolean mark)
Set an "I've been here" mark in the given cell.
Parameters:
position - The 3D co-ordinate of the cell.
mark - True to set a mark, false to remove it.

grid

public byte grid(int x,
                 int y,
                 int z)
Get the contents of a cell.
Parameters:
x - The x co-ordinate.
y - The y co-ordinate.
z - The z co-ordinate.
Returns:
A bitmap containing XPL,XMI etc.

grid

public byte grid(Coordinate3D c)
Get the contents of a cell.
Parameters:
c - The 3D co-ordinate of the cell.
Returns:
A bitmap containing XPL,XMI etc.

setFinish

public void setFinish(Coordinate3D finish)
Set the position of the finish or goal cell.
Parameters:
finish - The 3D co-ordinate of the cell.

setRandomFinish

public void setRandomFinish()
Set a random position for the finish cell.

getFinish

public Coordinate3D getFinish()
Get the finish cell location.
Returns:
The 3D co-ordinate of the cell.

setCurrent

public void setCurrent(Coordinate3D current)
Set the current player co-ordinate.
Parameters:
current - The 3D co-ordinate of the player in the maze.

getCurrent

public Coordinate3D getCurrent()
Get the current player co-ordinate.
Returns:
The 3D co-ordinate of the player in the maze.

isMarked

public boolean isMarked(Coordinate3D position)
Check if the given cell has an "I've been here" marker.
Parameters:
position - The 3D co-ordinate of the cell to check.
Returns:
True if a marker has been placed.

isOpen

public boolean isOpen(Coordinate3D current,
                      byte direction)
Check and see if movement is possible.
Parameters:
current - The 3D co-ordinate to start from.
direction - The direction to go, one of XPL,XMI etc.
Returns:
True if movement possible, false if blocked by a wall.

solve

public Stack solve(Coordinate3D start)
Solve the maze from a given start position.
Parameters:
start - The 3D co-ordinate to start from.
Returns:
A Stack of 3D co-ordinates giving the path from the given start to the known finish.

addMazeListener

public void addMazeListener(MazeListener l)
Add a MazeListener. An event is fired when the maze is created or when the finish or current positions change.
Parameters:
l - A MazeListener to listen for maze changes.

removeMazeListener

public void removeMazeListener(MazeListener l)
Remove a MazeListener.
Parameters:
l - The MazeListener to remove.