|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcmsc433.p3.Maze
public class Maze
Stores the maze and provides functions for querying the maze.
| Field Summary | |
|---|---|
MazeDisplay |
display
A reference to the graphical display of this maze. |
int |
height
|
java.util.concurrent.atomic.AtomicIntegerArray |
maze
The maze is a 2 dimensional array of atomic integers encoded as an AtomicIntegerArray. |
int |
width
|
| Constructor Summary | |
|---|---|
Maze()
|
|
| Method Summary | |
|---|---|
boolean |
canMove(Position pos,
Direction dir)
Returns true if it is possible to move in direction @dir when at position @pos. |
boolean |
checkSolution(java.util.List<Direction> soln)
Checks that a solution is correct. |
int |
getCell(Position pos)
Returns the integer at the given position. |
int |
getColor(Position pos)
Gets the color of the cell at position 'pos'. |
int |
getColor(Position pos,
Direction dir)
Gets the color of the edge in direction 'dir' at position 'pos'. |
Position |
getEnd()
Returns the position corresponding to the exit of the maze. |
int |
getHeight()
Returns the height of the maze. |
java.util.LinkedList<Direction> |
getMoves(Position pos)
Returns the list of open directions at this position. |
Position |
getStart()
Returns the position corresponding to the entrance of the maze. |
int |
getWidth()
Returns the width of the maze. |
void |
setColor(Position pos,
Direction dir,
int color)
Sets the color of the edge in direction 'dir' at position 'pos' to the specified value, which must be between 0 and 3 inclusive. |
void |
setColor(Position pos,
int color)
Sets the color of the cell at position 'pos' to the specified value, which must be between 0 and 3 inclusive. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public java.util.concurrent.atomic.AtomicIntegerArray maze
The maze is a 2 dimensional array of atomic integers encoded as an AtomicIntegerArray. The upper-left, or north-western corner of the maze is given by maze.get(0). The lower-right, or south-eastern corner of the maze is maze.get(maze.length()-1). The maze is stored in row-major order, so the element at row n, column m is given by maze.get(n * width + m).
The entrance to the maze is at row: 0, column: width/2. The exit is at row: height-1, column: width/2.
Individual bits of each byte in the "maze" array are used to encode information about that cell of the maze. Only the low-order 8 bits are used. The designated bits are:
CCSSEEse
and have the following meaning
CC
SS
EE
s
e
There is always a wall to the south of cells on the southern border of the maze. There is always a wall to the east of cells on the eastern border of the maze. There is an implicit wall to the north of cells on the northern border and to the west of cells on the western border.
public int width
public int height
public transient MazeDisplay display
| Constructor Detail |
|---|
public Maze()
| Method Detail |
|---|
public int getCell(Position pos)
maze field.
public boolean canMove(Position pos,
Direction dir)
public java.util.LinkedList<Direction> getMoves(Position pos)
public int getWidth()
public int getHeight()
public void setColor(Position pos,
int color)
public int getColor(Position pos)
public void setColor(Position pos,
Direction dir,
int color)
public int getColor(Position pos,
Direction dir)
public Position getStart()
public Position getEnd()
public final boolean checkSolution(java.util.List<Direction> soln)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||