org.moyoman.module.board
Interface Board

All Superinterfaces:
Cloneable, ModuleInterface, Serializable
All Known Implementing Classes:
BoardImpl

public interface Board
extends ModuleInterface

An object that implements the Board interface is responsible for maintaining the current state and history of a game.

It stores information about such things as the stones on the board, each move that has been made, all kos that have been taken and all prisoners captured, and the rule set under which the game is being played.


Field Summary
static short ALLOWED
          A superko is allowed.
static short DRAW
          A superko results in a draw.
static short FILLED
          A move is made on an occupied point.
static short FORBIDDEN
          A superko is forbidden.
static short KO
          A move illegally retakes the ko.
static short LEGAL
          A move is legal.
static short SUICIDE
          A move is an illegal suicide.
static short SUPERKO
          A whole board position is illegally recreated.
static short WRONG_COLOR
          The wrong color stone is moved.
 
Method Summary
 boolean didSuicideOccur()
          Return true if the last move was a suicide or false.
 boolean doCountPointsInSeki()
          Return true unless territory that is part of a seki are not counted.
 boolean freePlacementOfHandicapStones()
          Return whether handicap stones can be placed anywhere.
 NumberedStone[] getAllBlackPrisoners()
          Return all black prisoners that have been captured in this game.
 NumberedStone[] getAllKos()
          Return all kos that have occurred in this game.
 Move[] getAllMoves()
          Get all of the moves that have been made in the game.
 NumberedStone[] getAllPrisoners()
          Return all prisoners that have been captured in this game.
 NumberedStone[] getAllWhitePrisoners()
          Return all white prisoners that have been captured in this game.
 Stone[] getBlackStones()
          Return all of the black stones on the board.
 Color[][] getBoardArray()
          Return the Color objects that represent the board.
 Color getColor(Point pt)
          Return the color of the stone at the given point.
 Color getColorToMove()
          Return the color of the player to move.
 Stone[] getIllegalMoves()
          Get all moves which would be illegal for any reason.
 float getKomi()
          Return the amount of the komi for this game.
 Move getLastMove()
          Return the last move made.
 MoveDescriptor getLastMoveDescriptor()
          Return a MoveDescriptor for the last move made.
 Stone getLastMoveKo()
          If there is a ko situation, return the illegal move, otherwise null.
 short getLastMovePrisonerCount()
          Get the total number of prisoners captured on the last move.
 Stone[] getLastMovePrisoners()
          Return an array of all of the prisoners captured on the last move.
 short getLegalityStatus(Stone st)
          Return the status of the move.
 Stone[] getLegalMoves()
          Return all legal moves.
 short getMoveNumber()
          Return the move number to be made next.
 short getStoneCount()
          Return the total number of stones on the board.
 Stone[] getStones()
          Return all of the stones on the board.
 Stone[] getSuicideMoves()
          Get all moves which would be illegal because of suicide.
 Stone[] getSuperKoMoves()
          Get all moves which would be illegal because of superko.
 short getTotalBlackPrisonerCount()
          Get the total number of black prisoners in the game.
 short getTotalWhitePrisonerCount()
          Get the total number of white prisoners in the game.
 Stone[] getWhiteStones()
          Return all of the white stones on the board.
 boolean isBentFourDeadByRule()
          Return whether bent four in the corner is dead by rule.
 boolean isEndOfGame()
          Determine whether the last move caused the game to end.
 boolean isLegal(Stone st)
          Return true if the move is legal, or false.
 boolean isSuicideAllowed()
          Return true if suicide is allowed, or false.
 boolean isTerritoryScoring()
          Return true for territory (Japanese) scoring, or false for area (Chinese) scoring.
 void makeMove(Move move)
          Add a move to the board.
 boolean mustWhiteMoveLast()
          Return true if white must make the last move, or false.
 short numberOfPassesToEndGame()
          Return the number of consecutive passes required to end the game.
 short superKoRule()
          Return a constant indicating the legality of superko.
 
Methods inherited from interface org.moyoman.module.ModuleInterface
clone, getMoves, getScheduler
 

Field Detail

DRAW

public static final short DRAW
A superko results in a draw.

See Also:
Constant Field Values

FORBIDDEN

public static final short FORBIDDEN
A superko is forbidden.

See Also:
Constant Field Values

ALLOWED

public static final short ALLOWED
A superko is allowed.

See Also:
Constant Field Values

LEGAL

public static final short LEGAL
A move is legal.

See Also:
Constant Field Values

FILLED

public static final short FILLED
A move is made on an occupied point.

See Also:
Constant Field Values

SUICIDE

public static final short SUICIDE
A move is an illegal suicide.

See Also:
Constant Field Values

KO

public static final short KO
A move illegally retakes the ko.

See Also:
Constant Field Values

SUPERKO

public static final short SUPERKO
A whole board position is illegally recreated.

See Also:
Constant Field Values

WRONG_COLOR

public static final short WRONG_COLOR
The wrong color stone is moved.

See Also:
Constant Field Values
Method Detail

isTerritoryScoring

public boolean isTerritoryScoring()
Return true for territory (Japanese) scoring, or false for area (Chinese) scoring.

Returns:
true for territory scoring, or false for area scoring.

doCountPointsInSeki

public boolean doCountPointsInSeki()
Return true unless territory that is part of a seki are not counted.

Returns:
Whether to count territory that is part of a seki.

isSuicideAllowed

public boolean isSuicideAllowed()
Return true if suicide is allowed, or false.

Returns:
true if suicide is allowed, or false.

superKoRule

public short superKoRule()
Return a constant indicating the legality of superko.

Returns:
A constant indicating the legality of superko.

isBentFourDeadByRule

public boolean isBentFourDeadByRule()
Return whether bent four in the corner is dead by rule. This concerns the life and death of groups when the game is over. In some rule sets, such as the Japanese, if there is a ko to kill a group with a bent four, then the ko does not have to be fought, but the group is automatically dead.

Returns:
true if bent four in the corner is dead by rule, or false.

mustWhiteMoveLast

public boolean mustWhiteMoveLast()
Return true if white must make the last move, or false. If true, then if black makes the last move, white must give black a prisoner.

Returns:
true if white must make the last move, or false.

getKomi

public float getKomi()
Return the amount of the komi for this game.

Returns:
The amount of the komi.

freePlacementOfHandicapStones

public boolean freePlacementOfHandicapStones()
Return whether handicap stones can be placed anywhere.

Returns:
true if the handicap stones can be placed anywhere, or false if they must be put in the standara configuration.

numberOfPassesToEndGame

public short numberOfPassesToEndGame()
Return the number of consecutive passes required to end the game.

Returns:
The number of passes required to end the game.

getLastMoveKo

public Stone getLastMoveKo()
If there is a ko situation, return the illegal move, otherwise null.

Returns:
The stone that if played would illegally retake the ko, or null.

getAllKos

public NumberedStone[] getAllKos()
Return all kos that have occurred in this game.

Returns:
An array of NumberedStone object representing illegal moves as a result of kos.

getLastMovePrisoners

public Stone[] getLastMovePrisoners()
Return an array of all of the prisoners captured on the last move.

Returns:
The stones captured on the last move.

getAllPrisoners

public NumberedStone[] getAllPrisoners()
Return all prisoners that have been captured in this game.

Returns:
An array of NumberedStone objects representing all prisoners captured in this game.

getAllBlackPrisoners

public NumberedStone[] getAllBlackPrisoners()
Return all black prisoners that have been captured in this game.

Returns:
An array of NumberedStone objects representing all black prisoners captured in this game.

getAllWhitePrisoners

public NumberedStone[] getAllWhitePrisoners()
Return all white prisoners that have been captured in this game.

Returns:
An array of NumberedStone objects representing all white prisoners captured in this game.

getSuperKoMoves

public Stone[] getSuperKoMoves()
Get all moves which would be illegal because of superko.

Returns:
An array of Stone objects.

getSuicideMoves

public Stone[] getSuicideMoves()
Get all moves which would be illegal because of suicide.

Returns:
An array of Stone objects.

getIllegalMoves

public Stone[] getIllegalMoves()
Get all moves which would be illegal for any reason.

Returns:
An array of Stone objects.

getLegalMoves

public Stone[] getLegalMoves()
Return all legal moves.

Returns:
An array of Stone objects representing legal moves.

isLegal

public boolean isLegal(Stone st)
Return true if the move is legal, or false.

Parameters:
st - The stone to be played.
Returns:
true if the move is legal, or false.

getLegalityStatus

public short getLegalityStatus(Stone st)
Return the status of the move. The possible values are LEGAL if the move is legal, FILLED if the intersection is already occupied, SUICIDE if the move is illegal because it is suicide, KO if the move is illegally retaking the ko, SUPERKO if the move is illegally recreating a whole board position, and WRONG_COLOR if the stone is the wrong color to move.

Parameters:
st - The move being checked.
Returns:
A short which is one of an enumerated list of values.

getTotalBlackPrisonerCount

public short getTotalBlackPrisonerCount()
Get the total number of black prisoners in the game.

Returns:
The number of black prisoners.

getTotalWhitePrisonerCount

public short getTotalWhitePrisonerCount()
Get the total number of white prisoners in the game.

Returns:
The number of white prisoners.

getLastMovePrisonerCount

public short getLastMovePrisonerCount()
Get the total number of prisoners captured on the last move.

Returns:
The number of prisoners captured on the last move.

getLastMove

public Move getLastMove()
                 throws NoSuchDataException
Return the last move made.

Returns:
The last move that was made.
Throws:
NoSuchDataException - Thrown if no moves have been made, even if there are handicap stones on the board.

getLastMoveDescriptor

public MoveDescriptor getLastMoveDescriptor()
                                     throws NoSuchDataException
Return a MoveDescriptor for the last move made.

Returns:
A MoveDescriptor object.
Throws:
NoSuchDataException - Thrown if no moves have been made, even if there are handicap stones on the board.

getAllMoves

public Move[] getAllMoves()
Get all of the moves that have been made in the game. This includes handicap stones, which will have a move number of 0.

Returns:
An array of Move objects.

getBlackStones

public Stone[] getBlackStones()
Return all of the black stones on the board.

Returns:
An array containing all of the black stones on the board.

getWhiteStones

public Stone[] getWhiteStones()
Return all of the white stones on the board.

Returns:
An array containing all of the white stones on the board.

getStones

public Stone[] getStones()
Return all of the stones on the board.

Returns:
An array containing all of the stones on the board.

getStoneCount

public short getStoneCount()
Return the total number of stones on the board.

Returns:
A short which is the number of stones on the board.

getMoveNumber

public short getMoveNumber()
Return the move number to be made next. If three moves have been made, and there are nine handicap stones, then the value 4 would be returned.

Returns:
The number of the next move.

getColorToMove

public Color getColorToMove()
Return the color of the player to move.

Returns:
Either BLACK, or WHITE.

getColor

public Color getColor(Point pt)
Return the color of the stone at the given point.

Returns:
The color at the given point, which can be BLACK, WHITE, or EMPTY.

isEndOfGame

public boolean isEndOfGame()
Determine whether the last move caused the game to end.

Returns:
true if the game is over, or false.

getBoardArray

public Color[][] getBoardArray()
Return the Color objects that represent the board. The first index is the horizontal coordinate, and the second the vertical coordinate.

Returns:
A two dimensional array of Color objects.

didSuicideOccur

public boolean didSuicideOccur()
Return true if the last move was a suicide or false.

Returns:
true if the last move was a suicide, or false.

makeMove

public void makeMove(Move move)
              throws IllegalMoveException,
                     InternalErrorException
Add a move to the board.

Parameters:
move - The move to be added.
Throws:
IllegalMoveException - Thrown if the move is illegal.
InternalErrorException - Thrown if the operation fails for any reason.