Go board optimized for Monte-Carlo. More...
#include <GoUctBoard.h>
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... | |
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 SgArrayList< Block *, 4 > &adjBlocks) |
void | RemoveLibAndKill (SgPoint p, SgBlackWhite opp, SgArrayList< Block *, 4 > &ownAdjBlocks) |
Remove liberty from adjacent blocks and kill opponent blocks without liberties. | |
void | UpdateBlocksAfterAddStone (SgPoint p, SgBlackWhite c, const SgArrayList< 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 |
Go board optimized for Monte-Carlo.
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 40 of file GoUctBoard.h.
GoUctBoard::GoUctBoard | ( | const GoBoard & | bd | ) | [explicit] |
Definition at line 32 of file GoUctBoard.cpp.
GoUctBoard::~GoUctBoard | ( | ) |
Definition at line 39 of file GoUctBoard.cpp.
GoUctBoard::GoUctBoard | ( | const GoUctBoard & | ) | [private] |
Not implemented.
void GoUctBoard::AddLibToAdjBlocks | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 111 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 320 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 134 of file GoUctBoard.cpp.
References IsAdjacentTo(), IsColor(), IsEmpty(), m_block, GoUctBoard::Block::m_color, GoUctBoard::Block::m_liberties, GoUctBoard::Block::m_stones, SgArrayList< 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 514 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 553 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 559 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 564 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 569 of file GoUctBoard.h.
References NumLiberties().
Referenced by AdjacentBlocks(), CanCapture(), InAtari(), and NeighborBlocks().
const SgBoardConst & GoUctBoard::BoardConst | ( | ) | const |
Definition at line 589 of file GoUctBoard.h.
References m_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 670 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 574 of file GoUctBoard.h.
References m_capturedStones.
bool GoUctBoard::CapturingMove | ( | ) | const |
Whether the most recent move captured any stones.
Definition at line 579 of file GoUctBoard.h.
References SgArrayList< 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 43 of file GoUctBoard.cpp.
References CheckConsistencyBlock(), 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 75 of file GoUctBoard.cpp.
References GetColor(), IsBorder(), SgStack< T, SIZE >::IsEmpty(), SgArrayList< 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(), SgArrayList< T, SIZE >::PushBack(), SgArrayList< 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 150 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 584 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 594 of file GoUctBoard.h.
References m_secondLastMove.
SgBoardColor GoUctBoard::GetColor | ( | SgPoint | p | ) | const |
Definition at line 599 of file GoUctBoard.h.
References m_color.
Referenced by CheckConsistencyBlock(), IsSingleStone(), and IsSuicide().
SgPoint GoUctBoard::GetLastMove | ( | ) | const |
Return last move played.
Definition at line 604 of file GoUctBoard.h.
References m_lastMove.
SgBlackWhite GoUctBoard::GetStone | ( | SgPoint | p | ) | const |
Definition at line 609 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 615 of file GoUctBoard.h.
References IsColor(), SG_NS, and SG_WE.
Referenced by HasNeighborsOrDiags().
bool GoUctBoard::HasEmptyNeighbors | ( | SgPoint | p | ) | const |
Definition at line 623 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 633 of file GoUctBoard.h.
References m_nuNeighbors.
Referenced by HasNeighborsOrDiags().
bool GoUctBoard::HasNeighborsOrDiags | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Definition at line 638 of file GoUctBoard.h.
References HasDiagonals(), and HasNeighbors().
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 643 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 241 of file GoUctBoard.cpp.
References GoBoard::Anchor(), CheckConsistency(), GoBoard::Get2ndLastMove(), GoBoard::GetColor(), GoBoard::GetLastMove(), GoUctBoard::Block::InitNewBlock(), InitSize(), GoBoard::IsEmpty(), 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::NumEmptyNeighbors(), GoBoard::NumNeighbors(), GoBoard::NumPrisoners(), SgArrayList< 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 278 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 168 of file GoUctBoard.cpp.
References m_block, SG_NS, and SG_WE.
Referenced by AddStoneToBlock().
bool GoUctBoard::IsBorder | ( | SgPoint | p | ) | const |
Definition at line 697 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 703 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 710 of file GoUctBoard.h.
References m_color, SG_ASSERT, SG_EMPTY, and SG_PASS.
Referenced by AddStone(), AddStoneToBlock(), CreateSingleStoneBlock(), IsLegal(), IsLibertyOfBlock(), MergeBlocks(), NeighborBlocks(), and Play().
See GoBoard::IsInBlock.
Definition at line 649 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 733 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 716 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 656 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 738 of file GoUctBoard.h.
References GetColor(), NumNeighbors(), and Occupied().
bool GoUctBoard::IsSuicide | ( | SgPoint | p | ) | const |
Definition at line 743 of file GoUctBoard.h.
References IsSuicide(), and ToPlay().
bool GoUctBoard::IsSuicide | ( | SgPoint | p, | |
SgBlackWhite | toPlay | |||
) | const |
Definition at line 679 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 748 of file GoUctBoard.h.
References SgPointUtil::InBoardRange(), and IsBorder().
Referenced by NumLiberties(), and Play().
void GoUctBoard::KillBlock | ( | const Block * | block | ) | [private] |
Definition at line 393 of file GoUctBoard.cpp.
References AddLibToAdjBlocks(), SgArrayList< 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, SgArrayList< T, SIZE >::PushBack(), SG_EMPTY, SG_NS, SG_WE, and SgOppBW().
Referenced by RemoveLibAndKill().
int GoUctBoard::LastBoardPoint | ( | ) | const |
See SgBoardConst::FirstBoardPoint.
Definition at line 753 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 758 of file GoUctBoard.h.
References SgBoardConst::Left(), and m_const.
See SgBoardConst::Line.
Definition at line 763 of file GoUctBoard.h.
References SgBoardConst::Line(), and m_const.
void GoUctBoard::MergeBlocks | ( | SgPoint | p, | |
const SgArrayList< Block *, 4 > & | adjBlocks | |||
) | [private] |
Definition at line 177 of file GoUctBoard.cpp.
References SgMarker::Clear(), SgMarker::Include(), IsColor(), IsEmpty(), SgArrayList< T, SIZE >::Length(), m_block, m_color, GoUctBoard::Block::m_liberties, m_marker, GoUctBoard::Block::m_stones, SgMarker::NewMark(), NumNeighbors(), SgArrayList< T, SIZE >::PushBack(), SG_ASSERT, SG_NS, and SG_WE.
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 768 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 298 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 804 of file GoUctBoard.h.
References SgArrayList< T, SIZE >::Length(), and m_capturedStones.
Referenced by GoUctGlobalSearchState< POLICY >::ExecutePlayout().
int GoUctBoard::Num8EmptyNeighbors | ( | SgPoint | p | ) | const |
Includes diagonals.
Definition at line 799 of file GoUctBoard.h.
References NumEmptyDiagonals(), and NumEmptyNeighbors().
int GoUctBoard::Num8Neighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Includes diagonals.
Definition at line 794 of file GoUctBoard.h.
References NumDiagonals(), and NumNeighbors().
int GoUctBoard::NumDiagonals | ( | SgPoint | p, | |
SgBoardColor | c | |||
) | const |
Definition at line 809 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 823 of file GoUctBoard.h.
References NumDiagonals(), and SG_EMPTY.
Referenced by Num8EmptyNeighbors().
int GoUctBoard::NumEmptyNeighbors | ( | SgPoint | p | ) | const |
Definition at line 828 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 833 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 840 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 845 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 850 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 856 of file GoUctBoard.h.
References m_block.
Referenced by AdjacentBlocks(), Anchor(), AreInSameBlock(), CheckConsistencyBlock(), GoUctState::ExecutePlayout(), GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove(), 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 861 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 |
Opponent of player whose turn it is to play.
Definition at line 867 of file GoUctBoard.h.
void GoUctBoard::Play | ( | SgPoint | p | ) |
Play a move for the current player.
Definition at line 422 of file GoUctBoard.cpp.
References AddStone(), CheckConsistency(), SgArrayList< 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 872 of file GoUctBoard.h.
References m_const, and SgBoardConst::Pos().
void GoUctBoard::RemoveLibAndKill | ( | SgPoint | p, | |
SgBlackWhite | opp, | |||
SgArrayList< 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 340 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(), SgArrayList< 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 877 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 882 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 892 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 899 of file GoUctBoard.h.
References m_toPlay.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::ExecutePlayout(), GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove(), 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 904 of file GoUctBoard.h.
References m_const, and SgBoardConst::Up().
void GoUctBoard::UpdateBlocksAfterAddStone | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
const SgArrayList< Block *, 4 > & | adjBlocks | |||
) | [private] |
Definition at line 224 of file GoUctBoard.cpp.
References AddStoneToBlock(), CreateSingleStoneBlock(), IsColor(), SgArrayList< T, SIZE >::Length(), MergeBlocks(), and SG_ASSERT.
Referenced by Play().
friend class LibertyIterator [friend] |
Definition at line 386 of file GoUctBoard.h.
friend class StoneIterator [friend] |
Definition at line 387 of file GoUctBoard.h.
SgArray<Block*,SG_MAXPOINT> GoUctBoard::m_block [private] |
Definition at line 321 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] |
Definition at line 341 of file GoUctBoard.h.
Referenced by CreateSingleStoneBlock(), and Init().
GoPointList GoUctBoard::m_capturedStones [private] |
Definition at line 347 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 327 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 336 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] |
Definition at line 349 of file GoUctBoard.h.
Referenced by InitSize(), and IsBorder().
SgPoint GoUctBoard::m_koPoint [private] |
Point which is currently illegal for simple Ko rule.
Definition at line 316 of file GoUctBoard.h.
Referenced by Init(), IsLegal(), KillBlock(), and Play().
SgPoint GoUctBoard::m_lastMove [private] |
Definition at line 311 of file GoUctBoard.h.
Referenced by GetLastMove(), Init(), and Play().
SgMarker GoUctBoard::m_marker [mutable, private] |
Definition at line 343 of file GoUctBoard.h.
Referenced by AdjacentBlocks(), MergeBlocks(), NeighborBlocks(), and RemoveLibAndKill().
SgMarker GoUctBoard::m_marker2 [private] |
Definition at line 345 of file GoUctBoard.h.
Referenced by AddLibToAdjBlocks().
SgBWArray<SgArray<int,SG_MAXPOINT> > GoUctBoard::m_nuNeighbors [private] |
Number of black and white neighbors.
Definition at line 333 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 330 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 324 of file GoUctBoard.h.
Referenced by Init(), KillBlock(), and NumPrisoners().
SgPoint GoUctBoard::m_secondLastMove [private] |
Definition at line 313 of file GoUctBoard.h.
Referenced by Get2ndLastMove(), Init(), and Play().
SgGrid GoUctBoard::m_size [private] |
The current board size.
Definition at line 339 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 319 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 51 of file GoUctBoard.h.