|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.bluebones.tictactoe.Board
public class Board
Methods that work on a tictactoe board. The board is represented
as a byte[][]
and worked on with static methods
rather than being an object with behaviour so that AI players can
have many many copies of boards in memory without making the memory
requirements outrageous.
Field Summary | |
---|---|
static byte |
SIZE
Size of one side of the board. |
Constructor Summary | |
---|---|
Board()
|
Method Summary | |
---|---|
static byte[][] |
copy(byte[][] board)
Makes a new copy of the specified board. |
static boolean |
isEmpty(byte[][] board,
Move move)
Determines if the square the specified Move takes
place in is empty or not. |
static boolean |
isFull(byte[][] board)
Determines if this board is full (no more moves possible) or not. |
static boolean |
isWinner(byte[][] board,
byte player)
Determines if the specified player has won at the current board position. |
static boolean |
placePiece(byte[][] board,
Move m)
Does the move specified in m on board . |
static void |
printBoard(byte[][] board)
Prints a graphical representation of the board to STDOUT. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte SIZE
Constructor Detail |
---|
public Board()
Method Detail |
---|
public static boolean isEmpty(byte[][] board, Move move)
Move
takes
place in is empty or not.
move
- Move
to check position of.
boolean
, true if the square is empty.public static boolean isWinner(byte[][] board, byte player)
board
- byte[][]
board to check.player
- byte
either TicTacToe.NOUGHTS
or TicTacToe.CROSSES
.
boolean
, true
if the specified
player has won.public static boolean placePiece(byte[][] board, Move m)
m
on board
.
board
- byte[][]
of board to
perform move on.m
- Move
to perform.
boolean
of whether the move
succeeded or not.
IllegalStateException
- If the move is not legal.public static boolean isFull(byte[][] board)
boolean
, true if this board is full.public static void printBoard(byte[][] board)
public static byte[][] copy(byte[][] board)
board
- byte[][]
board to copy.
byte[][]
copy of board.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |