Go board. More...
#include <GoBoard.h>
Classes | |
class | Block |
Data related to a block of stones on the board. More... | |
class | HashCode |
Board hash code. More... | |
class | Iterator |
Iterate through all points. More... | |
class | LibertyCopyIterator |
Iterate through all the liberties of a block. More... | |
class | LibertyIterator |
Iterate through all the liberties of a block. More... | |
struct | Snapshot |
struct | StackEntry |
Information to undo a move. More... | |
struct | State |
Data that can be restored quickly with TakeSnapshot/RestoreSnapshot. More... | |
class | StoneIterator |
Iterate through all the stones of a block. More... | |
Public Member Functions | |
GoBoard (int size=GO_DEFAULT_SIZE, const GoSetup &setup=GoSetup(), const GoRules &rules=GoRules()) | |
~GoBoard () | |
const SgBoardConst & | BoardConst () const |
uint64_t | CountPlay () const |
Number of calls to Play since creation of this board. | |
void | Init (int size, const GoSetup &setup=GoSetup()) |
Re-initializes the board with new size. | |
void | Init (int size, const GoRules &rules, const GoSetup &setup=GoSetup()) |
Re-initializes the board with new size and rules. | |
GoRules & | Rules () |
Non-const access to current game rules. | |
const GoRules & | Rules () const |
Current game rules. | |
SgGrid | Size () const |
Return the size of this board. | |
bool | StackOverflowLikely () const |
Check if sufficient space on internal stacks. | |
bool | IsFirst (SgPoint p) const |
Check if move at point would be the first move there. | |
bool | IsNewPosition () const |
Check if board is in a definitely new situation, with no possibility of repetition. | |
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. | |
void | SetToPlay (SgBlackWhite player) |
Set the current player. | |
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. | |
bool | LastMoveInfo (GoMoveInfoFlag flag) const |
Information about the most recent call to Play. | |
GoMoveInfo | GetLastMoveInfo () const |
void | AllowKoRepetition (bool allowKo) |
void | AllowAnyRepetition (bool allowAny) |
Make all repetition moves legal. | |
void | SetKoModifiesHash (bool modify) |
Enable modification of hash code by Ko moves. | |
bool | KoRepetitionAllowed () const |
bool | AnyRepetitionAllowed () const |
Are all repetition moves legal? | |
bool | KoModifiesHash () const |
void | Play (SgPoint p, SgBlackWhite player) |
Play a move. | |
void | Play (SgPoint p) |
Play a move for the current player. | |
void | Play (GoPlayerMove move) |
Play a move. | |
void | Undo () |
Undo the most recent move. | |
bool | CanUndo () const |
Whether there is any move to undo. | |
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. | |
const GoSetup & | Setup () const |
Setup information of the first position. | |
int | MoveNumber () const |
Return the current number moves. | |
GoPlayerMove | Move (int i) const |
Return move with a certain move number. | |
SgPoint | GetLastMove () const |
Return last move played. | |
SgPoint | Get2ndLastMove () const |
2nd Last move = last move by ToPlay(). | |
SgPoint | KoPoint () const |
Point which is currently illegal due to simple ko rule. | |
const SgHashCode & | GetHashCode () const |
Return hash code for this position. | |
SgHashCode | GetHashCodeInclToPlay () const |
Return hash code for this position, modified by whose turn it is to play. | |
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 the smallest point of the block at a point. | |
bool | IsInBlock (SgPoint p, SgPoint anchor) const |
Efficient combined test if point is occupied and belongs to a block. | |
bool | IsLibertyOfBlock (SgPoint p, SgPoint anchor) const |
Check if empty point is a liberty of block. | |
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'. | |
const SgBWArray< int > & | TotalNumStones () const |
Number of stones currently on the board. | |
int | TotalNumStones (SgBlackWhite color) const |
int | TotalNumEmpty () const |
Number of empty points currently on the board. | |
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. | |
SgEmptyBlackWhite | KoColor () const |
Player who has immediately retaken a ko. | |
int | KoLevel () const |
Number of times that KoColor has immediately retaken a ko. | |
SgEmptyBlackWhite | KoLoser () const |
Player who will lose any ko. | |
void | SetKoLoser (SgEmptyBlackWhite color) |
See KoLoser. | |
void | CheckConsistency () const |
Checks whether all the board data structures are in a consistent state. | |
void | TakeSnapshot () |
Remember current position for quickly undoing a sequence of moves. | |
void | RestoreSnapshot () |
Restore a snapshot. | |
Point sets | |
SgPointSet | Occupied () const |
const SgPointSet & | All (SgBlackWhite color) const |
const SgPointSet & | AllEmpty () const |
const SgPointSet & | AllPoints () const |
const SgPointSet & | Corners () const |
See SgBoardConst::Corners. | |
const SgPointSet & | Edges () const |
See SgBoardConst::Edges. | |
const SgPointSet & | Centers () const |
See SgBoardConst::Centers. | |
const SgPointSet & | SideExtensions () const |
See SgBoardConst::SideExtensions. | |
const SgPointSet & | LineSet (SgGrid line) const |
See SgBoardConst::LineSet. | |
Public Attributes | |
SgMarker | m_userMarker |
Marker that can be used in client code. | |
Static Public Attributes | |
static const int | MAX_KOLEVEL = 3 |
Maximum number of immediate ko recaptures for GoBoard::m_koColor. | |
Private Member Functions | |
GoBoard (const GoBoard &) | |
Not implemented. | |
GoBoard & | operator= (const GoBoard &) |
Not implemented. | |
bool | CheckKo (SgBlackWhite player) |
Check if move violates Ko rule. | |
void | AddLibToAdjBlocks (SgPoint p) |
void | AddLibToAdjBlocks (SgPoint p, SgBlackWhite c) |
void | AddStoneToBlock (SgPoint p, SgBlackWhite c, Block *block, StackEntry &entry) |
Block & | CreateNewBlock () |
void | CreateSingleStoneBlock (SgPoint p, SgBlackWhite c) |
SgArrayList< Block *, 4 > | GetAdjacentBlocks (SgPoint p) const |
SgArrayList< Block *, 4 > | GetAdjacentBlocks (SgPoint p, SgBlackWhite c) const |
void | InitBlock (GoBoard::Block &block, SgBlackWhite c, SgPoint anchor) |
bool | IsAdjacentTo (SgPoint p, const Block *block) const |
void | MergeBlocks (SgPoint p, SgBlackWhite c, const SgArrayList< Block *, 4 > &adjBlocks) |
void | RemoveLibAndKill (SgPoint p, SgBlackWhite opp, StackEntry &entry) |
Remove liberty from adjacent blocks and kill opponent blocks without liberties. | |
void | RemoveLibFromAdjBlocks (SgPoint p, SgBlackWhite c) |
void | RestoreKill (Block *block, SgBlackWhite c) |
void | UpdateBlocksAfterAddStone (SgPoint p, SgBlackWhite c, StackEntry &entry) |
void | UpdateBlocksAfterUndo (const StackEntry &entry) |
void | CheckConsistencyBlock (SgPoint p) const |
bool | FullBoardRepetition () const |
bool | CheckSuicide (SgPoint p, StackEntry &entry) |
Kill own block if no liberties. | |
void | AddStone (SgPoint p, SgBlackWhite c) |
void | RemoveStone (SgPoint p) |
void | KillBlock (const Block *block) |
bool | HasLiberties (SgPoint p) const |
void | RestoreState (const StackEntry &entry) |
Restore state. | |
void | SaveState (StackEntry &entry) |
Save state. | |
Static Private Member Functions | |
static bool | IsPass (SgPoint p) |
Check if point is a pass move or a coupon move, which is handled like a pass move. | |
Private Attributes | |
State | m_state |
std::auto_ptr< Snapshot > | m_snapshot |
uint64_t | m_countPlay |
See CountPlay. | |
SgBoardConst | m_const |
Data that's constant for this board size. | |
SgGrid | m_size |
The current board size. | |
GoRules | m_rules |
Rules for this board. | |
GoSetup | m_setup |
Setup stones in the root position. | |
GoMoveInfo | m_moveInfo |
SgArrayList< Block, GO_MAX_NUM_MOVES > * | m_blockList |
Block data (stored in a stack). | |
SgMarker | m_marker |
GoPointList | m_capturedStones |
bool | m_allowAnyRepetition |
Arbitrary repetition for both players. | |
bool | m_allowKoRepetition |
Allow take-back of ko repetition. | |
bool | m_koModifiesHash |
SgEmptyBlackWhite | m_koColor |
SgEmptyBlackWhite | m_koLoser |
m_koLoser can never become m_koColor. | |
SgArray< bool, SG_MAXPOINT > | m_isBorder |
SgArrayList< StackEntry, GO_MAX_NUM_MOVES > * | m_moves |
Friends | |
class | LibertyCopyIterator |
class | LibertyIterator |
class | StoneIterator |
Go board.
It maintains the state of each point when playing moves and taking them back. Setup stones are only supported in the initial position. It provides basic information about the board state, e.g. blocks and liberties. The actual storage representation and updating of stones and liberties is encapsulated, it can only be accessed with GoBoard::LibertyIterator, GoBoard::LibertyCopyIterator, and GoBoard::StoneIterator.
Boards are thread-safe (w.r.t. different instances) after construction (the constructor is not thread-safe, because it uses global variables via SgBoardConst).
Definition at line 93 of file GoBoard.h.
GoBoard::GoBoard | ( | int | size = GO_DEFAULT_SIZE , |
|
const GoSetup & | setup = GoSetup() , |
|||
const GoRules & | rules = GoRules() | |||
) | [explicit] |
Definition at line 40 of file GoBoard.cpp.
References GoInitCheck(), and Init().
GoBoard::~GoBoard | ( | ) |
Definition at line 51 of file GoBoard.cpp.
References m_blockList, and m_moves.
GoBoard::GoBoard | ( | const GoBoard & | ) | [private] |
Not implemented.
void GoBoard::AddLibToAdjBlocks | ( | SgPoint | p | ) | [private] |
Definition at line 161 of file GoBoard.cpp.
References GoBoard::Block::AppendLiberty(), GetAdjacentBlocks(), NumNeighbors(), SG_BLACK, and SG_WHITE.
Referenced by KillBlock(), and UpdateBlocksAfterUndo().
void GoBoard::AddLibToAdjBlocks | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 174 of file GoBoard.cpp.
References GoBoard::Block::AppendLiberty(), GetAdjacentBlocks(), and NumNeighbors().
void GoBoard::AddStone | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 630 of file GoBoard.cpp.
References SgPointSet::Exclude(), IsEmpty(), GoBoard::State::m_all, GoBoard::State::m_color, GoBoard::State::m_empty, GoBoard::State::m_nuNeighbors, GoBoard::State::m_nuNeighborsEmpty, m_state, SG_ASSERT, SG_ASSERT_BW, SG_NS, and SG_WE.
Referenced by Init(), Play(), and RestoreKill().
void GoBoard::AddStoneToBlock | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
Block * | block, | |||
StackEntry & | entry | |||
) | [private] |
Definition at line 187 of file GoBoard.cpp.
References GoBoard::Block::Anchor(), GoBoard::Block::AppendLiberty(), GoBoard::Block::AppendStone(), SgArrayList< T, SIZE >::Clear(), IsAdjacentTo(), IsColor(), IsEmpty(), GoBoard::State::m_block, GoBoard::StackEntry::m_newLibs, GoBoard::StackEntry::m_oldAnchor, m_state, SgArrayList< T, SIZE >::PushBack(), SG_ASSERT, SG_DEBUG_ONLY, SG_NS, SG_WE, and GoBoard::Block::UpdateAnchor().
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 GoBoard.cpp.
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().
Referenced by GoBoardUtil::AdjacentBlocks().
const SgPointSet & GoBoard::All | ( | SgBlackWhite | color | ) | const |
Definition at line 1135 of file GoBoard.h.
References GoBoard::State::m_all, and m_state.
Referenced by GoSafetyUtil::AddToSafe(), GoRegionBoard::All(), GoRegion::CheckConsistency(), GoBlock::CheckConsistency(), GoGtpEngine::CmdListStones(), GoBoardUtil::ExpandToBlocks(), GoSafetyUtil::ExtendedMightMakeLife(), GoSafetyUtil::FindDameAndUnsurroundablePoints(), GoInfluence::FindInfluence(), GoRegionUtil::Has2IPorEyes(), GoRegionUtil::Has2SureLiberties(), GoRegionUtil::IsSmallRegion(), GoSafetyUtil::IsTerritory(), GoSafetyUtil::MightMakeLife(), and GoGtpEngine::WriteBoardInfo().
const SgPointSet & GoBoard::AllEmpty | ( | ) | const |
Definition at line 1140 of file GoBoard.h.
References GoBoard::State::m_empty, and m_state.
Referenced by GoSafetyUtil::AddToSafe(), GoRegionBoard::AllEmpty(), GoChain::AllEmptyAreLiberties(), GoRegion::AllInsideLibs(), GoSafetyCommands::CmdDameStatic(), GoSafetyCommands::CmdGfx(), GoRegion::Find2ConnForAll(), GoRegion::Find2ConnForAllInterior(), GoRegionUtil::Has2SureLiberties(), GoBlock::Liberties(), GoRegion::ProtectedCuts(), GoRegion::Safe2Cuts(), GoEyeUtil::TestNakade(), and GoGtpEngine::WriteBoardInfo().
void GoBoard::AllowAnyRepetition | ( | bool | allowAny | ) |
Make all repetition moves legal.
Definition at line 1145 of file GoBoard.h.
References m_allowAnyRepetition.
Referenced by GoRestoreRepetitionAndSuicide::GoRestoreRepetitionAndSuicide(), and GoRestoreRepetitionAndSuicide::~GoRestoreRepetitionAndSuicide().
void GoBoard::AllowKoRepetition | ( | bool | allowKo | ) |
Definition at line 1150 of file GoBoard.h.
References m_allowKoRepetition.
Referenced by GoRestoreRepetitionAndSuicide::GoRestoreRepetitionAndSuicide(), and GoRestoreRepetitionAndSuicide::~GoRestoreRepetitionAndSuicide().
const SgPointSet & GoBoard::AllPoints | ( | ) | const |
Definition at line 1155 of file GoBoard.h.
References Size().
Referenced by GoRegionBoard::AllPoints(), GoSafetyCommands::CmdGfx(), GoTimeControl::GetPositionInfo(), and GoGtpEngine::WriteBoardInfo().
Return the smallest point of the block at a point.
Requires: Occupied(p)
Definition at line 1160 of file GoBoard.h.
References GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.
Referenced by GoBoardUtil::AddNeighborBlocksOfColor(), GoBlock::AddStone(), AdjacentBlocks(), GoBoardUtil::Approx2Libs(), AreInSameBlock(), GoBoardUtil::AtLeastTwoSharedLibs(), GoBoardUtil::BlocksAdjacentToPoints(), GoBoardUtil::CfgDistance(), GoBlock::CheckConsistency(), GoEyeUtil::CheckInterior(), GoGtpExtraCommands::CmdCfgDistance(), GoGtpEngine::CmdPointInfo(), GoRegionUtil::FindCurrentAnchors(), GoBoardUtil::GetDirtyRegion(), IsInBlock(), IsLibertyOfBlock(), GoEyeUtil::IsSimpleEye(), GoBoardUtil::IsSimpleEyeOfBlock(), GoRegionUtil::IsSingleBlock(), NeighborBlocks(), GoBlockIterator::operator bool(), GoSafetyUtil::ReduceToAnchors(), GoBoardUtil::ReduceToAnchors(), GoBlock::RemoveStone(), GoBoardUtil::SharedLiberties(), GoBoardUtil::SharedLibertyBlocks(), GoBoardUtil::Stones(), and GoRegionBoard::UpdateBlock().
bool GoBoard::AnyRepetitionAllowed | ( | ) | const |
Are all repetition moves legal?
Definition at line 1166 of file GoBoard.h.
References m_allowAnyRepetition.
Referenced by GoAssertBoardRestored::AssertRestored(), CheckKo(), GoAssertBoardRestored::Init(), and IsLegal().
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 1171 of file GoBoard.h.
References Anchor(), and Occupied().
Referenced by GoLadder::PlayHunterMove().
bool GoBoard::AtLeastNumLibs | ( | SgPoint | block, | |
int | n | |||
) | const |
Return whether block has at least n liberties.
Definition at line 1176 of file GoBoard.h.
References NumLiberties().
bool GoBoard::AtMostNumLibs | ( | SgPoint | block, | |
int | n | |||
) | const |
Return whether block has at most n liberties.
Definition at line 1181 of file GoBoard.h.
References NumLiberties().
Referenced by AdjacentBlocks(), CanCapture(), GoBoardUtil::HasAdjacentBlocks(), InAtari(), NeighborBlocks(), and GoBoardUtil::SharedLibertyBlocks().
const SgBoardConst & GoBoard::BoardConst | ( | ) | const |
bool GoBoard::CanCapture | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
bool GoBoard::CanUndo | ( | ) | const |
Whether there is any move to undo.
Definition at line 1186 of file GoBoard.h.
References SgArrayList< T, SIZE >::Length(), and m_moves.
Referenced by GoBoardUtil::UndoAll().
const GoPointList & GoBoard::CapturedStones | ( | ) | const |
The stones removed from the board by the most recent move.
Can be used for incremental update of other data structures. Includes captures and suicide stones. Only valid directly after a GoBoard::Play, otherwise undefined.
Definition at line 1191 of file GoBoard.h.
References m_capturedStones.
Referenced by GoBoardUtil::GetDirtyRegion(), and GoLadder::PlayPreyMove().
bool GoBoard::CapturingMove | ( | ) | const |
Whether the most recent move captured any stones.
Definition at line 1196 of file GoBoard.h.
References SgArrayList< T, SIZE >::IsEmpty(), and m_capturedStones.
Referenced by GoBoardUtil::GetDirtyRegion(), GoLadder::PlayHunterMove(), and GoLadder::PlayPreyMove().
const SgPointSet & GoBoard::Centers | ( | ) | const |
Definition at line 1201 of file GoBoard.h.
References SgBoardConst::Centers(), and m_const.
Referenced by InCenter(), and GoGtpEngine::WriteBoardInfo().
void GoBoard::CheckConsistency | ( | ) | const |
Checks whether all the board data structures are in a consistent state.
Definition at line 59 of file GoBoard.cpp.
References CheckConsistencyBlock(), IsBorder(), GoBoard::State::m_all, GoBoard::State::m_block, GoBoard::State::m_color, m_state, NumEmptyNeighbors(), NumNeighbors(), SG_ASSERT, SG_ASSERT_EBW, SG_BLACK, SG_EMPTY, SG_MAXPOINT, and SG_WHITE.
Referenced by Init(), Play(), RestoreSnapshot(), and Undo().
void GoBoard::CheckConsistencyBlock | ( | SgPoint | p | ) | const [private] |
Definition at line 102 of file GoBoard.cpp.
References GoBoard::Block::Anchor(), GoBoard::Block::Color(), SgArrayList< T, SIZE >::Contains(), GetColor(), IsBorder(), SgStack< T, SIZE >::IsEmpty(), SgArrayList< T, SIZE >::Length(), GoBoard::Block::Liberties(), GoBoard::State::m_block, m_state, SgMarker::NewMark(), NumStones(), Occupied(), SgStack< T, SIZE >::Pop(), SgStack< T, SIZE >::Push(), SgArrayList< T, SIZE >::PushBack(), SgArrayList< T, SIZE >::SameElements(), SG_ASSERT, SG_DEBUG_ONLY, SG_EMPTY, SG_NS, SG_WE, and GoBoard::Block::Stones().
Referenced by CheckConsistency().
bool GoBoard::CheckKo | ( | SgBlackWhite | player | ) | [private] |
Check if move violates Ko rule.
Sets isRepetition and updates m_koLevel, m_koColor and hash (if KoModifiesHash)
Definition at line 136 of file GoBoard.cpp.
References AnyRepetitionAllowed(), FullBoardRepetition(), GO_MOVEFLAG_REPETITION, KoRepetitionAllowed(), GoBoard::State::m_hash, m_koColor, GoBoard::State::m_koLevel, m_koLoser, m_koModifiesHash, m_moveInfo, m_state, MAX_KOLEVEL, SG_EMPTY, SgOppBW(), and GoBoard::HashCode::XorWinKo().
Referenced by Play().
bool GoBoard::CheckSuicide | ( | SgPoint | p, | |
StackEntry & | entry | |||
) | [private] |
Kill own block if no liberties.
Sets isSuicide flag.
Definition at line 739 of file GoBoard.cpp.
References GoRules::AllowSuicide(), GO_MOVEFLAG_SUICIDE, HasLiberties(), KillBlock(), GoBoard::State::m_block, m_moveInfo, m_rules, m_state, and GoBoard::StackEntry::m_suicide.
Referenced by Play().
const SgPointSet & GoBoard::Corners | ( | ) | const |
Definition at line 1206 of file GoBoard.h.
References SgBoardConst::Corners(), and m_const.
Referenced by InCorner(), and GoGtpEngine::WriteBoardInfo().
uint64_t GoBoard::CountPlay | ( | ) | const |
Number of calls to Play since creation of this board.
Definition at line 1211 of file GoBoard.h.
References m_countPlay.
Referenced by GoBoard::LibertyIterator::LibertyIterator(), GoBoard::LibertyIterator::operator*(), GoBoard::StoneIterator::operator*(), GoBoard::StoneIterator::StoneIterator(), and GoGtpEngine::WriteBoardInfo().
GoBoard::Block & GoBoard::CreateNewBlock | ( | ) | [private] |
Definition at line 220 of file GoBoard.cpp.
References SgArrayList< T, SIZE >::Last(), SgArrayList< T, SIZE >::Length(), m_blockList, and SgArrayList< T, SIZE >::Resize().
Referenced by CreateSingleStoneBlock(), Init(), and MergeBlocks().
void GoBoard::CreateSingleStoneBlock | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 228 of file GoBoard.cpp.
References GoBoard::Block::AppendLiberty(), CreateNewBlock(), GoBoard::Block::Init(), IsColor(), IsEmpty(), GoBoard::State::m_block, m_state, NumNeighbors(), SG_ASSERT, SG_NS, and SG_WE.
Referenced by UpdateBlocksAfterAddStone().
const SgPointSet & GoBoard::Edges | ( | ) | const |
See SgBoardConst::Edges.
Definition at line 1216 of file GoBoard.h.
References SgBoardConst::Edges(), and m_const.
Referenced by OnEdge(), and GoGtpEngine::WriteBoardInfo().
int GoBoard::FirstBoardPoint | ( | ) | const |
See SgBoardConst::FirstBoardPoint.
Definition at line 1221 of file GoBoard.h.
References SgBoardConst::FirstBoardPoint(), and m_const.
Referenced by GoBoardCheckPerformance::CheckPerformance().
bool GoBoard::FullBoardRepetition | ( | ) | const [private] |
Definition at line 688 of file GoBoard.cpp.
References GoBoard::Block::Color(), GetColor(), GoRules::GetKoRule(), IsPass(), SgArrayList< SgPoint, SG_MAX_ONBOARD+1 >::Iterator, SgArrayList< T, SIZE >::Length(), GoBoard::StackEntry::m_color, GoBoard::StackEntry::m_isFirst, GoBoard::StackEntry::m_killed, GoBoard::StackEntry::m_koPoint, m_moves, GoBoard::StackEntry::m_point, m_state, GoBoard::StackEntry::m_suicide, GoBoard::State::m_toPlay, GoBoard::StackEntry::m_toPlay, MoveNumber(), Rules(), SG_BLACK, SG_EMPTY, SG_WHITE, GoRules::SIMPLEKO, and GoBoard::Block::Stones().
Referenced by CheckKo().
SgPoint GoBoard::Get2ndLastMove | ( | ) | const |
2nd Last move = last move by ToPlay().
Conditions similar to GetLastMove().
Definition at line 1231 of file GoBoard.h.
References GoBoard::StackEntry::m_color, GoBoard::StackEntry::m_point, MoveNumber(), SG_NULLMOVE, SgOppBW(), and ToPlay().
SgArrayList< GoBoard::Block *, 4 > GoBoard::GetAdjacentBlocks | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const [private] |
Definition at line 267 of file GoBoard.cpp.
References SgArrayList< T, SIZE >::Contains(), IsColor(), GoBoard::State::m_block, m_state, NumNeighbors(), SgArrayList< T, SIZE >::PushBack(), SG_NS, and SG_WE.
SgArrayList< GoBoard::Block *, 4 > GoBoard::GetAdjacentBlocks | ( | SgPoint | p | ) | const [private] |
Definition at line 246 of file GoBoard.cpp.
References SgArrayList< T, SIZE >::Contains(), GoBoard::State::m_block, m_state, NumNeighbors(), SgArrayList< T, SIZE >::PushBack(), SG_BLACK, SG_NS, SG_WE, and SG_WHITE.
Referenced by AddLibToAdjBlocks(), RemoveLibAndKill(), RemoveLibFromAdjBlocks(), and UpdateBlocksAfterAddStone().
SgBoardColor GoBoard::GetColor | ( | SgPoint | p | ) | const |
Definition at line 1244 of file GoBoard.h.
References GoBoard::State::m_color, and m_state.
Referenced by CheckConsistencyBlock(), GoEyeUtil::CheckInterior(), GoGtpEngine::CmdPointInfo(), GoGtpExtraCommands::CmdStaticLadder(), GoEyeUtil::CountSinglePointEyes2(), GoSetupUtil::CurrentPosSetup(), GoGtpCommandUtil::EmptyPointArg(), FullBoardRepetition(), GoStaticLadder::IsEdgeLadder(), GoEyeUtil::IsPossibleEye(), GoEyeUtil::IsSimpleEye(), GoEyeUtil::IsSinglePointEye2(), IsSingleStone(), IsSuicide(), GoGtpCommandUtil::ParseMultiStoneArgument(), GoBoardUtil::ScorePosition(), GoGame::SetupPosition(), and GoGtpCommandUtil::StoneArg().
const SgHashCode & GoBoard::GetHashCode | ( | ) | const |
Return hash code for this position.
Definition at line 1249 of file GoBoard.h.
References GoBoard::HashCode::Get(), GoBoard::State::m_hash, and m_state.
Referenced by GoAssertBoardRestored::AssertRestored(), GoRegionBoard::ChainsUpToDate(), GoSafetySolver::GenBlocksRegions(), GoRegionBoard::GenBlocksRegions(), GoRegionBoard::GenChains(), GoAssertBoardRestored::Init(), GoLadderUtil::Ladder(), GoLadderUtil::LadderStatus(), GoBoard::LibertyCopyIterator::LibertyCopyIterator(), GoRegionBoard::OnExecutedUncodedMove(), GoRegionBoard::OnUndoneMove(), GoBoard::LibertyCopyIterator::operator*(), GoBoardSynchronizer::UpdateSubscriber(), GoSafetySolver::UpToDate(), GoRegionBoard::UpToDate(), and GoGtpEngine::WriteBoardInfo().
SgHashCode GoBoard::GetHashCodeInclToPlay | ( | ) | const |
Return hash code for this position, modified by whose turn it is to play.
Note that GetHashCode() != GetHashCodeInclToPlay(), regardless of whose turn it is to play.
Definition at line 1254 of file GoBoard.h.
References GoBoard::HashCode::GetInclToPlay(), GoBoard::State::m_hash, m_state, and ToPlay().
Referenced by GoAutoBookState::ComputeHashCode(), GoSearch::GetHashCode(), GoBook::InsertEntry(), GoBook::LookupEntry(), GoAutoBookState::Play(), and GoGtpEngine::WriteBoardInfo().
SgPoint GoBoard::GetLastMove | ( | ) | const |
Return last move played.
Definition at line 1259 of file GoBoard.h.
References GoBoard::StackEntry::m_color, GoBoard::StackEntry::m_point, MoveNumber(), SG_NULLMOVE, SgOppBW(), and ToPlay().
Referenced by GoBoardUtil::TrompTaylorPassWins().
GoMoveInfo GoBoard::GetLastMoveInfo | ( | ) | const |
Definition at line 1270 of file GoBoard.h.
References m_moveInfo.
Referenced by GoGtpEngine::CheckLegal().
SgBlackWhite GoBoard::GetStone | ( | SgPoint | p | ) | const |
Definition at line 1275 of file GoBoard.h.
References GoBoard::State::m_color, m_state, Occupied(), and SG_ASSERT.
Referenced by AdjacentBlocks(), GoBoardUtil::AdjacentStones(), GoRegionBoard::ChainAt(), GoBoardUtil::HasAdjacentBlocks(), GoBoardUtil::HasStonesOfBothColors(), GoBoardUtil::IsSimpleEyeOfBlock(), GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), GoLadder::Ladder(), GoLadderUtil::LadderStatus(), GoBoardUtil::RegionCode(), RemoveStone(), GoBoardUtil::SharedLibertyBlocks(), GoBoardUtil::TestForChain(), and GoLadderUtil::TryLadder().
bool GoBoard::HasDiagonals | ( | SgPoint | p, | |
SgBoardColor | c | |||
) | const |
Definition at line 1281 of file GoBoard.h.
References IsColor(), SG_NS, and SG_WE.
Referenced by HasNeighborsOrDiags(), and GoEyeUtil::IsSinglePointEye().
bool GoBoard::HasEmptyNeighbors | ( | SgPoint | p | ) | const |
Definition at line 1289 of file GoBoard.h.
References GoBoard::State::m_nuNeighborsEmpty, and m_state.
Referenced by GoEyeUtil::IsSimpleEye(), GoEyeUtil::IsSinglePointEye(), and IsSuicide().
bool GoBoard::HasLiberties | ( | SgPoint | p | ) | const [private] |
bool GoBoard::HasNeighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Definition at line 1299 of file GoBoard.h.
References GoBoard::State::m_nuNeighbors, and m_state.
Referenced by GoRegion::AllEmptyAreLibs(), HasNeighborsOrDiags(), GoRegion::InteriorEmpty(), GoEyeUtil::IsSimpleEye(), and GoEyeUtil::IsSinglePointEye().
bool GoBoard::HasNeighborsOrDiags | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Definition at line 1304 of file GoBoard.h.
References HasDiagonals(), and HasNeighbors().
bool GoBoard::InAtari | ( | SgPoint | p | ) | const |
Return whether the number of liberties of the block at 'p' is one.
Requires: Occupied(p)
Definition at line 1309 of file GoBoard.h.
References AtMostNumLibs(), Occupied(), and SG_ASSERT.
Referenced by GoGtpEngine::CmdPointInfo(), GoLadder::FilterAdjacent(), GoLadderUtil::IsProtectedLiberty(), GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), GoBoardUtil::MoveLegalAndNotAtari(), GoBoardUtil::MoveNotLegalOrAtari(), and GoLadder::PlayHunterMove().
bool GoBoard::InCenter | ( | SgPoint | p | ) | const |
Definition at line 1346 of file GoBoard.h.
References Centers().
Referenced by GoGtpEngine::CmdPointInfo().
bool GoBoard::InCorner | ( | SgPoint | p | ) | const |
Definition at line 1351 of file GoBoard.h.
References Corners().
Referenced by GoGtpEngine::CmdPointInfo().
Re-initializes the board with new size and rules.
Definition at line 421 of file GoBoard.cpp.
References AddStone(), SgBoardConst::ChangeSize(), CheckConsistency(), SgPointSet::Clear(), SgBWSet::Clear(), SgArrayList< T, SIZE >::Clear(), GoBoard::HashCode::Clear(), CreateNewBlock(), SgArray< T, SIZE >::Fill(), SgPointSet::Include(), InitBlock(), IsBorder(), IsEmpty(), IsValidPoint(), GoBoard::State::m_all, m_allowAnyRepetition, m_allowKoRepetition, GoBoard::State::m_block, m_blockList, GoBoard::State::m_color, m_const, m_countPlay, GoBoard::State::m_empty, GoBoard::State::m_hash, m_isBorder, GoBoard::State::m_isFirst, GoBoard::State::m_isNewPosition, m_koColor, GoBoard::State::m_koLevel, m_koLoser, m_koModifiesHash, GoBoard::State::m_koPoint, m_moves, GoBoard::State::m_numStones, GoBoard::State::m_nuNeighbors, GoBoard::State::m_nuNeighborsEmpty, GoSetup::m_player, GoBoard::State::m_prisoners, m_rules, m_setup, m_size, m_snapshot, m_state, GoSetup::m_stones, GoBoard::State::m_toPlay, SgPointUtil::Pt(), SG_ASSERT, SG_ASSERTRANGE, SG_BLACK, SG_BORDER, SG_EMPTY, SG_MAX_SIZE, SG_MAXPOINT, SG_MIN_SIZE, SG_NULLPOINT, SG_WHITE, and GoBoard::HashCode::XorStone().
Re-initializes the board with new size.
Keeps old GoRules.
Definition at line 1356 of file GoBoard.h.
References m_rules.
Referenced by GoBook::Entry::ApplyTo(), GoGtpEngine::CmdPlaceFreeHandicap(), GoBoard(), GoGame::Init(), GoBook::InsertEntry(), GoAutoBookState::Synchronize(), GoBoardUpdater::Update(), GoBoardSynchronizer::UpdateFromInit(), and GoBoardRestorer::~GoBoardRestorer().
void GoBoard::InitBlock | ( | GoBoard::Block & | block, | |
SgBlackWhite | c, | |||
SgPoint | anchor | |||
) | [private] |
Definition at line 500 of file GoBoard.cpp.
References SgMarker::Clear(), SgArrayList< T, SIZE >::Contains(), GoBoard::Block::Init(), SgStack< T, SIZE >::IsEmpty(), GoBoard::State::m_block, GoBoard::State::m_color, m_isBorder, m_marker, m_state, SgMarker::NewMark(), SgStack< T, SIZE >::Pop(), SgStack< T, SIZE >::Push(), SgArrayList< T, SIZE >::PushBack(), SG_ASSERT_BW, and SG_EMPTY.
Referenced by Init().
Definition at line 289 of file GoBoard.cpp.
References GoBoard::State::m_block, m_state, SG_NS, and SG_WE.
Referenced by AddStoneToBlock().
bool GoBoard::IsBorder | ( | SgPoint | p | ) | const |
Definition at line 1379 of file GoBoard.h.
References m_isBorder, SG_ASSERT, and SG_PASS.
Referenced by CheckConsistency(), CheckConsistencyBlock(), Init(), GoEyeUtil::IsSimpleEye(), GoBoardUtil::IsSimpleEyeOfBlock(), IsSuicide(), and IsValidPoint().
bool GoBoard::IsColor | ( | SgPoint | p, | |
int | c | |||
) | const |
Definition at line 1385 of file GoBoard.h.
References GoBoard::State::m_color, m_state, SG_ASSERT, SG_ASSERT_EBW, and SG_PASS.
Referenced by GoBoardUtil::AddNeighborBlocksOfColor(), AddStoneToBlock(), AdjacentBlocks(), GoBoardUtil::AdjacentStones(), GoBoardUtil::Approx2Libs(), GoLadder::BlockIsAdjToPrey(), GoBoardUtil::BlocksAdjacentToPoints(), CanCapture(), GoInfluence::ComputeInfluence(), CreateSingleStoneBlock(), GoBoardUtil::DiagonalsOfColor(), GoLadder::FilterAdjacent(), GetAdjacentBlocks(), GoBoardUtil::GetDirtyRegion(), GoBoardUtil::HasAdjacentBlocks(), HasDiagonals(), GoRegionBoard::IsColor(), GoRegion::IsInteriorBlock(), GoBoardUtil::IsSimpleEyeOfBlock(), GoRegionUtil::IsSingleBlock(), GoEyeUtil::IsSinglePointEye2(), GoLadder::Ladder(), MergeBlocks(), NeighborBlocks(), GoBoardUtil::NeighborsOfColor(), GoEyeUtil::NumberOfMoveToEye2(), NumDiagonals(), GoBoardUtil::SharedLibertyBlocks(), and UpdateBlocksAfterAddStone().
bool GoBoard::IsEmpty | ( | SgPoint | p | ) | const |
Definition at line 1392 of file GoBoard.h.
References GoBoard::State::m_color, m_state, SG_ASSERT, SG_EMPTY, and SG_PASS.
Referenced by AddStone(), AddStoneToBlock(), GoBlock::AllEmptyAreLiberties(), GoRegion::AllEmptyAreLibs(), GoBoardUtil::Approx2Libs(), GoEyeUtil::CheckInterior(), GoBoardCheckPerformance::CheckPerformance(), GoGtpExtraCommands::CmdCfgDistance(), CreateSingleStoneBlock(), Init(), GoRegion::InteriorEmpty(), GoStaticLadder::IsEdgeLadder(), IsFirst(), GoRegion::IsInteriorBlock(), IsLegal(), IsLibertyOfBlock(), GoEyeUtil::IsSinglePointEye(), GoEyeUtil::IsVitalPt(), GoBoardUtil::ManySecondaryLibs(), MergeBlocks(), NeighborBlocks(), GoEyeUtil::NumberOfMoveToEye(), Play(), GoBoardUtil::PlayIfLegal(), GoLadder::PlayPreyMove(), GoLadder::ReduceToBlocks(), GoRegionUtil::StaticIs1VitalAndConnected(), GoRegion::StaticIs1VitalAndConnected(), and GoEyeUtil::TestNakade().
bool GoBoard::IsFirst | ( | SgPoint | p | ) | const |
Check if move at point would be the first move there.
Definition at line 1398 of file GoBoard.h.
References IsEmpty(), GoBoard::State::m_isFirst, m_state, and SG_ASSERT.
Referenced by GoGtpEngine::CmdPointInfo(), IsLegal(), and Play().
Efficient combined test if point is occupied and belongs to a block.
Definition at line 1315 of file GoBoard.h.
References GoBoard::Block::Anchor(), Anchor(), GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.
bool GoBoard::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. LastMoveInfo is guaranteed to be vaild after this call. Suicide moves are only legal, if SetSelfRemovalAllowed(true) was called.
Definition at line 1404 of file GoBoard.h.
References AnyRepetitionAllowed(), CanCapture(), GO_MOVEFLAG_ILLEGAL, SgPointUtil::InBoardRange(), IsEmpty(), IsFirst(), IsNewPosition(), IsPass(), IsSuicide(), KoRepetitionAllowed(), LastMoveInfo(), GoBoard::State::m_koPoint, m_state, GoBoard::State::m_toPlay, Play(), Rules(), SG_ASSERT, SG_ASSERT_BW, GoRules::SIMPLEKO, and Undo().
Referenced by GoBook::Add(), GoBook::Entry::ApplyTo(), GoGtpEngine::CmdPointInfo(), GoAutoBook::ExportToOldFormat(), GoAutoBook::FindBestChild(), GoBoardUtil::GenerateIfLegal(), GoBook::InsertEntry(), IsLegal(), GoBook::LookupAllMoves(), GoBookCommands::PositionInfo(), GoEyeUtil::TestNakade(), and GoAutoBook::TruncateByDepth().
bool GoBoard::IsLegal | ( | int | p | ) | const |
Check if empty point is a liberty of block.
p | The point the check. | |
anchor | The anchor of the block. |
Definition at line 1323 of file GoBoard.h.
References Anchor(), GoBoard::Block::Color(), IsEmpty(), GoBoard::State::m_block, GoBoard::State::m_nuNeighbors, m_state, Occupied(), SG_ASSERT, SG_NS, and SG_WE.
Referenced by GoBlock::AllEmptyAreLiberties(), GoBoardUtil::AtLeastTwoSharedLibs(), GoBlock::HasLiberty(), and GoBoardUtil::SharedLiberties().
bool GoBoard::IsNewPosition | ( | ) | const |
bool GoBoard::IsPass | ( | SgPoint | p | ) | [static, private] |
Check if point is a pass move or a coupon move, which is handled like a pass move.
Definition at line 1446 of file GoBoard.h.
References SgMoveUtil::IsCouponMove(), and SG_PASS.
Referenced by FullBoardRepetition(), IsLegal(), Play(), RestoreState(), SaveState(), and UpdateBlocksAfterUndo().
bool GoBoard::IsSingleStone | ( | SgPoint | p | ) | const |
Return NumStones(p) == 1.
Definition at line 1451 of file GoBoard.h.
References GetColor(), NumNeighbors(), and Occupied().
Referenced by GoGtpEngine::CmdPointInfo(), GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), and GoBoardUtil::Stones().
bool GoBoard::IsSuicide | ( | SgPoint | p | ) | const |
Definition at line 1456 of file GoBoard.h.
References IsSuicide(), and ToPlay().
bool GoBoard::IsSuicide | ( | SgPoint | p, | |
SgBlackWhite | toPlay | |||
) | const |
Definition at line 1361 of file GoBoard.h.
References GetColor(), HasEmptyNeighbors(), IsBorder(), NumLiberties(), and SgOppBW().
Referenced by GoGtpEngine::CmdPointInfo(), IsLegal(), IsSuicide(), and GoBoardUtil::PlayIfLegal().
bool GoBoard::IsValidPoint | ( | SgPoint | p | ) | const |
Definition at line 1461 of file GoBoard.h.
References SgPointUtil::InBoardRange(), and IsBorder().
Referenced by GoBoardUtil::AdjacentStones(), Init(), GoBoardUtil::IsSnapback(), GoLadderUtil::Ladder(), GoLadderUtil::LadderStatus(), GoLadder::MarkStonesAsPrey(), NumLiberties(), Play(), GoGtpCommandUtil::PointArg(), and GoBoardUtil::Stones().
void GoBoard::KillBlock | ( | const Block * | block | ) | [private] |
Definition at line 666 of file GoBoard.cpp.
References AddLibToAdjBlocks(), GoBoard::Block::Anchor(), GoBoard::Block::Color(), SgArrayList< T, SIZE >::Length(), GoBoard::State::m_block, m_capturedStones, GoBoard::State::m_hash, GoBoard::State::m_koPoint, GoBoard::State::m_numStones, GoBoard::State::m_prisoners, m_state, SgArrayList< T, SIZE >::PushBack(), RemoveStone(), SgOppBW(), GoBoard::Block::Stones(), and GoBoard::HashCode::XorStone().
Referenced by CheckSuicide(), and RemoveLibAndKill().
SgEmptyBlackWhite GoBoard::KoColor | ( | ) | const |
Player who has immediately retaken a ko.
It is SG_EMPTY if no player has done it.
Definition at line 1466 of file GoBoard.h.
References m_koColor.
Referenced by GoAssertBoardRestored::AssertRestored(), GoAssertBoardRestored::Init(), and GoGtpEngine::WriteBoardInfo().
int GoBoard::KoLevel | ( | ) | const |
Number of times that KoColor has immediately retaken a ko.
Definition at line 1471 of file GoBoard.h.
References GoBoard::State::m_koLevel, and m_state.
Referenced by GoAssertBoardRestored::AssertRestored(), GoAssertBoardRestored::Init(), and SetKoLoser().
SgEmptyBlackWhite GoBoard::KoLoser | ( | ) | const |
Player who will lose any ko.
KoLoser is a player who is a priori determined to lose ko fights. therefore he is never allowed to become 'KoColor' If KoLoser is empty, no such prior bias is assumed.
Definition at line 1476 of file GoBoard.h.
References m_koLoser.
Referenced by GoAssertBoardRestored::AssertRestored(), and GoAssertBoardRestored::Init().
bool GoBoard::KoModifiesHash | ( | ) | const |
Definition at line 1481 of file GoBoard.h.
References m_koModifiesHash.
Referenced by GoAssertBoardRestored::AssertRestored(), and GoAssertBoardRestored::Init().
SgPoint GoBoard::KoPoint | ( | ) | const |
Point which is currently illegal due to simple ko rule.
Note that there could be more points illegal if superko rules are used.
Definition at line 1486 of file GoBoard.h.
References GoBoard::State::m_koPoint, and m_state.
bool GoBoard::KoRepetitionAllowed | ( | ) | const |
Definition at line 1491 of file GoBoard.h.
References m_allowKoRepetition.
Referenced by GoAssertBoardRestored::AssertRestored(), CheckKo(), GoAssertBoardRestored::Init(), and IsLegal().
int GoBoard::LastBoardPoint | ( | ) | const |
See SgBoardConst::FirstBoardPoint.
Definition at line 1496 of file GoBoard.h.
References SgBoardConst::LastBoardPoint(), and m_const.
Referenced by GoBoardCheckPerformance::CheckPerformance().
bool GoBoard::LastMoveInfo | ( | GoMoveInfoFlag | flag | ) | const |
Information about the most recent call to Play.
Guaranteed to be valid only directly after a call to Play.
Definition at line 1501 of file GoBoard.h.
References m_moveInfo.
Referenced by IsLegal(), GoLadderUtil::IsProtectedLiberty(), GoRegionBoard::OnExecutedUncodedMove(), and GoBoardUtil::PlayIfLegal().
int GoBoard::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 1506 of file GoBoard.h.
References SgBoardConst::Left(), and m_const.
See SgBoardConst::Line.
Definition at line 1511 of file GoBoard.h.
References SgBoardConst::Line(), and m_const.
Referenced by GoEyeUtil::CanBecomeSinglePointEye(), GoGtpEngine::CmdPointInfo(), GoStaticLadder::IsEdgeLadder(), GoEyeUtil::IsPossibleEye(), GoBoardUtil::IsSimpleEyeOfBlock(), GoEyeUtil::IsSinglePointEye(), GoEyeUtil::IsSinglePointEye2(), GoEyeUtil::NumberOfMoveToEye(), and GoEyeUtil::NumberOfMoveToEye2().
const SgPointSet & GoBoard::LineSet | ( | SgGrid | line | ) | const |
Definition at line 1516 of file GoBoard.h.
References SgBoardConst::LineSet(), and m_const.
Referenced by GoBoardUtil::Lines().
void GoBoard::MergeBlocks | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
const SgArrayList< Block *, 4 > & | adjBlocks | |||
) | [private] |
Definition at line 297 of file GoBoard.cpp.
References GoBoard::Block::Anchor(), GoBoard::Block::AppendLiberty(), GoBoard::Block::AppendStone(), SgMarker::Clear(), CreateNewBlock(), GoBoard::Block::Init(), IsColor(), IsEmpty(), GoBoard::Block::Liberties(), GoBoard::State::m_block, m_marker, m_state, SgMarker::NewMark(), NumNeighbors(), SG_ASSERT, SG_NS, SG_UNUSED(), SG_WE, GoBoard::Block::Stones(), and GoBoard::Block::UpdateAnchor().
Referenced by UpdateBlocksAfterAddStone().
GoPlayerMove GoBoard::Move | ( | int | i | ) | const |
Return move with a certain move number.
i | The move number (starting with 0). |
Definition at line 530 of file GoBoard.cpp.
References GoBoard::StackEntry::m_color, and GoBoard::StackEntry::m_point.
Referenced by GoBoardUtil::EndOfGame(), GoAutoBook::ExportToOldFormat(), GoBoardSynchronizer::FindNuCommon(), GoBoardRestorer::GoBoardRestorer(), GoBoardHistory::SetFromBoard(), GoAutoBookState::Synchronize(), GoBoardUtil::TwoPasses(), GoBoardSynchronizer::UpdateFromInit(), and GoBoardSynchronizer::UpdateIncremental().
int GoBoard::MoveNumber | ( | ) | const |
Return the current number moves.
Definition at line 1521 of file GoBoard.h.
References SgArrayList< T, SIZE >::Length(), and m_moves.
Referenced by GoAssertBoardRestored::AssertRestored(), GoLadder::CheckMoveOverflow(), GoGtpEngine::CmdKgsTimeSettings(), GoGtpEngine::CmdSetup(), GoBoardUtil::EndOfGame(), GoAutoBook::ExportToOldFormat(), GoBoardSynchronizer::FindNuCommon(), FullBoardRepetition(), Get2ndLastMove(), GetLastMove(), GoBoardRestorer::GoBoardRestorer(), GoAssertBoardRestored::Init(), GoLadder::InitMaxMoveNumber(), Play(), RestoreSnapshot(), GoBoardHistory::SetFromBoard(), StackOverflowLikely(), GoAutoBookState::Synchronize(), TakeSnapshot(), GoBoardUtil::TwoPasses(), GoBoardSynchronizer::UpdateFromInit(), GoBoardSynchronizer::UpdateIncremental(), and GoGtpEngine::WriteBoardInfo().
void GoBoard::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 582 of file GoBoard.cpp.
References Anchor(), SgMarker::Clear(), IsColor(), IsEmpty(), m_marker, SgMarker::NewMark(), NumNeighbors(), SG_ASSERT, SG_ENDPOINT, SG_NS, SG_UNUSED(), and SG_WE.
Referenced by GoNeighborBlockIterator::GoNeighborBlockIterator().
void GoBoard::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 604 of file GoBoard.cpp.
References Anchor(), AtMostNumLibs(), SgMarker::Clear(), IsColor(), IsEmpty(), m_marker, SgMarker::NewMark(), NumNeighbors(), SG_ASSERT, SG_ENDPOINT, SG_NS, SG_UNUSED(), and SG_WE.
int GoBoard::NuCapturedStones | ( | ) | const |
The stones captured by the most recent move.
Definition at line 1536 of file GoBoard.h.
References SgArrayList< T, SIZE >::Length(), and m_capturedStones.
int GoBoard::Num8EmptyNeighbors | ( | SgPoint | p | ) | const |
Includes diagonals.
Definition at line 1531 of file GoBoard.h.
References NumEmptyDiagonals(), and NumEmptyNeighbors().
Referenced by GoGtpEngine::CmdPointInfo(), GoEyeUtil::IsPossibleEye(), and GoEyeUtil::NumberOfMoveToEye().
int GoBoard::Num8Neighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Includes diagonals.
Definition at line 1526 of file GoBoard.h.
References NumDiagonals(), and NumNeighbors().
Referenced by GoEyeUtil::IsPossibleEye(), and GoEyeUtil::NumberOfMoveToEye().
int GoBoard::NumDiagonals | ( | SgPoint | p, | |
SgBoardColor | c | |||
) | const |
Definition at line 1541 of file GoBoard.h.
References IsColor(), SG_NS, and SG_WE.
Referenced by GoEyeUtil::IsPossibleEye(), GoEyeUtil::IsSinglePointEye(), Num8Neighbors(), and NumEmptyDiagonals().
int GoBoard::NumEmptyDiagonals | ( | SgPoint | p | ) | const |
Definition at line 1555 of file GoBoard.h.
References NumDiagonals(), and SG_EMPTY.
Referenced by GoEyeUtil::IsPossibleEye(), and Num8EmptyNeighbors().
int GoBoard::NumEmptyNeighbors | ( | SgPoint | p | ) | const |
Definition at line 1560 of file GoBoard.h.
References GoBoard::State::m_nuNeighborsEmpty, and m_state.
Referenced by CheckConsistency(), GoGtpEngine::CmdPointInfo(), GoLadder::HunterLadder(), GoRegion::IsCorridor(), GoStaticLadder::IsEdgeLadder(), GoEyeUtil::IsVitalPt(), and Num8EmptyNeighbors().
int GoBoard::NumLiberties | ( | SgPoint | p | ) | const |
Return the number of liberties of the block at 'p'.
Not defined for empty or border points.
Definition at line 1565 of file GoBoard.h.
References IsValidPoint(), GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.
Referenced by GoBoardUtil::Approx2Libs(), AtLeastNumLibs(), AtMostNumLibs(), GoEyeUtil::CheckInterior(), GoGtpEngine::CmdPointInfo(), GoBoardUtil::GetDirtyRegion(), HasLiberties(), GoStaticLadder::IsEdgeLadder(), GoLadderUtil::IsProtectedLiberty(), IsSuicide(), GoLadder::Ladder(), GoBlock::NuLiberties(), GoEyeUtil::NumberOfMoveToEye2(), Play(), and TheLiberty().
int GoBoard::NumNeighbors | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | const |
Definition at line 1572 of file GoBoard.h.
References GoBoard::State::m_nuNeighbors, and m_state.
Referenced by AddLibToAdjBlocks(), AdjacentBlocks(), GoBoardUtil::AdjacentStones(), GoBoardUtil::BlocksAdjacentToPoints(), CheckConsistency(), CreateSingleStoneBlock(), GetAdjacentBlocks(), GoRegion::IsCorridor(), GoStaticLadder::IsEdgeLadder(), GoEyeUtil::IsPossibleEye(), IsSingleStone(), GoEyeUtil::IsVitalPt(), MergeBlocks(), NeighborBlocks(), Num8Neighbors(), GoEyeUtil::NumberOfMoveToEye(), RemoveLibAndKill(), RemoveLibFromAdjBlocks(), GoBoardUtil::SharedLibertyBlocks(), and UpdateBlocksAfterAddStone().
int GoBoard::NumPrisoners | ( | SgBlackWhite | color | ) | const |
The total number of stones of 'color' that have been captured by the opponent throughout the game.
Definition at line 1577 of file GoBoard.h.
References GoBoard::State::m_prisoners, and m_state.
Referenced by GoBoardUtil::ScorePosition().
int GoBoard::NumStones | ( | SgPoint | p | ) | const |
Return the number of stones in the block at 'p'.
Not defined for empty or border points.
Definition at line 1582 of file GoBoard.h.
References GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.
Referenced by CheckConsistencyBlock(), GoGtpEngine::CmdPointInfo(), GoLadderUtil::IsProtectedLiberty(), and Play().
bool GoBoard::Occupied | ( | SgPoint | p | ) | const |
Check if point is occupied by a stone.
Can be called with border points.
Definition at line 1593 of file GoBoard.h.
References GoBoard::State::m_block, and m_state.
Referenced by GoBook::Add(), GoBoardUtil::AdjacentStones(), GoBoardUtil::AtLeastTwoSharedLibs(), GoBoardUtil::CfgDistance(), GoGtpEngine::CheckLegal(), GoGtpEngine::CmdAllMoveValues(), GoGtpEngine::CmdPointInfo(), GoEyeUtil::CountSinglePointEyes2(), GoSetupUtil::CurrentPosSetup(), GoBoardUtil::ExpandToBlocks(), GoBoardUtil::GetDirtyRegion(), GoTimeControl::GetPositionInfo(), GoBoardUtil::HasAdjacentBlocks(), GoBoardUtil::HasStonesOfBothColors(), GoBoardUtil::IsSnapback(), GoLadderUtil::Ladder(), GoLadder::Ladder(), GoLadderUtil::LadderStatus(), GoBoard::LibertyCopyIterator::LibertyCopyIterator(), GoBoard::LibertyIterator::LibertyIterator(), GoLadder::MarkStonesAsPrey(), GoBlockIterator::operator bool(), GoSafetyUtil::ReduceToAnchors(), GoBoardUtil::ReduceToAnchors(), GoLadder::ReduceToBlocks(), GoBoardUtil::RegionCode(), GoBoardUtil::ScorePosition(), GoBoardUtil::SharedLiberties(), GoBoard::StoneIterator::StoneIterator(), GoBoardUtil::Stones(), GoBoardUpdater::Update(), and GoGtpEngine::WriteBoardInfo().
SgPointSet GoBoard::Occupied | ( | ) | const |
Definition at line 1588 of file GoBoard.h.
References GoBoard::State::m_all, m_state, SG_BLACK, and SG_WHITE.
Referenced by AdjacentBlocks(), Anchor(), AreInSameBlock(), CheckConsistencyBlock(), GetStone(), InAtari(), IsInBlock(), IsLibertyOfBlock(), IsSingleStone(), NumLiberties(), NumStones(), and TheLiberty().
bool GoBoard::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 1598 of file GoBoard.h.
References GoBoard::State::m_block, m_state, and GoBoard::Block::NumLiberties().
bool GoBoard::OnEdge | ( | SgPoint | p | ) | const |
Definition at line 1604 of file GoBoard.h.
References Edges().
Referenced by GoGtpEngine::CmdPointInfo().
SgBlackWhite GoBoard::Opponent | ( | ) | const |
Opponent of player whose turn it is to play.
Definition at line 1609 of file GoBoard.h.
References m_state, GoBoard::State::m_toPlay, and SgOppBW().
void GoBoard::Play | ( | GoPlayerMove | move | ) |
Play a move.
Definition at line 1614 of file GoBoard.h.
References GoPlayerMove::Color(), Play(), and GoPlayerMove::Point().
void GoBoard::Play | ( | SgPoint | p, | |
SgBlackWhite | player | |||
) |
Play a move.
Move needs to be SG_PASS or on-board empty point. If move is not legal according to the current GoRules, the move flag isIllegal will be set. After playing the color to play ys the opposite color of the color of the move.
Definition at line 751 of file GoBoard.cpp.
References AddStone(), CheckConsistency(), CheckKo(), CheckSuicide(), SgArrayList< T, SIZE >::Clear(), GO_MOVEFLAG_CAPTURING, GO_MOVEFLAG_ILLEGAL, SgArrayList< T, SIZE >::IsEmpty(), IsEmpty(), IsFirst(), IsNewPosition(), IsPass(), IsValidPoint(), SgArrayList< T, SIZE >::Last(), SgArrayList< T, SIZE >::Length(), m_capturedStones, GoBoard::StackEntry::m_color, m_countPlay, GoBoard::State::m_hash, GoBoard::State::m_isFirst, GoBoard::State::m_isNewPosition, GoBoard::StackEntry::m_killed, m_koModifiesHash, GoBoard::State::m_koPoint, m_moveInfo, m_moves, GoBoard::State::m_numStones, GoBoard::StackEntry::m_point, m_state, GoBoard::StackEntry::m_suicide, GoBoard::State::m_toPlay, MoveNumber(), NumLiberties(), NumStones(), RemoveLibAndKill(), SgArrayList< T, SIZE >::Resize(), SaveState(), SG_ASSERT, SG_ASSERT_BW, SG_NULLMOVE, SG_NULLPOINT, SgOppBW(), UpdateBlocksAfterAddStone(), GoBoard::HashCode::XorCaptured(), and GoBoard::HashCode::XorStone().
Referenced by GoBoardUtil::AddWall(), GoBook::Entry::ApplyTo(), GoGtpEngine::CheckLegal(), GoGtpEngine::CmdPlaceFreeHandicap(), GoBoardSynchronizer::ExecuteSubscriber(), GoLadder::HunterLadder(), GoBook::InsertEntry(), IsLegal(), Play(), GoBoardUtil::PlayIfLegal(), GoBookCommands::PositionInfo(), GoAutoBookState::Synchronize(), GoBoardUpdater::Update(), and GoBoardRestorer::~GoBoardRestorer().
void GoBoard::Play | ( | SgPoint | p | ) |
Play a move for the current player.
See SgBoardConst::Pos.
Definition at line 1624 of file GoBoard.h.
References m_const, and SgBoardConst::Pos().
Referenced by GoGtpEngine::CmdPointInfo(), and GoEyeUtil::IsPossibleEye().
void GoBoard::RemoveLibAndKill | ( | SgPoint | p, | |
SgBlackWhite | opp, | |||
StackEntry & | entry | |||
) | [private] |
Remove liberty from adjacent blocks and kill opponent blocks without liberties.
Definition at line 825 of file GoBoard.cpp.
References SgArrayList< T, SIZE >::Clear(), GoBoard::Block::Color(), GoBoard::Block::ExcludeLiberty(), GetAdjacentBlocks(), KillBlock(), GoBoard::StackEntry::m_killed, GoBoard::Block::NumLiberties(), NumNeighbors(), SgArrayList< T, SIZE >::PushBack(), SG_BLACK, and SG_WHITE.
Referenced by Play().
void GoBoard::RemoveLibFromAdjBlocks | ( | SgPoint | p, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 332 of file GoBoard.cpp.
References GetAdjacentBlocks(), and NumNeighbors().
Referenced by RestoreKill().
void GoBoard::RemoveStone | ( | SgPoint | p | ) | [private] |
Definition at line 648 of file GoBoard.cpp.
References GetStone(), SgPointSet::Include(), GoBoard::State::m_all, GoBoard::State::m_color, GoBoard::State::m_empty, GoBoard::State::m_nuNeighbors, GoBoard::State::m_nuNeighborsEmpty, m_state, SG_ASSERT_BW, SG_EMPTY, SG_NS, and SG_WE.
Referenced by KillBlock(), and UpdateBlocksAfterUndo().
void GoBoard::RestoreKill | ( | Block * | block, | |
SgBlackWhite | c | |||
) | [private] |
Definition at line 341 of file GoBoard.cpp.
References AddStone(), SgArrayList< T, SIZE >::Length(), GoBoard::State::m_block, GoBoard::State::m_numStones, GoBoard::State::m_prisoners, m_state, RemoveLibFromAdjBlocks(), SG_ASSERT, SgOppBW(), and GoBoard::Block::Stones().
Referenced by UpdateBlocksAfterUndo().
void GoBoard::RestoreSnapshot | ( | ) |
Restore a snapshot.
Can only be called, if previously TakeSnapshot() was called and the current position is a followup position of the snapshot position. RestoreSnapshot() can used multiple times for the same snapshot.
Definition at line 889 of file GoBoard.cpp.
References CheckConsistency(), GoBoard::State::m_block, m_blockList, m_moves, m_snapshot, m_state, MoveNumber(), SgArrayList< T, SIZE >::Resize(), and SG_ASSERT.
void GoBoard::RestoreState | ( | const StackEntry & | entry | ) | [private] |
Restore state.
Definition at line 844 of file GoBoard.cpp.
References IsPass(), GoBoard::StackEntry::m_hash, GoBoard::State::m_hash, GoBoard::StackEntry::m_isFirst, GoBoard::State::m_isFirst, GoBoard::StackEntry::m_isNewPosition, GoBoard::State::m_isNewPosition, GoBoard::StackEntry::m_koColor, m_koColor, GoBoard::StackEntry::m_koLevel, GoBoard::State::m_koLevel, GoBoard::StackEntry::m_koLoser, m_koLoser, GoBoard::StackEntry::m_koModifiesHash, m_koModifiesHash, GoBoard::StackEntry::m_koPoint, GoBoard::State::m_koPoint, GoBoard::StackEntry::m_point, m_state, GoBoard::StackEntry::m_toPlay, and GoBoard::State::m_toPlay.
Referenced by Undo().
int GoBoard::Right | ( | SgPoint | p | ) | const |
Returns the offset along right side of the board.
Definition at line 1629 of file GoBoard.h.
References m_const, and SgBoardConst::Right().
GoRules & GoBoard::Rules | ( | ) |
Non-const access to current game rules.
The game rules are attached to a GoBoard for convenient access by the players only. The players and the class GoBoard should not assume that they are immutable; they can be changed from the outside using this function at anytime.
Definition at line 1634 of file GoBoard.h.
References m_rules.
Referenced by GoAssertBoardRestored::AssertRestored(), GoGtpEngine::CheckLegal(), GoGtpEngine::CmdFinalScore(), GoGtpEngine::CmdGenMoveCleanup(), GoGtpEngine::CmdGetKomi(), GoGtpEngine::CmdParamRules(), GoBoardUtil::EndOfGame(), FullBoardRepetition(), GoSafetyUtil::GetWinner(), GoRestoreRepetitionAndSuicide::GoRestoreRepetitionAndSuicide(), GoRestoreSuicide::GoRestoreSuicide(), GoGame::Init(), GoAssertBoardRestored::Init(), IsLegal(), GoGame::PlaceHandicap(), GoBoardUtil::PlayIfLegal(), GoBoardUtil::RemainingChineseHandicap(), GoBoardUtil::ScorePosition(), GoBoardHistory::SetFromBoard(), GoGame::SetKomiGlobal(), GoGame::SetRulesGlobal(), GoBoardUtil::TrompTaylorPassWins(), GoBoardSynchronizer::UpdateSubscriber(), GoRestoreKoRule::~GoRestoreKoRule(), GoRestoreRepetitionAndSuicide::~GoRestoreRepetitionAndSuicide(), and GoRestoreSuicide::~GoRestoreSuicide().
const GoRules & GoBoard::Rules | ( | ) | const |
void GoBoard::SaveState | ( | StackEntry & | entry | ) | [private] |
Save state.
entry | The stack entry to save information to; must already have a valid m_type field. |
Definition at line 860 of file GoBoard.cpp.
References IsPass(), GoBoard::State::m_hash, GoBoard::StackEntry::m_hash, GoBoard::State::m_isFirst, GoBoard::StackEntry::m_isFirst, GoBoard::State::m_isNewPosition, GoBoard::StackEntry::m_isNewPosition, m_koColor, GoBoard::StackEntry::m_koColor, GoBoard::State::m_koLevel, GoBoard::StackEntry::m_koLevel, m_koLoser, GoBoard::StackEntry::m_koLoser, m_koModifiesHash, GoBoard::StackEntry::m_koModifiesHash, GoBoard::State::m_koPoint, GoBoard::StackEntry::m_koPoint, GoBoard::StackEntry::m_point, m_state, GoBoard::State::m_toPlay, and GoBoard::StackEntry::m_toPlay.
Referenced by Play().
void GoBoard::SetKoLoser | ( | SgEmptyBlackWhite | color | ) |
void GoBoard::SetKoModifiesHash | ( | bool | modify | ) |
Enable modification of hash code by Ko moves.
Can be used if Ko repetition is allowed.
Definition at line 1650 of file GoBoard.h.
References m_koModifiesHash.
void GoBoard::SetToPlay | ( | SgBlackWhite | player | ) |
Set the current player.
Definition at line 1655 of file GoBoard.h.
References m_state, GoBoard::State::m_toPlay, and SG_ASSERT_BW.
Referenced by GoGame::GoToNode(), GoLadderUtil::IsProtectedLiberty(), GoSearch::SetToPlay(), GoGame::SetToPlay(), GoBoardUtil::TestForChain(), GoBoardUpdater::Update(), GoBoardSynchronizer::UpdateToPlay(), and GoRestoreToPlay::~GoRestoreToPlay().
const GoSetup & GoBoard::Setup | ( | ) | const |
Setup information of the first position.
Definition at line 1661 of file GoBoard.h.
References m_setup.
Referenced by GoBoardUtil::DumpBoard(), GoBoardHistory::SetFromBoard(), GoBoardSynchronizer::UpdateFromInit(), and GoBoardSynchronizer::UpdateSubscriber().
int GoBoard::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 1666 of file GoBoard.h.
References m_const, and SgBoardConst::Side().
const SgPointSet & GoBoard::SideExtensions | ( | ) | const |
See SgBoardConst::SideExtensions.
Definition at line 1671 of file GoBoard.h.
References m_const, and SgBoardConst::SideExtensions().
Referenced by GoGtpEngine::WriteBoardInfo().
SgGrid GoBoard::Size | ( | ) | const |
Return the size of this board.
Definition at line 1676 of file GoBoard.h.
References m_size.
Referenced by GoBook::Add(), GoSafetyUtil::AddToSafe(), GoRegion::AllInsideLibs(), AllPoints(), GoBook::Entry::ApplyTo(), GoAssertBoardRestored::AssertRestored(), GoRegion::CheckConsistency(), GoRegionBoard::Clear(), GoGtpExtraCommands::CmdCfgDistance(), GoGtpEngine::CmdFixedHandicap(), GoGtpEngine::CmdListStones(), GoGtpEngine::CmdPlaceFreeHandicap(), GoGtpEngine::CmdPointNumbers(), GoBook::Delete(), GoRegion::Dep(), GoBoardUtil::DumpBoard(), GoBoardUtil::ExpandToBlocks(), GoAutoBook::ExportToOldFormat(), GoSafetyUtil::ExtendedIsTerritory(), GoSafetyUtil::ExtendedMightMakeLife(), GoRegion::Find2ConnForAllInterior(), GoRegion::FindBlocks(), GoRegion::FindChains(), GoSafetyUtil::FindDameAndUnsurroundablePoints(), GoInfluence::FindInfluence(), GoRegionBoard::GetBlock(), GoBoardUtil::GetCoordString(), GoRegionUtil::Has2SureLiberties(), GoAssertBoardRestored::Init(), GoGame::InitHandicap(), GoBook::InsertEntry(), GoStaticLadder::IsEdgeLadder(), GoRegionUtil::IsSingleBlock(), GoRegionUtil::IsSmallRegion(), GoRegion::IsSurrounded(), GoSafetyUtil::IsTerritory(), GoBlock::Liberties(), GoBoardUtil::Lines(), GoBook::LookupEntry(), GoRegionBoard::MergeAdjacentAndAddBlock(), GoSafetyUtil::MightMakeLife(), operator<<(), GoRegion::ProtectedCuts(), GoRegionBoard::RemoveBlock(), GoGtpCommandUtil::RespondNumberArray(), GoRegion::Safe2Cuts(), GoRegion::SetBlocks(), GoBoardHistory::SetFromBoard(), GoAutoBookState::Synchronize(), GoEyeUtil::TestNakade(), TotalNumEmpty(), GoBoardUpdater::Update(), GoRegionBoard::UpdateBlock(), GoBoardSynchronizer::UpdateFromInit(), GoBoardSynchronizer::UpdateSubscriber(), GoRegionBoard::UpToDate(), GoSafetyUtil::WriteStatistics(), and GoBoardRestorer::~GoBoardRestorer().
bool GoBoard::StackOverflowLikely | ( | ) | const |
Check if sufficient space on internal stacks.
Should be checked before executing a move. If the internal stacks overflow, assertions will (hopefully) trigger in debug mode, but undefined behaviour occurs in release mode.
Definition at line 538 of file GoBoard.cpp.
References GO_MAX_NUM_MOVES, and MoveNumber().
void GoBoard::TakeSnapshot | ( | ) |
Remember current position for quickly undoing a sequence of moves.
Note that for short sequences of moves this can take longer than incrementally restoring the state by multiple calls to Undo().
Definition at line 876 of file GoBoard.cpp.
References SgArrayList< T, SIZE >::Length(), GoBoard::State::m_block, m_blockList, m_snapshot, m_state, and MoveNumber().
Return the liberty of 'blockInAtari' which must have exactly one liberty.
Definition at line 1681 of file GoBoard.h.
References GoBoard::State::m_block, m_state, NumLiberties(), Occupied(), and SG_ASSERT.
Referenced by GoStaticLadder::IsEdgeLadder(), GoLadderUtil::IsProtectedLiberty(), and GoBoardUtil::IsSnapback().
SgBlackWhite GoBoard::ToPlay | ( | ) | const |
Player whose turn it is to play.
Definition at line 1688 of file GoBoard.h.
References m_state, and GoBoard::State::m_toPlay.
Referenced by GoAssertBoardRestored::AssertRestored(), GoGtpEngine::BoardChanged(), GoSetupUtil::CurrentPosSetup(), GoBoardUtil::EndOfGame(), GoSearch::Execute(), Get2ndLastMove(), GetHashCodeInclToPlay(), GetLastMove(), GoTimeControl::GetPositionInfo(), GoSearch::GetToPlay(), GoGame::GoToNode(), GoAssertBoardRestored::Init(), IsLegal(), GoLadderUtil::IsProtectedLiberty(), IsSuicide(), Play(), GoBoardUtil::PlayIfLegal(), GoBoardHistory::SetFromBoard(), GoGame::SetToPlay(), GoBoardUtil::TrompTaylorPassWins(), GoBoardUtil::TwoPasses(), GoBoardSynchronizer::UpdateToPlay(), and GoGtpEngine::WriteBoardInfo().
int GoBoard::TotalNumEmpty | ( | ) | const |
Number of empty points currently on the board.
Definition at line 1693 of file GoBoard.h.
References GoBoard::State::m_numStones, m_state, SG_BLACK, SG_WHITE, and Size().
Referenced by GoTimeControl::GetPositionInfo(), GoRegionUtil::IsSingleBlock(), and GoGtpEngine::WriteBoardInfo().
const SgBWArray< int > & GoBoard::TotalNumStones | ( | ) | const |
Number of stones currently on the board.
Definition at line 1699 of file GoBoard.h.
References GoBoard::State::m_numStones, and m_state.
Referenced by GoAssertBoardRestored::AssertRestored(), GoAssertBoardRestored::Init(), GoBoardUtil::RemainingChineseHandicap(), and GoGtpEngine::WriteBoardInfo().
int GoBoard::TotalNumStones | ( | SgBlackWhite | color | ) | const |
Definition at line 1704 of file GoBoard.h.
References GoBoard::State::m_numStones, and m_state.
void GoBoard::Undo | ( | ) |
Undo the most recent move.
Definition at line 813 of file GoBoard.cpp.
References CheckConsistency(), SgArrayList< T, SIZE >::Last(), m_moves, SgArrayList< T, SIZE >::PopBack(), RestoreState(), and UpdateBlocksAfterUndo().
Referenced by GoGtpEngine::CheckLegal(), GoLadder::HunterLadder(), IsLegal(), GoLadderUtil::IsProtectedLiberty(), GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), GoLadder::Ladder(), GoLadder::PlayHunterMove(), GoBoardUtil::PlayIfLegal(), GoLadder::PlayPreyMove(), GoBookCommands::PositionInfo(), GoSearch::TakeBack(), GoBoardUtil::UndoAll(), GoMoveExecutor::UndoMove(), GoBoardSynchronizer::UpdateIncremental(), and GoMoveExecutor::~GoMoveExecutor().
int GoBoard::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 1709 of file GoBoard.h.
References m_const, and SgBoardConst::Up().
void GoBoard::UpdateBlocksAfterAddStone | ( | SgPoint | p, | |
SgBlackWhite | c, | |||
StackEntry & | entry | |||
) | [private] |
Definition at line 357 of file GoBoard.cpp.
References AddStoneToBlock(), SgArrayList< T, SIZE >::Clear(), CreateSingleStoneBlock(), GetAdjacentBlocks(), IsColor(), SgArrayList< T, SIZE >::Length(), GoBoard::StackEntry::m_merged, GoBoard::StackEntry::m_stoneAddedTo, MergeBlocks(), NumNeighbors(), and SG_ASSERT.
Referenced by Play().
void GoBoard::UpdateBlocksAfterUndo | ( | const StackEntry & | entry | ) | [private] |
Definition at line 386 of file GoBoard.cpp.
References AddLibToAdjBlocks(), GoBoard::Block::ExcludeLiberty(), IsPass(), GoBoard::State::m_block, m_blockList, GoBoard::StackEntry::m_color, GoBoard::StackEntry::m_killed, GoBoard::StackEntry::m_merged, GoBoard::StackEntry::m_newLibs, GoBoard::State::m_numStones, GoBoard::StackEntry::m_oldAnchor, GoBoard::StackEntry::m_point, m_state, GoBoard::StackEntry::m_stoneAddedTo, GoBoard::StackEntry::m_suicide, SgArrayList< T, SIZE >::PopBack(), GoBoard::Block::PopStone(), RemoveStone(), RestoreKill(), GoBoard::Block::SetAnchor(), SgOppBW(), and GoBoard::Block::Stones().
Referenced by Undo().
friend class LibertyCopyIterator [friend] |
friend class LibertyIterator [friend] |
friend class StoneIterator [friend] |
bool GoBoard::m_allowAnyRepetition [private] |
Arbitrary repetition for both players.
Definition at line 780 of file GoBoard.h.
Referenced by AllowAnyRepetition(), AnyRepetitionAllowed(), and Init().
bool GoBoard::m_allowKoRepetition [private] |
Allow take-back of ko repetition.
Definition at line 783 of file GoBoard.h.
Referenced by AllowKoRepetition(), Init(), and KoRepetitionAllowed().
SgArrayList<Block,GO_MAX_NUM_MOVES>* GoBoard::m_blockList [private] |
Block data (stored in a stack).
Maximum number: A move can create zero or one new block.
Definition at line 769 of file GoBoard.h.
Referenced by CreateNewBlock(), Init(), RestoreSnapshot(), TakeSnapshot(), UpdateBlocksAfterUndo(), and ~GoBoard().
GoPointList GoBoard::m_capturedStones [private] |
Definition at line 777 of file GoBoard.h.
Referenced by CapturedStones(), CapturingMove(), KillBlock(), NuCapturedStones(), and Play().
SgBoardConst GoBoard::m_const [private] |
Data that's constant for this board size.
Definition at line 753 of file GoBoard.h.
Referenced by BoardConst(), Centers(), Corners(), Edges(), FirstBoardPoint(), Init(), LastBoardPoint(), Left(), Line(), LineSet(), Pos(), Right(), Side(), SideExtensions(), and Up().
uint64_t GoBoard::m_countPlay [private] |
See CountPlay.
Definition at line 750 of file GoBoard.h.
Referenced by CountPlay(), Init(), and Play().
SgArray<bool,SG_MAXPOINT> GoBoard::m_isBorder [private] |
Definition at line 792 of file GoBoard.h.
Referenced by Init(), InitBlock(), and IsBorder().
SgEmptyBlackWhite GoBoard::m_koColor [private] |
Definition at line 787 of file GoBoard.h.
Referenced by CheckKo(), Init(), KoColor(), RestoreState(), and SaveState().
SgEmptyBlackWhite GoBoard::m_koLoser [private] |
m_koLoser can never become m_koColor.
Definition at line 790 of file GoBoard.h.
Referenced by CheckKo(), Init(), KoLoser(), RestoreState(), SaveState(), and SetKoLoser().
bool GoBoard::m_koModifiesHash [private] |
Definition at line 785 of file GoBoard.h.
Referenced by CheckKo(), Init(), KoModifiesHash(), Play(), RestoreState(), SaveState(), and SetKoModifiesHash().
SgMarker GoBoard::m_marker [mutable, private] |
Definition at line 775 of file GoBoard.h.
Referenced by AdjacentBlocks(), InitBlock(), MergeBlocks(), and NeighborBlocks().
GoMoveInfo GoBoard::m_moveInfo [private] |
Definition at line 765 of file GoBoard.h.
Referenced by CheckKo(), CheckSuicide(), GetLastMoveInfo(), LastMoveInfo(), and Play().
SgArrayList<StackEntry,GO_MAX_NUM_MOVES>* GoBoard::m_moves [private] |
Definition at line 794 of file GoBoard.h.
Referenced by CanUndo(), FullBoardRepetition(), Init(), MoveNumber(), Play(), RestoreSnapshot(), Undo(), and ~GoBoard().
GoRules GoBoard::m_rules [private] |
Rules for this board.
Can be modified anytime with GoBoard::Rules()
Definition at line 760 of file GoBoard.h.
Referenced by CheckSuicide(), Init(), and Rules().
GoSetup GoBoard::m_setup [private] |
SgGrid GoBoard::m_size [private] |
std::auto_ptr<Snapshot> GoBoard::m_snapshot [private] |
Definition at line 747 of file GoBoard.h.
Referenced by Init(), RestoreSnapshot(), and TakeSnapshot().
State GoBoard::m_state [private] |
Definition at line 745 of file GoBoard.h.
Referenced by AddStone(), AddStoneToBlock(), All(), AllEmpty(), Anchor(), CheckConsistency(), CheckConsistencyBlock(), CheckKo(), CheckSuicide(), CreateSingleStoneBlock(), FullBoardRepetition(), GetAdjacentBlocks(), GetColor(), GetHashCode(), GetHashCodeInclToPlay(), GetStone(), HasEmptyNeighbors(), HasNeighbors(), Init(), InitBlock(), IsAdjacentTo(), IsColor(), IsEmpty(), IsFirst(), IsInBlock(), IsLegal(), IsLibertyOfBlock(), IsNewPosition(), KillBlock(), KoLevel(), KoPoint(), MergeBlocks(), NumEmptyNeighbors(), NumLiberties(), NumNeighbors(), NumPrisoners(), NumStones(), Occupied(), OccupiedInAtari(), Opponent(), Play(), RemoveStone(), RestoreKill(), RestoreSnapshot(), RestoreState(), SaveState(), SetToPlay(), TakeSnapshot(), TheLiberty(), ToPlay(), TotalNumEmpty(), TotalNumStones(), and UpdateBlocksAfterUndo().
SgMarker GoBoard::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 109 of file GoBoard.h.
Referenced by GoBoardUtil::AdjacentStones(), GoBoardUtil::BlocksAdjacentToPoints(), and GoBoardUtil::SharedLibertyBlocks().
const int GoBoard::MAX_KOLEVEL = 3 [static] |
Maximum number of immediate ko recaptures for GoBoard::m_koColor.
Enforced only if ko modifies hash
Definition at line 99 of file GoBoard.h.
Referenced by CheckKo(), and GoBoard::HashCode::XorWinKo().