All Packages Class Hierarchy This Package Previous Next Index
Interface map.Map
- public interface Map
The inteface Map describes a mine map. A strategy operates on a mine
map. By invoking the operations of probing and marking, the strategy
attempts to place the mine map in a state in which every cell that does
not contain a mine has been probed, without probing a cell that does
contain a mine.
- See Also:
- Strategy
-
BOOM
- Boom return code.
-
MARKED
- Marked return code.
-
OUT_OF_BOUNDS
- Out of bounds return code.
-
UNPROBED
- Unprobed return code.
-
columns()
- Provide the number of columns in this mine map.
-
display()
- Display the mine map on the standard output stream.
-
done()
- Is this game finished?
The game is finished if it has been won or if a cell with a
mine has been probed.
-
look(int, int)
- Look at a cell.
-
mark(int, int)
- Mark a cell.
-
mines_minus_marks()
- Provide the number of mines minus the
number of marks in this mine map.
-
pick(int)
- Pick a number at random.
-
probe(int, int)
- Probe a cell for a mine.
-
rows()
- Provide the number of rows in this mine map.
-
unmark(int, int)
- Unmark a cell.
-
won()
- Has this game been won?
A game is won if every cell which does not contain a mine has
been probed, but no cell with a mine has been probed.
OUT_OF_BOUNDS
public static final int OUT_OF_BOUNDS
- Out of bounds return code.
- See Also:
- look
MARKED
public static final int MARKED
- Marked return code.
- See Also:
- look
UNPROBED
public static final int UNPROBED
- Unprobed return code.
- See Also:
- look
BOOM
public static final int BOOM
- Boom return code.
- See Also:
- look
won
public abstract boolean won()
- Has this game been won?
A game is won if every cell which does not contain a mine has
been probed, but no cell with a mine has been probed.
done
public abstract boolean done()
- Is this game finished?
The game is finished if it has been won or if a cell with a
mine has been probed.
probe
public abstract int probe(int x,
int y)
- Probe a cell for a mine.
- If the game is finished, probe behaves like look.
- If the cell does not exist,
OUT_OF_BOUNDS
is returned.
- If the cell is marked,
MARKED
is returned.
- If the cell has a mine,
BOOM
is returned
and the game is lost.
- Otherwise, the number of adjacent mines is returned.
- Parameters:
- x - x coordinate of cell
- y - y coordinate of cell
look
public abstract int look(int x,
int y)
- Look at a cell.
- If the cell does not exist,
OUT_OF_BOUNDS
is returned.
- If the cell is marked,
MARKED
is returned.
- If the cell has not been probed,
UNPROBED
is returned.
- If the cell has a probed mine,
BOOM
is returned.
- Otherwise, the number of adjacent mines is returned.
- Parameters:
- x - x coordinate of cell
- y - y coordinate of cell
mark
public abstract int mark(int x,
int y)
- Mark a cell.
- If the game is finished, mark behaves like look.
- If the cell does not exist,
OUT_OF_BOUNDS
is returned.
- If the cell is marked,
MARKED
is returned.
- If the cell has not been probed, the cell is marked
and
MARKED
is returned.
- Otherwise, the number of adjacent mines is returned.
- Parameters:
- x - x coordinate of cell
- y - y coordinate of cell
unmark
public abstract int unmark(int x,
int y)
- Unmark a cell.
- If the game is finished, unmark behaves like look.
- If the cell does not exist,
OUT_OF_BOUNDS
is returned.
- If the cell is marked, the cell is unmarked
and
UNPROBED
is returned.
- If the cell has not been probed,
UNPROBED
is returned.
- Otherwise, the number of adjacent mines is returned.
- Parameters:
- x - x coordinate of cell
- y - y coordinate of cell
mines_minus_marks
public abstract int mines_minus_marks()
- Provide the number of mines minus the
number of marks in this mine map.
rows
public abstract int rows()
- Provide the number of rows in this mine map.
columns
public abstract int columns()
- Provide the number of columns in this mine map.
display
public abstract void display()
- Display the mine map on the standard output stream.
Used only for debugging.
pick
public abstract int pick(int n)
- Pick a number at random.
- Parameters:
- n - a positive number (not checked)
- Returns:
- a nonnegative number less than n
All Packages Class Hierarchy This Package Previous Next Index