#include <GoUctBoard.h>
In contrast to class GoBoard, this board makes certain assumptions that are usually true for Monte-Carlo simulations for better efficiency:
Otherwise, the member functions are named like in class GoBoard to allow writing utility functions that use the board class as a template parameter (as long as they use only the functionality shared by both board classes)
Definition at line 42 of file GoUctBoard.h.
Public Member Functions | |
GoUctBoard (const GoBoard &bd) | |
~GoUctBoard () | |
const SgBoardConst & | BoardConst () const |
void | Init (const GoBoard &bd) |
Re-initializes the board from GoBoard position. | |
SgGrid | Size () const |
Return the size of this board. | |
bool | Occupied (SgPoint p) const |
Check if point is occupied by a stone. | |
bool | IsEmpty (SgPoint p) const |
bool | IsBorder (SgPoint p) const |
bool | IsColor (SgPoint p, int c) const |
SgBoardColor | GetColor (SgPoint p) const |
SgBlackWhite | GetStone (SgPoint p) const |
SgBlackWhite | ToPlay () const |
Player whose turn it is to play. | |
SgBlackWhite | Opponent () const |
Opponent of player whose turn it is to play. | |
SgGrid | Line (SgPoint p) const |
See SgBoardConst::Line. | |
SgGrid | Pos (SgPoint p) const |
See SgBoardConst::Pos. | |
int | Up (SgPoint p) const |
Returns the offset to the point on the line above this point. | |
int | Left (SgPoint p) const |
Returns the offset along left side of the board. | |
int | Right (SgPoint p) const |
Returns the offset along right side of the board. | |
int | Side (SgPoint p, int index) const |
Same as Left/Right, but the side is passed in as an index (0 or 1). | |
bool | IsSuicide (SgPoint p, SgBlackWhite toPlay) const |
bool | IsValidPoint (SgPoint p) const |
bool | HasEmptyNeighbors (SgPoint p) const |
int | NumEmptyNeighbors (SgPoint p) const |
int | Num8EmptyNeighbors (SgPoint p) const |
Includes diagonals. | |
bool | HasNeighbors (SgPoint p, SgBlackWhite c) const |
int | NumNeighbors (SgPoint p, SgBlackWhite c) const |
int | Num8Neighbors (SgPoint p, SgBlackWhite c) const |
Includes diagonals. | |
bool | HasDiagonals (SgPoint p, SgBoardColor c) const |
int | NumDiagonals (SgPoint p, SgBoardColor c) const |
int | NumEmptyDiagonals (SgPoint p) const |
bool | HasNeighborsOrDiags (SgPoint p, SgBlackWhite c) const |
bool | InCorner (SgPoint p) const |
bool | OnEdge (SgPoint p) const |
bool | InCenter (SgPoint p) const |
int | FirstBoardPoint () const |
See SgBoardConst::FirstBoardPoint. | |
int | LastBoardPoint () const |
See SgBoardConst::FirstBoardPoint. | |
void | Play (SgPoint p) |
Play a move for the current player. | |
bool | IsLegal (int p, SgBlackWhite player) const |
Check whether the move at 'p' is legal. | |
bool | IsLegal (int p) const |
Check whether the move at 'p' is legal for color to play. | |
bool | IsSuicide (SgPoint p) const |
bool | CapturingMove () const |
Whether the most recent move captured any stones. | |
const GoPointList & | CapturedStones () const |
The stones removed from the board by the most recent move. | |
int | NuCapturedStones () const |
The stones captured by the most recent move. | |
int | NumPrisoners (SgBlackWhite color) const |
The total number of stones of 'color' that have been captured by the opponent throughout the game. | |
SgPoint | GetLastMove () const |
Return last move played. | |
SgPoint | Get2ndLastMove () const |
2nd Last move = last move by ToPlay(). | |
int | NumStones (SgPoint p) const |
Return the number of stones in the block at 'p'. | |
bool | IsSingleStone (SgPoint p) const |
Return NumStones(p) == 1. | |
bool | AreInSameBlock (SgPoint stone1, SgPoint stone2) const |
Return whether the two stones are located in the same block. | |
SgPoint | Anchor (SgPoint p) const |
Return a reference point in the block at a point. | |
bool | IsInBlock (SgPoint p, SgPoint anchor) const |
See GoBoard::IsInBlock. | |
bool | IsLibertyOfBlock (SgPoint p, SgPoint anchor) const |
See GoBoard::IsLibertyOfBlock. | |
int | AdjacentBlocks (SgPoint p, int maxLib, SgPoint anchors[], int maxAnchors) const |
Get adjacent opponent blocks with a maximum number of liberties for a given block. | |
void | NeighborBlocks (SgPoint p, SgBlackWhite c, SgPoint anchors[]) const |
List anchor of each block of color 'c' adjacent to the empty point 'p'. | |
void | NeighborBlocks (SgPoint p, SgBlackWhite c, int maxLib, SgPoint anchors[]) const |
List anchor of each block of color 'c' with at most 'maxLib' liberties adjacent to the empty point 'p'. | |
SgPoint | TheLiberty (SgPoint blockInAtari) const |
Return the liberty of 'blockInAtari' which must have exactly one liberty. | |
int | NumLiberties (SgPoint p) const |
Return the number of liberties of the block at 'p'. | |
bool | AtMostNumLibs (SgPoint block, int n) const |
Return whether block has at most n liberties. | |
bool | AtLeastNumLibs (SgPoint block, int n) const |
Return whether block has at least n liberties. | |
bool | InAtari (SgPoint p) const |
Return whether the number of liberties of the block at 'p' is one. | |
bool | OccupiedInAtari (SgPoint p) const |
Check if point is occupied and in atari. | |
bool | CanCapture (SgPoint p, SgBlackWhite c) const |
Return whether playing colour c at p can capture anything, ignoring any possible repetition. | |
void | CheckConsistency () const |
Checks whether all the board data structures are in a consistent state. | |
Public Attributes | |
SgMarker | m_userMarker |
Marker that can be used in client code. | |
Private Member Functions | |
GoUctBoard (const GoUctBoard &) | |
Not implemented. | |
GoUctBoard & | operator= (const GoUctBoard &) |
Not implemented. | |
void | AddLibToAdjBlocks (SgPoint p, SgBlackWhite c) |
void | AddStoneToBlock (SgPoint p, Block *block) |
void | CreateSingleStoneBlock (SgPoint p, SgBlackWhite c) |
void | InitSize (const GoBoard &bd) |
bool | IsAdjacentTo (SgPoint p, const Block *block) const |
void | MergeBlocks (SgPoint p, const SgSList< Block *, 4 > &adjBlocks) |
void | RemoveLibAndKill (SgPoint p, SgBlackWhite opp, SgSList< Block *, 4 > &ownAdjBlocks) |
Remove liberty from adjacent blocks and kill opponent blocks without liberties. | |
void | UpdateBlocksAfterAddStone (SgPoint p, SgBlackWhite c, const SgSList< Block *, 4 > &adjBlocks) |
void | CheckConsistencyBlock (SgPoint p) const |
bool | FullBoardRepetition () const |
void | AddStone (SgPoint p, SgBlackWhite c) |
void | KillBlock (const Block *block) |
bool | HasLiberties (SgPoint p) const |
Private Attributes | |
SgPoint | m_lastMove |
SgPoint | m_secondLastMove |
SgPoint | m_koPoint |
Point which is currently illegal for simple Ko rule. | |
SgBlackWhite | m_toPlay |
Whose turn it is to play. | |
SgArray< Block *, SG_MAXPOINT > | m_block |
SgBWArray< int > | m_prisoners |
Number of prisoners of each color. | |
SgArray< int, SG_MAXPOINT > | m_color |
The current board position. | |
SgArray< int, SG_MAXPOINT > | m_nuNeighborsEmpty |
Number of black and white neighbors. | |
SgBWArray< SgArray< int, SG_MAXPOINT > > | m_nuNeighbors |
Number of black and white neighbors. | |
SgBoardConst | m_const |
Data that's constant for this board size. | |
SgGrid | m_size |
The current board size. | |
SgPointArray< Block > | m_blockArray |
SgMarker | m_marker |
SgMarker | m_marker2 |
GoPointList | m_capturedStones |
SgArray< bool, SG_MAXPOINT > | m_isBorder |
Friends | |
class | LibertyIterator |
class | StoneIterator |
Classes | |
struct | Block |
Data related to a block of stones on the board. More... | |
class | Iterator |
Iterate through all points on the given board. More... | |
class | LibertyIterator |
Iterate through all the liberties of a block. More... | |
class | StoneIterator |
Iterate through all the stones of a block. More... |
GoUctBoard::GoUctBoard | ( | const GoBoard & | bd | ) | [explicit] |
GoUctBoard::~GoUctBoard | ( | ) |
Definition at line 41 of file GoUctBoard.cpp.
GoUctBoard::GoUctBoard | ( | const GoUctBoard & | ) | [private] |
Not implemented.
void GoUctBoard::AddLibToAdjBlocks | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 113 of file GoUctBoard.cpp.
References SgMarker::Clear(), SgMarker::Contains(), SgMarker::Include(), GoUctBoard::Block::m_anchor, m_block, m_color, GoUctBoard::Block::m_liberties, m_marker2, SgMarker::NewMark(), NumNeighbors(), SG_NS, and SG_WE.
Referenced by KillBlock().
void GoUctBoard::AddStone | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 322 of file GoUctBoard.cpp.
References IsEmpty(), m_color, m_nuNeighbors, m_nuNeighborsEmpty, SG_ASSERT, SG_ASSERT_BW, SG_NS, and SG_WE.
Referenced by Play().
Definition at line 136 of file GoUctBoard.cpp.
References IsAdjacentTo(), IsColor(), IsEmpty(), m_block, GoUctBoard::Block::m_color, GoUctBoard::Block::m_liberties, GoUctBoard::Block::m_stones, SgSList< T, SIZE >::PushBack(), SG_ASSERT, SG_NS, and SG_WE.
Referenced by UpdateBlocksAfterAddStone().
Get adjacent opponent blocks with a maximum number of liberties for a given block.
Not defined for empty points.
p | The block to check. | |
maxLib | The maximum number of liberties of the neighbors. | |
anchors | Resulting neighbor anchors and an additional END_POINT. | |
maxAnchors | Array size of anchors (for detecting overflow in debug mode) |
Definition at line 543 of file GoUctBoard.h.
References Anchor(), AtMostNumLibs(), SgMarker::Clear(), GetStone(), IsColor(), m_marker, SgMarker::NewMark(), NumNeighbors(), Occupied(), SG_ASSERT, SG_DEBUG_ONLY, SG_ENDPOINT, SG_NS, SG_UNUSED(), SG_WE, and SgOppBW().
Return a reference point in the block at a point.
Definition at line 582 of file GoUctBoard.h.
References m_block, Occupied(), and SG_ASSERT.
Referenced by AdjacentBlocks(), AreInSameBlock(), IsLibertyOfBlock(), and NeighborBlocks().
Return whether the two stones are located in the same block.
Return false if one of the stones is an empty or border point.
Definition at line 588 of file GoUctBoard.h.
References Anchor(), and Occupied().
bool GoUctBoard::AtLeastNumLibs | ( | SgPoint | block, | |
int | n | |||
) | const |
Return whether block has at least n liberties.
Definition at line 593 of file GoUctBoard.h.
References NumLiberties().
bool GoUctBoard::AtMostNumLibs | ( | SgPoint | block, | |
int | n | |||
) | const |
Return whether block has at most n liberties.
Definition at line 598 of file GoUctBoard.h.
References NumLiberties().
Referenced by AdjacentBlocks(), CanCapture(), InAtari(), and NeighborBlocks().
const SgBoardConst & GoUctBoard::BoardConst | ( | ) | const |
bool GoUctBoard::CanCapture | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Return whether playing colour c at p can capture anything, ignoring any possible repetition.
Definition at line 699 of file GoUctBoard.h.
References AtMostNumLibs(), IsColor(), and SgOppBW().
const GoPointList & GoUctBoard::CapturedStones | ( | ) | const |
The stones removed from the board by the most recent move.
Can be used for incremental update of other data structures. Only valid directly after a GoUctBoard::Play, otherwise undefined.
Definition at line 603 of file GoUctBoard.h.
References m_capturedStones.
bool GoUctBoard::CapturingMove | ( | ) | const |
Whether the most recent move captured any stones.
Definition at line 608 of file GoUctBoard.h.
References SgSList< T, SIZE >::IsEmpty(), and m_capturedStones.
void GoUctBoard::CheckConsistency | ( | ) | const |
Checks whether all the board data structures are in a consistent state.
Definition at line 45 of file GoUctBoard.cpp.
References CheckConsistencyBlock(), CONSISTENCY, IsBorder(), m_block, m_color, NumEmptyNeighbors(), NumNeighbors(), SG_ASSERT, SG_ASSERT_EBW, SG_BLACK, SG_EMPTY, SG_MAXPOINT, and SG_WHITE.
void GoUctBoard::CheckConsistencyBlock | ( | SgPoint | p | ) | const [private] |
Definition at line 77 of file GoUctBoard.cpp.
References GetColor(), IsBorder(), SgStack< T, SIZE >::IsEmpty(), SgSList< T, SIZE >::Length(), GoUctBoard::Block::m_anchor, m_block, GoUctBoard::Block::m_color, GoUctBoard::Block::m_liberties, GoUctBoard::Block::m_stones, SgMarker::NewMark(), NumStones(), Occupied(), SgStack< T, SIZE >::Pop(), SgStack< T, SIZE >::Push(), SgSList< T, SIZE >::PushBack(), SgSList< T, SIZE >::SameElements(), SG_ASSERT, SG_EMPTY, SG_NS, and SG_WE.
Referenced by CheckConsistency().
void GoUctBoard::CreateSingleStoneBlock | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 152 of file GoUctBoard.cpp.
References GoUctBoard::Block::InitSingleStoneBlock(), IsColor(), IsEmpty(), m_block, m_blockArray, GoUctBoard::Block::m_liberties, NumNeighbors(), SG_ASSERT, SG_NS, and SG_WE.
Referenced by UpdateBlocksAfterAddStone().
int GoUctBoard::FirstBoardPoint | ( | ) | const |
See SgBoardConst::FirstBoardPoint.
Definition at line 613 of file GoUctBoard.h.
References SgBoardConst::FirstBoardPoint(), and m_const.
bool GoUctBoard::FullBoardRepetition | ( | ) | const [private] |
SgPoint GoUctBoard::Get2ndLastMove | ( | ) | const |
2nd Last move = last move by ToPlay().
Conditions similar to GetLastMove().
Definition at line 623 of file GoUctBoard.h.
References m_secondLastMove.
SgBoardColor GoUctBoard::GetColor | ( | SgPoint | p | ) | const |
Definition at line 628 of file GoUctBoard.h.
References m_color.
Referenced by CheckConsistencyBlock(), IsSingleStone(), and IsSuicide().
SgPoint GoUctBoard::GetLastMove | ( | ) | const |
Return last move played.
Definition at line 633 of file GoUctBoard.h.
References m_lastMove.
SgBlackWhite GoUctBoard::GetStone | ( | SgPoint | p | ) | const |
Definition at line 638 of file GoUctBoard.h.
References m_color, Occupied(), and SG_ASSERT.
Referenced by AdjacentBlocks().
bool GoUctBoard::HasDiagonals | ( | SgPoint | p, | |
SgBoardColor | c | |||
) | const |
Definition at line 644 of file GoUctBoard.h.
References IsColor(), SG_NS, and SG_WE.
Referenced by HasNeighborsOrDiags().
bool GoUctBoard::HasEmptyNeighbors | ( | SgPoint | p | ) | const |
Definition at line 652 of file GoUctBoard.h.
References m_nuNeighborsEmpty.
Referenced by IsSuicide().
bool GoUctBoard::HasLiberties | ( | SgPoint | p | ) | const [private] |
bool GoUctBoard::HasNeighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Definition at line 662 of file GoUctBoard.h.
References m_nuNeighbors.
Referenced by HasNeighborsOrDiags().
bool GoUctBoard::HasNeighborsOrDiags | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
bool GoUctBoard::InAtari | ( | SgPoint | p | ) | const |
Return whether the number of liberties of the block at 'p' is one.
Requires: Occupied(p)
Definition at line 672 of file GoUctBoard.h.
References AtMostNumLibs(), Occupied(), and SG_ASSERT.
bool GoUctBoard::InCenter | ( | SgPoint | p | ) | const |
bool GoUctBoard::InCorner | ( | SgPoint | p | ) | const |
void GoUctBoard::Init | ( | const GoBoard & | bd | ) |
Re-initializes the board from GoBoard position.
Definition at line 243 of file GoUctBoard.cpp.
References CheckConsistency(), GoBoard::Get2ndLastMove(), GoBoard::GetLastMove(), GoUctBoard::Block::InitNewBlock(), InitSize(), GoBoard::KoPoint(), m_block, m_blockArray, m_color, m_koPoint, m_lastMove, GoUctBoard::Block::m_liberties, m_nuNeighbors, m_nuNeighborsEmpty, m_prisoners, m_secondLastMove, m_size, GoUctBoard::Block::m_stones, m_toPlay, GoBoard::NumPrisoners(), SgSList< T, SIZE >::PushBack(), SG_BLACK, SG_WHITE, GoBoard::Size(), and GoBoard::ToPlay().
Referenced by GoUctBoard(), and GoUctState::StartPlayout().
void GoUctBoard::InitSize | ( | const GoBoard & | bd | ) | [private] |
Definition at line 280 of file GoUctBoard.cpp.
References SgBoardConst::ChangeSize(), SgArray< T, SIZE >::Fill(), GoBoard::IsBorder(), m_block, m_color, m_const, m_isBorder, m_nuNeighbors, m_nuNeighborsEmpty, m_size, SG_BLACK, SG_BORDER, SG_MAXPOINT, SG_WHITE, and GoBoard::Size().
Referenced by Init().
Definition at line 170 of file GoUctBoard.cpp.
References m_block, SG_NS, and SG_WE.
Referenced by AddStoneToBlock().
bool GoUctBoard::IsBorder | ( | SgPoint | p | ) | const |
Definition at line 726 of file GoUctBoard.h.
References m_isBorder, SG_ASSERT, and SG_PASS.
Referenced by CheckConsistency(), CheckConsistencyBlock(), IsSuicide(), and IsValidPoint().
bool GoUctBoard::IsColor | ( | SgPoint | p, | |
int | c | |||
) | const |
Definition at line 732 of file GoUctBoard.h.
References m_color, SG_ASSERT, SG_ASSERT_EBW, and SG_PASS.
Referenced by AddStoneToBlock(), AdjacentBlocks(), CanCapture(), CreateSingleStoneBlock(), HasDiagonals(), MergeBlocks(), NeighborBlocks(), NumDiagonals(), and UpdateBlocksAfterAddStone().
bool GoUctBoard::IsEmpty | ( | SgPoint | p | ) | const |
Definition at line 739 of file GoUctBoard.h.
References m_color, SG_ASSERT, SG_EMPTY, and SG_PASS.
Referenced by AddStone(), AddStoneToBlock(), CreateSingleStoneBlock(), IsLegal(), IsLibertyOfBlock(), NeighborBlocks(), and Play().
See GoBoard::IsInBlock.
Definition at line 678 of file GoUctBoard.h.
References GoUctBoard::Block::m_anchor, m_block, Occupied(), and SG_ASSERT.
bool GoUctBoard::IsLegal | ( | int | p | ) | const |
Check whether the move at 'p' is legal for color to play.
Definition at line 762 of file GoUctBoard.h.
bool GoUctBoard::IsLegal | ( | int | p, | |
SgBlackWhite | player | |||
) | const |
Check whether the move at 'p' is legal.
Since it's not clear how 'p' was arrived at, any value of 'p' is admissible, even out of point range and on border points; just return false on such input.
Definition at line 745 of file GoUctBoard.h.
References SgPointUtil::InBoardRange(), IsEmpty(), IsSuicide(), m_koPoint, m_toPlay, SG_ASSERT, SG_ASSERT_BW, and SG_PASS.
Referenced by IsLegal().
See GoBoard::IsLibertyOfBlock.
Definition at line 685 of file GoUctBoard.h.
References Anchor(), IsEmpty(), m_block, GoUctBoard::Block::m_color, m_nuNeighbors, Occupied(), SG_ASSERT, SG_NS, and SG_WE.
bool GoUctBoard::IsSingleStone | ( | SgPoint | p | ) | const |
Return NumStones(p) == 1.
Definition at line 767 of file GoUctBoard.h.
References GetColor(), NumNeighbors(), and Occupied().
bool GoUctBoard::IsSuicide | ( | SgPoint | p | ) | const |
bool GoUctBoard::IsSuicide | ( | SgPoint | p, | |
SgBlackWhite | toPlay | |||
) | const |
Definition at line 708 of file GoUctBoard.h.
References GetColor(), HasEmptyNeighbors(), IsBorder(), NumLiberties(), and SgOppBW().
Referenced by IsLegal(), and IsSuicide().
bool GoUctBoard::IsValidPoint | ( | SgPoint | p | ) | const |
Definition at line 777 of file GoUctBoard.h.
References SgPointUtil::InBoardRange(), and IsBorder().
Referenced by NumLiberties(), and Play().
void GoUctBoard::KillBlock | ( | const Block * | block | ) | [private] |
Definition at line 396 of file GoUctBoard.cpp.
References AddLibToAdjBlocks(), SgSList< T, SIZE >::Length(), GoUctBoard::Block::m_anchor, m_block, m_capturedStones, m_color, GoUctBoard::Block::m_color, m_koPoint, m_nuNeighbors, m_nuNeighborsEmpty, m_prisoners, GoUctBoard::Block::m_stones, SgSList< T, SIZE >::PushBack(), SG_EMPTY, SG_NS, SG_WE, and SgOppBW().
Referenced by RemoveLibAndKill().
int GoUctBoard::LastBoardPoint | ( | ) | const |
See SgBoardConst::FirstBoardPoint.
Definition at line 782 of file GoUctBoard.h.
References SgBoardConst::LastBoardPoint(), and m_const.
int GoUctBoard::Left | ( | SgPoint | p | ) | const |
Returns the offset along left side of the board.
Left and right are as seen from the edge toward the center of the board. Returns zero for the same points as Up does.
Definition at line 787 of file GoUctBoard.h.
References SgBoardConst::Left(), and m_const.
See SgBoardConst::Line.
Definition at line 792 of file GoUctBoard.h.
References SgBoardConst::Line(), and m_const.
Definition at line 179 of file GoUctBoard.cpp.
References SgMarker::Clear(), SgMarker::Include(), IsColor(), m_block, m_color, GoUctBoard::Block::m_liberties, m_marker, GoUctBoard::Block::m_stones, SgMarker::NewMark(), NumNeighbors(), SgSList< T, SIZE >::PushBack(), and SG_ASSERT.
Referenced by UpdateBlocksAfterAddStone().
void GoUctBoard::NeighborBlocks | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
int | maxLib, | |||
SgPoint | anchors[] | |||
) | const |
List anchor of each block of color 'c' with at most 'maxLib' liberties adjacent to the empty point 'p'.
Assert if 'p' is not empty. Fill an array of points, terminated by END_POINT.
Definition at line 797 of file GoUctBoard.h.
References Anchor(), AtMostNumLibs(), SgMarker::Clear(), IsColor(), IsEmpty(), m_marker, SgMarker::NewMark(), NumNeighbors(), SG_ASSERT, SG_ENDPOINT, SG_NS, SG_UNUSED(), and SG_WE.
void GoUctBoard::NeighborBlocks | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
SgPoint | anchors[] | |||
) | const |
List anchor of each block of color 'c' adjacent to the empty point 'p'.
Assert if 'p' is not empty. Fill an array of points, terminated by END_POINT.
Definition at line 300 of file GoUctBoard.cpp.
References Anchor(), SgMarker::Clear(), IsColor(), IsEmpty(), m_marker, SgMarker::NewMark(), NumNeighbors(), SG_ASSERT, SG_ENDPOINT, SG_NS, SG_UNUSED(), and SG_WE.
int GoUctBoard::NuCapturedStones | ( | ) | const |
The stones captured by the most recent move.
Definition at line 833 of file GoUctBoard.h.
References SgSList< T, SIZE >::Length(), and m_capturedStones.
Referenced by GoUctGlobalSearchState< POLICY >::ExecutePlayout().
int GoUctBoard::Num8EmptyNeighbors | ( | SgPoint | p | ) | const |
Includes diagonals.
Definition at line 828 of file GoUctBoard.h.
References NumEmptyDiagonals(), and NumEmptyNeighbors().
int GoUctBoard::Num8Neighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Includes diagonals.
Definition at line 823 of file GoUctBoard.h.
References NumDiagonals(), and NumNeighbors().
int GoUctBoard::NumDiagonals | ( | SgPoint | p, | |
SgBoardColor | c | |||
) | const |
Definition at line 838 of file GoUctBoard.h.
References IsColor(), SG_NS, and SG_WE.
Referenced by Num8Neighbors(), and NumEmptyDiagonals().
int GoUctBoard::NumEmptyDiagonals | ( | SgPoint | p | ) | const |
Definition at line 852 of file GoUctBoard.h.
References NumDiagonals(), and SG_EMPTY.
Referenced by Num8EmptyNeighbors().
int GoUctBoard::NumEmptyNeighbors | ( | SgPoint | p | ) | const |
Definition at line 857 of file GoUctBoard.h.
References m_nuNeighborsEmpty.
Referenced by CheckConsistency(), and Num8EmptyNeighbors().
int GoUctBoard::NumLiberties | ( | SgPoint | p | ) | const |
Return the number of liberties of the block at 'p'.
Not defined for empty or border points.
Definition at line 862 of file GoUctBoard.h.
References IsValidPoint(), m_block, Occupied(), and SG_ASSERT.
Referenced by AtLeastNumLibs(), AtMostNumLibs(), HasLiberties(), IsSuicide(), Play(), and TheLiberty().
int GoUctBoard::NumNeighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Definition at line 869 of file GoUctBoard.h.
References m_nuNeighbors.
Referenced by AddLibToAdjBlocks(), AdjacentBlocks(), CheckConsistency(), CreateSingleStoneBlock(), IsSingleStone(), MergeBlocks(), NeighborBlocks(), Num8Neighbors(), and Play().
int GoUctBoard::NumPrisoners | ( | SgBlackWhite | color | ) | const |
The total number of stones of 'color' that have been captured by the opponent throughout the game.
Definition at line 874 of file GoUctBoard.h.
References m_prisoners.
int GoUctBoard::NumStones | ( | SgPoint | p | ) | const |
Return the number of stones in the block at 'p'.
Not defined for empty or border points.
Definition at line 879 of file GoUctBoard.h.
References m_block, Occupied(), and SG_ASSERT.
Referenced by CheckConsistencyBlock(), and Play().
bool GoUctBoard::Occupied | ( | SgPoint | p | ) | const |
Check if point is occupied by a stone.
Can be called with border points.
Definition at line 885 of file GoUctBoard.h.
References m_block.
Referenced by AdjacentBlocks(), Anchor(), AreInSameBlock(), CheckConsistencyBlock(), GoUctState::ExecutePlayout(), GetStone(), InAtari(), IsInBlock(), IsLibertyOfBlock(), IsSingleStone(), GoUctBoard::LibertyIterator::LibertyIterator(), NumLiberties(), NumStones(), GoUctBoard::StoneIterator::StoneIterator(), and TheLiberty().
bool GoUctBoard::OccupiedInAtari | ( | SgPoint | p | ) | const |
Check if point is occupied and in atari.
Faster than Occupied(p) || InAtari(p). May be called for border points.
Definition at line 890 of file GoUctBoard.h.
References m_block, and GoUctBoard::Block::m_liberties.
bool GoUctBoard::OnEdge | ( | SgPoint | p | ) | const |
GoUctBoard& GoUctBoard::operator= | ( | const GoUctBoard & | ) | [private] |
Not implemented.
SgBlackWhite GoUctBoard::Opponent | ( | ) | const |
void GoUctBoard::Play | ( | SgPoint | p | ) |
Play a move for the current player.
Definition at line 425 of file GoUctBoard.cpp.
References AddStone(), CheckConsistency(), SgSList< T, SIZE >::Clear(), HasLiberties(), IsEmpty(), IsValidPoint(), m_capturedStones, m_koPoint, m_lastMove, m_secondLastMove, m_toPlay, NumLiberties(), NumNeighbors(), NumStones(), RemoveLibAndKill(), SG_ASSERT, SG_BLACK, SG_NULLPOINT, SG_PASS, SG_WHITE, SgOppBW(), and UpdateBlocksAfterAddStone().
Referenced by GoUctState::ExecutePlayout().
See SgBoardConst::Pos.
Definition at line 901 of file GoUctBoard.h.
References m_const, and SgBoardConst::Pos().
void GoUctBoard::RemoveLibAndKill | ( | SgPoint | p, | |
SgBlackWhite | opp, | |||
SgSList< Block *, 4 > & | ownAdjBlocks | |||
) | [private] |
Remove liberty from adjacent blocks and kill opponent blocks without liberties.
As a side effect, computes adjacent blocks of own color to avoid a second call to GetAdjacentBlocks() in UpdateBlocksAfterAddStone().
Definition at line 343 of file GoUctBoard.cpp.
References SgMarker::Clear(), SgMarker::Contains(), SgMarker::Include(), KillBlock(), GoUctBoard::Block::m_anchor, m_block, GoUctBoard::Block::m_color, GoUctBoard::Block::m_liberties, m_marker, SgMarker::NewMark(), SgSList< T, SIZE >::PushBack(), SG_NS, and SG_WE.
Referenced by Play().
int GoUctBoard::Right | ( | SgPoint | p | ) | const |
Returns the offset along right side of the board.
Definition at line 906 of file GoUctBoard.h.
References m_const, and SgBoardConst::Right().
int GoUctBoard::Side | ( | SgPoint | p, | |
int | index | |||
) | const |
Same as Left/Right, but the side is passed in as an index (0 or 1).
Definition at line 911 of file GoUctBoard.h.
References m_const, and SgBoardConst::Side().
SgGrid GoUctBoard::Size | ( | ) | const |
Return the liberty of 'blockInAtari' which must have exactly one liberty.
Definition at line 921 of file GoUctBoard.h.
References m_block, NumLiberties(), Occupied(), and SG_ASSERT.
SgBlackWhite GoUctBoard::ToPlay | ( | ) | const |
Player whose turn it is to play.
Definition at line 928 of file GoUctBoard.h.
References m_toPlay.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::ExecutePlayout(), IsLegal(), and IsSuicide().
int GoUctBoard::Up | ( | SgPoint | p | ) | const |
Returns the offset to the point on the line above this point.
Returns zero for points outside the board, and for the center point(s).
Definition at line 933 of file GoUctBoard.h.
References m_const, and SgBoardConst::Up().
void GoUctBoard::UpdateBlocksAfterAddStone | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
const SgSList< Block *, 4 > & | adjBlocks | |||
) | [private] |
Definition at line 226 of file GoUctBoard.cpp.
References AddStoneToBlock(), CreateSingleStoneBlock(), IsColor(), SgSList< T, SIZE >::Length(), MergeBlocks(), and SG_ASSERT.
Referenced by Play().
friend class LibertyIterator [friend] |
Definition at line 413 of file GoUctBoard.h.
friend class StoneIterator [friend] |
Definition at line 414 of file GoUctBoard.h.
SgArray<Block*,SG_MAXPOINT> GoUctBoard::m_block [private] |
Definition at line 348 of file GoUctBoard.h.
Referenced by AddLibToAdjBlocks(), AddStoneToBlock(), Anchor(), CheckConsistency(), CheckConsistencyBlock(), CreateSingleStoneBlock(), Init(), InitSize(), IsAdjacentTo(), IsInBlock(), IsLibertyOfBlock(), KillBlock(), MergeBlocks(), NumLiberties(), NumStones(), Occupied(), OccupiedInAtari(), RemoveLibAndKill(), and TheLiberty().
SgPointArray<Block> GoUctBoard::m_blockArray [private] |
GoPointList GoUctBoard::m_capturedStones [private] |
Definition at line 374 of file GoUctBoard.h.
Referenced by CapturedStones(), CapturingMove(), KillBlock(), NuCapturedStones(), and Play().
SgArray<int,SG_MAXPOINT> GoUctBoard::m_color [private] |
The current board position.
Definition at line 354 of file GoUctBoard.h.
Referenced by AddLibToAdjBlocks(), AddStone(), CheckConsistency(), GetColor(), GetStone(), Init(), InitSize(), IsColor(), IsEmpty(), KillBlock(), and MergeBlocks().
SgBoardConst GoUctBoard::m_const [private] |
Data that's constant for this board size.
Definition at line 363 of file GoUctBoard.h.
Referenced by BoardConst(), FirstBoardPoint(), InitSize(), LastBoardPoint(), Left(), Line(), Pos(), Right(), Side(), and Up().
SgArray<bool,SG_MAXPOINT> GoUctBoard::m_isBorder [private] |
SgPoint GoUctBoard::m_koPoint [private] |
Point which is currently illegal for simple Ko rule.
Definition at line 343 of file GoUctBoard.h.
Referenced by Init(), IsLegal(), KillBlock(), and Play().
SgPoint GoUctBoard::m_lastMove [private] |
SgMarker GoUctBoard::m_marker [mutable, private] |
Definition at line 370 of file GoUctBoard.h.
Referenced by AdjacentBlocks(), MergeBlocks(), NeighborBlocks(), and RemoveLibAndKill().
SgMarker GoUctBoard::m_marker2 [private] |
SgBWArray<SgArray<int,SG_MAXPOINT> > GoUctBoard::m_nuNeighbors [private] |
Number of black and white neighbors.
Definition at line 360 of file GoUctBoard.h.
Referenced by AddStone(), HasNeighbors(), Init(), InitSize(), IsLibertyOfBlock(), KillBlock(), and NumNeighbors().
SgArray<int,SG_MAXPOINT> GoUctBoard::m_nuNeighborsEmpty [private] |
Number of black and white neighbors.
Definition at line 357 of file GoUctBoard.h.
Referenced by AddStone(), HasEmptyNeighbors(), Init(), InitSize(), KillBlock(), and NumEmptyNeighbors().
SgBWArray<int> GoUctBoard::m_prisoners [private] |
Number of prisoners of each color.
Definition at line 351 of file GoUctBoard.h.
Referenced by Init(), KillBlock(), and NumPrisoners().
SgPoint GoUctBoard::m_secondLastMove [private] |
SgGrid GoUctBoard::m_size [private] |
The current board size.
Definition at line 366 of file GoUctBoard.h.
Referenced by GoUctBoard(), Init(), InitSize(), and Size().
SgBlackWhite GoUctBoard::m_toPlay [private] |
Whose turn it is to play.
Definition at line 346 of file GoUctBoard.h.
Referenced by Init(), IsLegal(), Opponent(), Play(), and ToPlay().
SgMarker GoUctBoard::m_userMarker [mutable] |
Marker that can be used in client code.
This marker is never used by this class, it is intended for external functions that operate on the board and can profit from the fast clear operation of SgMarker (if reused), but cannot store its own marker (or don't want to use a global variable for thread-safety). Since only one function can use this marker at a time, you should assert with SgReserveMarker that the marker is not used in a conflicting way.
Definition at line 54 of file GoUctBoard.h.