Here are some of the most useful classes, fields and methods in the Sokoban API. For more details, look at the source code.
All fields and methods are public unless noted otherwise.
enum
EDirection
{ UP, RIGHT, DOWN, LEFT }
The possible values of this enumeration.
final
int
dX, dY;
The X and Y deltas for
this direction. For example, LEFT.dX
= -1 and LEFT.dY
= 0.
static
EDirection[] arrows()
Return an array containing all four directions.
class
CTile
Use the methods in this class to interpret the
return value from BoardCompact.tile()
.
static
boolean
isWall(
int
tileFlag)
Given a position's tileFlag, return true if there is a wall at that position.
static
boolean
isPlayer(
int
tileFlag)
Given a position's tileFlag, return true if the player is at that position.
static
boolean
isSomeBox(
int
tileFlag)
Given a position's tileFlag, return true if there is a box at that position.
static
boolean
forSomeBox(
int
tileFlag)
Given a position's tileFlag, return true if that position is a box target.
class
BoardCompact
int playerX, playerY;
BoardCompact
clone()
Return a copy of the board state.
int
width()
Return the board width in squares.
int
height()
Return the board height in squares.
int
tile(
int
x,
int
y)
Return an encoded integer value indicating what
is at the square (x, y). You can use the static methods in CTile
to interpret this value. The upper-left corner of the board is (0,
0).
boolean
isVictory()
Return true if the player has won since all boxes have reached target squares.
abstract
class
CAction
abstract
boolean
isPossible(BoardCompact board)
Return true if this action is possible in the given board state.
abstract
void
perform(BoardCompact board)
Apply this action to the given board.
abstract
void
reverse(BoardCompact board)
Revert this action in the given board.
class
CMove
extends
CAction
static
CMove getAction(EDirection direction)
Return a CMove
representing a move in the given direction.
class
CPush
extends
CAction
static
CPush getAction(EDirection direction)
Return a CPush
representing a push in the given direction.
abstract
class
ArtificialAgent
Implement your agent as a subclass of this class.
protected
abstract
List<EDirection> think(BoardCompact board)
Given a board state, return a sequence of directions in which Sokoban should move to solve the level.