|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.tabacha.cgo.DefaultBoard
The 19x19 board from the game Go.
$Id: DefaultBoard.java,v 1.9 2004/12/23 21:42:43 mk Exp $
Field Summary |
Fields inherited from interface de.tabacha.cgo.Constants |
BALL, COL_COUNT, DCOL, DOWN, DROW, E, EMPTY, FIRST_DIRECTION, KICK_OFF_FIELD, LAST_DIRECTION, N, NE, NW, OPPOSITE, PIECE, ROW_COUNT, S, SE, SW, UP, UPSIDEDOWN, W |
Constructor Summary | |
DefaultBoard()
Constructs and resets the board. |
|
DefaultBoard(byte[][] fields,
Field ballField,
boolean whoseTurn)
Constructor that receives direct values. |
Method Summary | |
void |
addPiece(Field f)
Puts a piece (aka player) on the board. |
void |
addPiece(int col,
int row)
Puts a piece (aka player) on the board. |
void |
clear()
Removes all pieces and the ball from the field. |
java.lang.Object |
clone()
Returns a deep copy of this object. |
boolean |
equals(java.lang.Object o)
Returns true if the other object is also a DefaultBoard and represents the same position. |
Field |
getBall()
Returns the actual field of the ball. |
int |
hashCode()
As nearly all information about the position is in the byte arrays, returns the hash code of the two-dimensional field array. |
protected void |
jump(Jump move)
Moves the ball around the field. |
protected void |
jumpOnce(byte dir,
Move move)
Makes the ball jump once. |
void |
move(Move move)
Makes a move. |
protected void |
nextTurn()
Switchs the player who has to move. |
byte |
on(Field field)
Returns the content of the specified field on the board. |
byte |
on(int col,
int row)
Returns the content of the field on the specified row and column. |
protected void |
put(Put move)
Puts a piece on the board. |
void |
removePiece(Field f)
Removes a piece (aka player) from the board. |
void |
removePiece(int col,
int row)
Removes a piece (aka player) from the board. |
void |
reset()
Sets the board to the start position. |
void |
setBall(Field newBallField)
Sets the actual field of the ball. |
void |
setBall(int col,
int row)
Sets the actual field of the ball. |
byte[][] |
toArray()
Returns this object as a two-dimensional array containing the contents of the fields. |
java.lang.String |
toString()
Returns a string representation of the board, for debugging. |
Board |
upsideDown()
Returns a copy of this board mirrored along the x-axis. |
boolean |
whoseTurn()
Returns the player who has to move. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DefaultBoard()
public DefaultBoard(byte[][] fields, Field ballField, boolean whoseTurn)
Method Detail |
public java.lang.Object clone()
Board
clone
in interface Board
public byte[][] toArray()
Board
toArray
in interface Board
public void clear()
public void reset()
reset
in interface Board
public Board upsideDown()
Board
upsideDown
in interface Board
protected void nextTurn()
public boolean whoseTurn()
Board
whoseTurn
in interface Board
public byte on(int col, int row)
Board
on
in interface Board
public byte on(Field field)
Board
on
in interface Board
public Field getBall()
Board
getBall
in interface Board
public void setBall(Field newBallField)
Board
setBall
in interface Board
public void setBall(int col, int row)
Board
setBall
in interface Board
public void addPiece(Field f)
Board
addPiece
in interface Board
public void addPiece(int col, int row)
Board
addPiece
in interface Board
public void removePiece(Field f)
Board
removePiece
in interface Board
public void removePiece(int col, int row)
Board
removePiece
in interface Board
public final void move(Move move) throws InvalidMoveException
Board
move
in interface Board
InvalidMoveException
- If the move was not correct.protected void put(Put move) throws InvalidMoveException
InvalidMoveException
- If field is not empty or outside the board.protected void jump(Jump move) throws InvalidMoveException
InvalidMoveException
- If no jumps are contained in the
move or one of the jumps is not possibleprotected void jumpOnce(byte dir, Move move) throws InvalidMoveException
dir
- Direction where to jump to. Defined in Constants.move
- The move this jump is a part of.
InvalidMoveException
- If jump is not possible.public boolean equals(java.lang.Object o)
public int hashCode()
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |