public final class Board extends java.lang.Object implements ConstBoard
Modifier and Type | Class and Description |
---|---|
class |
Board.BoardIterator |
Constructor and Description |
---|
Board(int boardSize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
bothPassed()
Check for two consecutive passes.
|
void |
clear()
Clear board.
|
boolean |
contains(GoPoint point)
Check if board contains a point.
|
ConstPointList |
getAdjacent(GoPoint point)
Get points adjacent to a point.
|
int |
getCaptured(GoColor c)
Get number of captured stones.
|
GoColor |
getColor(GoPoint p)
Get state of a point on the board.
|
static ConstPointList |
getHandicapStones(int size,
int n)
Get location of handicap stones for a given board size.
|
ConstPointList |
getKilled()
Opponent stones captured in last move.
|
Move |
getLastMove()
Return last move.
|
Move |
getMove(int i)
Get a move from the sequence of moves played so far.
|
int |
getNumberMoves()
Get the number of moves played so far.
|
ConstPointList |
getSetup(GoColor c)
Get initial setup stones of a color.
|
GoColor |
getSetupPlayer()
Get player of initial setup position.
|
int |
getSize()
Get board size.
|
void |
getStones(GoPoint p,
GoColor color,
PointList stones)
Get stones of a block.
|
ConstPointList |
getSuicide()
Player stones killed by suicide in last move.
|
GoColor |
getToMove()
Get color to move.
|
void |
init(int size)
Initialize the board for a given board size.
|
boolean |
isCaptureOrSuicide(GoColor c,
GoPoint p)
Check if a move would capture anything (including suicide).
|
boolean |
isHandicap(GoPoint point)
Check if a point is a handicap point.
|
boolean |
isKo(GoPoint point)
Check if move would violate the simple Ko rule.
|
boolean |
isModified()
Check if any moves were played or setup stones placed on the board.
|
boolean |
isSetupHandicap()
Check if the initial setup position was a handicap.
|
boolean |
isSuicide(GoColor c,
GoPoint p)
Check if a point would be a suicide move.
|
java.util.Iterator<GoPoint> |
iterator() |
void |
play(GoColor color,
GoPoint point)
Play a move.
|
void |
play(Move move)
Play a move.
|
void |
setToMove(GoColor toMove)
Change the color to move.
|
void |
setup(ConstPointList black,
ConstPointList white,
GoColor player)
Setup position.
|
void |
setupHandicap(ConstPointList points)
Setup initial handicap stones.
|
void |
undo()
Undo the last move.
|
void |
undo(int n)
Undo a number of moves.
|
public Board(int boardSize)
boardSize
- The board size (number of points per row / column)
in the range from one to GoPoint.MAX_SIZEpublic boolean bothPassed()
bothPassed
in interface ConstBoard
public boolean contains(GoPoint point)
contains
in interface ConstBoard
point
- The point to checkpublic ConstPointList getAdjacent(GoPoint point)
getAdjacent
in interface ConstBoard
point
- The point.public int getCaptured(GoColor c)
getCaptured
in interface ConstBoard
public GoColor getColor(GoPoint p)
getColor
in interface ConstBoard
public static ConstPointList getHandicapStones(int size, int n)
n
- The number of handicap stones.size
- The board size.BoardConstants.getHandicapStones(int)
public ConstPointList getKilled()
getKilled
in interface ConstBoard
getSuicide()
public Move getLastMove()
getLastMove
in interface ConstBoard
public int getNumberMoves()
getNumberMoves
in interface ConstBoard
getMove(int)
public Move getMove(int i)
getMove
in interface ConstBoard
i
- The number of the move (starting with zero).getNumberMoves()
public ConstPointList getSetup(GoColor c)
getSetup
in interface ConstBoard
c
- Black or White.setup
.setup(net.sf.gogui.go.ConstPointList, net.sf.gogui.go.ConstPointList, net.sf.gogui.go.GoColor)
public GoColor getSetupPlayer()
getSetupPlayer
in interface ConstBoard
setup
; null
means unknown player color.setup(net.sf.gogui.go.ConstPointList, net.sf.gogui.go.ConstPointList, net.sf.gogui.go.GoColor)
public int getSize()
getSize
in interface ConstBoard
public void getStones(GoPoint p, GoColor color, PointList stones)
getStones
in interface ConstBoard
public ConstPointList getSuicide()
getSuicide
in interface ConstBoard
getKilled()
public GoColor getToMove()
getToMove
in interface ConstBoard
public void init(int size)
size
- The new board size (number of points per
row / column) in the range from one to GoPoint.MAX_SIZEpublic boolean isCaptureOrSuicide(GoColor c, GoPoint p)
isCaptureOrSuicide
in interface ConstBoard
c
- The player color.p
- The point to check.public boolean isHandicap(GoPoint point)
isHandicap
in interface ConstBoard
point
- The point to check.BoardConstants.isHandicap(net.sf.gogui.go.GoPoint)
public boolean isKo(GoPoint point)
isKo
in interface ConstBoard
point
- The point to checkpublic boolean isModified()
isModified
in interface ConstBoard
public boolean isSetupHandicap()
isSetupHandicap
in interface ConstBoard
true
, if the initial position was setup by
calling setupHandicap, false
otherwise.setupHandicap(net.sf.gogui.go.ConstPointList)
public boolean isSuicide(GoColor c, GoPoint p)
isSuicide
in interface ConstBoard
c
- The player color to check.p
- The point to check.public java.util.Iterator<GoPoint> iterator()
iterator
in interface java.lang.Iterable<GoPoint>
iterator
in interface ConstBoard
public void clear()
public void play(GoColor color, GoPoint point)
color
- The player who played the move.point
- The location of the move.play(Move)
public void play(Move move)
move
- The move (location and player)public void setToMove(GoColor toMove)
toMove
- The new color to move.public void setup(ConstPointList black, ConstPointList white, GoColor player)
black
- Black stones to add on the board.white
- White stones to add on the board.player
- Color to playpublic void setupHandicap(ConstPointList points)
isSetupHandicap
.isSetupHandicap()
public void undo()
public void undo(int n)
n
- Number of moves to undo. Must be between 0
and getNumberMoves().undo()