|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectboardgame.Board
pushers.PBoard
public class PBoard
Pushers board representation. The board is represented as a
one dimensional array with a coord in the i-th row and j-th column
at index (i-1) * SIZE + (j-1).
| Field Summary | |
|---|---|
static int |
BLACK
|
static int |
BLACK_PUSHER
|
protected int[] |
data
|
static int |
EMPTY
|
static int |
MAX_TURNS
Maximum number of turns before a draw. |
protected int[] |
numPusheePieces
|
protected int[] |
numPusherPieces
|
static int |
PUSHER
|
static int |
SIZE
Board size |
protected int |
turn
|
protected int |
turnCount
|
static int |
WHITE
|
static int |
WHITE_PUSHER
|
protected int |
winner
|
| Fields inherited from class boardgame.Board |
|---|
BOARD, DRAW, NOBODY |
| Constructor Summary | |
|---|---|
PBoard()
Returns a board in the starting position. |
|
PBoard(PBoard bb)
Returns a deep copy of another board. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Return a copy of this board |
BoardPanel |
createBoardPanel()
Return a custom BoardPanel so that we can accept user input |
void |
forceWinner(int win)
Set a winner without finishing the game. |
int[] |
getBoardData()
Get the array containing the board data directly |
int |
getCol(int coord)
|
int |
getCoord(int row,
int col)
Convert between array index and (row,col) pairs |
int |
getIDForName(java.lang.String s)
Get the player ID corresponding to name |
java.lang.String |
getNameForID(int p)
Get the name corresponding to a player ID. |
int |
getNumberOfPlayers()
Get the number of players. |
int |
getNumPusheePieces(int playerID)
Return the number of pushee pieces for a player. |
int |
getNumPusherPieces(int playerID)
Return the number of pusher pieces for a player. |
int |
getPieceAt(int index)
Get the value at a position: return BLACK, WHITE or EMPTY. |
int |
getPieceAt(int row,
int col)
|
int |
getRow(int coord)
|
int |
getTurn()
Return the next player. |
int |
getTurnsPlayed()
Get the number of turns played. |
int |
getWinner()
Return winner colour, DRAW or NOBODY if no winner yet. |
boolean |
isLegal(int player,
int orig,
int dest)
Verify legality of a move. |
boolean |
isLegal(Move mm)
Verify legality of a move. |
void |
move(int player,
int orig,
int dest)
Execute a move. |
void |
move(Move mm)
Execute a move. |
void |
moveFast(int player,
int orig,
int dest)
Execute a move without checking legality. |
Move |
parseMove(java.lang.String str)
Parse a move from a string |
java.lang.String |
toString()
String representation of a board |
| Methods inherited from class boardgame.Board |
|---|
filterMove, getBoardMove |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SIZE
public static final int MAX_TURNS
public static final int EMPTY
public static final int WHITE
public static final int BLACK
public static final int WHITE_PUSHER
public static final int BLACK_PUSHER
public static final int PUSHER
protected final int[] data
protected int turn
protected int winner
protected int turnCount
protected int[] numPusherPieces
protected int[] numPusheePieces
| Constructor Detail |
|---|
public PBoard()
public PBoard(PBoard bb)
| Method Detail |
|---|
public int[] getBoardData()
public int getPieceAt(int index)
public int getPieceAt(int row,
int col)
public int getCoord(int row,
int col)
public int getRow(int coord)
public int getCol(int coord)
public int getNumPusherPieces(int playerID)
public int getNumPusheePieces(int playerID)
public int getWinner()
getWinner in class Boardpublic void forceWinner(int win)
forceWinner in class Boardpublic int getTurn()
getTurn in class Boardpublic int getTurnsPlayed()
getTurnsPlayed in class Boardpublic boolean isLegal(Move mm)
public boolean isLegal(int player,
int orig,
int dest)
public void move(Move mm)
throws java.lang.IllegalArgumentException
move in class Boardjava.lang.IllegalArgumentException
public void move(int player,
int orig,
int dest)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void moveFast(int player,
int orig,
int dest)
public java.lang.Object clone()
clone in class Boardpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getNameForID(int p)
Board
getNameForID in class Boardpublic int getIDForName(java.lang.String s)
Board
getIDForName in class Boardpublic int getNumberOfPlayers()
Board
getNumberOfPlayers in class Board
public Move parseMove(java.lang.String str)
throws java.lang.NumberFormatException,
java.lang.IllegalArgumentException
Board
parseMove in class Boardjava.lang.NumberFormatException
java.lang.IllegalArgumentExceptionpublic BoardPanel createBoardPanel()
createBoardPanel in class Board
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||