Minesweeper API
All fields and methods are public unless
noted otherwise.
== package minesweeper4j.agents ==
abstract class ArtificialAgent
Implement your agent as a subclass of this class.
- protected
abstract
Action thinkImpl(Board board, Board previousBoard)
-
The framework calls this method to ask for your next action.
-
The first time this method is called,
board
will hold the initial board state, in which the first
hint square has already been opened and any surrounding squares with
no mines have already been expanded. On this call previousBoard
will be null. -
On each subsequent call,
board
is the current board
state and previousBoard
is the board state from the
previous call to this method. You can compare board
and
previousBoard
to determine the new information that is
available (e.g. as a consequence of opening a square on your
previous turn).
== package minesweeper4j.game ==
class
Action
An action that your agent can take.
- static
Action advice()
-
Return an
Action
that asks for a hint. -
static Action
flag(int
tileX, int
tileY)
-
Return an Action that marks the tile at (tileX, tileY) as a known
mine.
-
static Action
open(int
tileX, int
tileY)
-
Return an Action that uncovers the tile at (tileX, tileY). If you
return this action and this tile is a mine, your game is over!
class
Board
A Minesweeper game in progress.
- int
height;
-
The height of the board in squares.
-
Tile[][] tiles;
-
A two-dimensional array of Tile objects, indexed as tiles[x][y].
-
int totalMines;
-
The total number of mines (visible + invisible) on the board.
-
int width;
-
The width of the board in squares.
enum
ETile
The
contents of a tile: either FREE if it does not contain a mine, MINE
if it contains a mine, or UNKNOWN if it is not visible.
class
Tile
- boolean
flag;
-
True if the player has marked this square with a flag.
-
Integer mines;
-
The number of mines surrounding this tile, or
null
if
the tile is not currently visible. -
ETile type;
-
If this tile is visible, this field will have
the value FREE or MINE. Otherwise, it will be UNKNOWN.
-
boolean visible;
-
True if this tile is currently visible.