Robot Maze Reference
robot methods
| Name | Arguments | Returns |
|---|---|---|
getRuns | None | int - Number of previous runs the robot has made of the current maze |
look | int - Direction in which to look | int - State of the maze square in the given direction |
face | int - Direction in which to face the robot | void |
setHeading | int - Heading in which to face the robot | void |
getHeading | None | int - Current heading of the robot |
getLocation | None | Point - The x and y coordinates of the robot in the maze |
getTargetLocation | None | Point - The x and y coordinates of the robot's target |
Headings
NORTH, EAST, SOUTH and WEST are referred to as headings.
Headings are used for setHeading and returned by getHeading.
| Name | Value |
|---|---|
NORTH | 1000 |
EAST | 1001 |
SOUTH | 1002 |
WEST | 1003 |
Directions
AHEAD, RIGHT, BEHIND and LEFT are referred to as directions.
Directions are relative to the robot's current heading. Directions are used for
look and face. CENTRE can be used as a null value.
| Name | Value |
|---|---|
AHEAD | 2000 |
RIGHT | 2001 |
BEHIND | 2002 |
LEFT | 2003 |
CENTRE | 2004 |
States
WALL, PASSAGE and BEENBEFORE are referred to as states that a
square in the maze can have. They are returned by look. PASSAGE
means an empty square that has not been visited yet, BEENBEFORE is an
empty square that has been visited.
| Name | Value |
|---|---|
WALL | 3000 |
PASSAGE | 3001 |
BEENBEFORE | 4000 |
Coordinates
Maze coordinates start in the top left corner with $(1,1)$ and finish in
the bottom right corner. The default maze is $15 \times 15$, so the
bottom right corner is $(15,15)$. The coordinates of the robot are given
by getLocation. The coordinates of the target are given by
getTargetLocation. Both of these return a Point object (java.awt.Point), where the x
coordinate is given by p.x and the y by p.y where p is the Point
object.
Important notes
Only headings can be used as the argument for setHeading. Only
directions can be used as the argument for look and face.
IRobot is an interface, robot is an instance of an implementation of
IRobot.