Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoBoard Class Reference

#include <GoBoard.h>

List of all members.


Detailed Description

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).

See also:

Definition at line 98 of file GoBoard.h.

Public Member Functions

 GoBoard (int size=GO_DEFAULT_SIZE, const GoSetup &setup=GoSetup(), const GoRules &rules=GoRules())
 ~GoBoard ()
const SgBoardConstBoardConst () 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.
GoRulesRules ()
 Non-const access to current game rules.
const GoRulesRules () 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 GoPointListCapturedStones () 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 GoSetupSetup () 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 SgHashCodeGetHashCode () 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 SgPointSetAll (SgBlackWhite color) const
const SgPointSetAllEmpty () const
const SgPointSetAllPoints () const
const SgPointSetCorners () const
 See SgBoardConst::Corners.
const SgPointSetEdges () const
 See SgBoardConst::Edges.
const SgPointSetCenters () const
 See SgBoardConst::Centers.
const SgPointSetSideExtensions () const
 See SgBoardConst::SideExtensions.
const SgPointSetLineSet (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.
GoBoardoperator= (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)
BlockCreateNewBlock ()
void CreateSingleStoneBlock (SgPoint p, SgBlackWhite c)
SgSList< Block *, 4 > GetAdjacentBlocks (SgPoint p) const
SgSList< 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 SgSList< 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 AddStoneForUndo (SgPoint p, SgBlackWhite c)
void RemoveStoneForUndo (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< Snapshotm_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
SgSList< 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_MAXPOINTm_isBorder
SgSList< StackEntry, GO_MAX_NUM_MOVES > * m_moves

Friends

class LibertyCopyIterator
class LibertyIterator
class StoneIterator

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...


Constructor & Destructor Documentation

GoBoard::GoBoard ( int  size = GO_DEFAULT_SIZE,
const GoSetup setup = GoSetup(),
const GoRules rules = GoRules() 
) [explicit]

Definition at line 42 of file GoBoard.cpp.

References GoInitCheck(), and Init().

GoBoard::~GoBoard (  ) 

Definition at line 53 of file GoBoard.cpp.

References m_blockList, and m_moves.

GoBoard::GoBoard ( const GoBoard  )  [private]

Not implemented.


Member Function Documentation

void GoBoard::AddLibToAdjBlocks ( SgPoint  p,
SgBlackWhite  c 
) [private]

Definition at line 176 of file GoBoard.cpp.

References GetAdjacentBlocks(), and NumNeighbors().

void GoBoard::AddLibToAdjBlocks ( SgPoint  p  )  [private]

Definition at line 163 of file GoBoard.cpp.

References GetAdjacentBlocks(), NumNeighbors(), SG_BLACK, and SG_WHITE.

Referenced by KillBlock(), and UpdateBlocksAfterUndo().

void GoBoard::AddStone ( SgPoint  p,
SgBlackWhite  c 
) [private]

Definition at line 632 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 AddStoneForUndo(), and RestoreKill().

void GoBoard::AddStoneForUndo ( SgPoint  p,
SgBlackWhite  c 
) [private]

Definition at line 668 of file GoBoard.cpp.

References AddStone(), GoBoard::State::m_hash, GoBoard::State::m_isFirst, GoBoard::State::m_isNewPosition, m_state, SG_ASSERT_BOARDRANGE, SG_ASSERT_BW, and GoBoard::HashCode::XorStone().

Referenced by Play().

void GoBoard::AddStoneToBlock ( SgPoint  p,
SgBlackWhite  c,
Block block,
StackEntry entry 
) [private]

Definition at line 189 of file GoBoard.cpp.

References GoBoard::Block::Anchor(), GoBoard::Block::AppendLiberty(), GoBoard::Block::AppendStone(), IsAdjacentTo(), IsColor(), IsEmpty(), GoBoard::State::m_block, GoBoard::StackEntry::m_newLibs, GoBoard::StackEntry::m_oldAnchor, m_state, SG_ASSERT, SG_DEBUG_ONLY, SG_NS, SG_WE, and GoBoard::Block::UpdateAnchor().

Referenced by UpdateBlocksAfterAddStone().

int GoBoard::AdjacentBlocks ( SgPoint  p,
int  maxLib,
SgPoint  anchors[],
int  maxAnchors 
) const

Get adjacent opponent blocks with a maximum number of liberties for a given block.

Not defined for empty points.

Parameters:
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)
Returns:
Number of anchors (without the END_POINT)

Definition at line 545 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 1202 of file GoBoard.h.

References GoBoard::State::m_all, and m_state.

Referenced by GoRegionBoard::All(), AlmostFilledByLivingShape(), AlmostFilledByNakade(), BulkyFiveNakade(), GoRegion::CheckConsistency(), GoBlock::CheckConsistency(), GoGtpEngine::CmdListStones(), ContainsLivingShape(), GoBoardUtil::ExpandToBlocks(), GoSafetyUtil::ExtendedMightMakeLife(), Find2ConnectionsForAll(), GoSafetyUtil::FindDameAndUnsurroundablePoints(), GoInfluence::FindInfluence(), GoRegionUtil::Has2IPorEyes(), GoRegionUtil::Has2SureLiberties(), GoRegionUtil::IsSmallRegion(), GoSafetyUtil::IsTerritory(), GoSafetyUtil::MightMakeLife(), Special2x3Cases(), TwoDiagonalStonesInBulkyFour(), TwoSeparateEyes(), and GoGtpEngine::WriteBoardInfo().

const SgPointSet & GoBoard::AllEmpty (  )  const

Definition at line 1207 of file GoBoard.h.

References GoBoard::State::m_empty, and m_state.

Referenced by GoSafetyUtil::AddToSafe(), GoRegionBoard::AllEmpty(), GoChain::AllEmptyAreLiberties(), GoRegion::AllInsideLibs(), AlmostFilledByLivingShape(), AlmostFilledByNakade(), BulkyFiveNakade(), GoSafetyCommands::CmdDameStatic(), GoSafetyCommands::CmdGfx(), Find2ConnectionsForAll(), GoRegion::Find2ConnForAll(), GoRegion::Find2ConnForAllInterior(), GoRegionUtil::Has2SureLiberties(), GoBlock::Liberties(), GoRegion::Safe2Cuts(), GoEyeUtil::TestNakade(), TwoDiagonalStonesInBulkyFour(), TwoSeparateEyes(), and GoGtpEngine::WriteBoardInfo().

void GoBoard::AllowAnyRepetition ( bool  allowAny  ) 

Make all repetition moves legal.

See also:
Handling of Ko Moves in Class GoBoard

Definition at line 1212 of file GoBoard.h.

References m_allowAnyRepetition.

Referenced by GoRestoreRepetitionAndSuicide::GoRestoreRepetitionAndSuicide(), and GoRestoreRepetitionAndSuicide::~GoRestoreRepetitionAndSuicide().

void GoBoard::AllowKoRepetition ( bool  allowKo  ) 

Definition at line 1217 of file GoBoard.h.

References m_allowKoRepetition.

Referenced by GoRestoreRepetitionAndSuicide::GoRestoreRepetitionAndSuicide(), and GoRestoreRepetitionAndSuicide::~GoRestoreRepetitionAndSuicide().

const SgPointSet & GoBoard::AllPoints (  )  const

Definition at line 1222 of file GoBoard.h.

References SgPointSet::AllPoints(), and Size().

Referenced by GoRegionBoard::AllPoints(), GoSafetyCommands::CmdGfx(), GoTimeControl::GetPositionInfo(), and GoGtpEngine::WriteBoardInfo().

SgPoint GoBoard::Anchor ( SgPoint  p  )  const

Return the smallest point of the block at a point.

Requires: Occupied(p)

Definition at line 1227 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(), CfgDistanceCheck(), GoBlock::CheckConsistency(), GoEyeUtil::CheckInterior(), GoGtpExtraCommands::CmdCfgDistance(), GoRegionUtil::FindCurrentAnchors(), GoBoardUtil::GetDirtyRegion(), IsInBlock(), IsLibertyOfBlock(), GoEyeUtil::IsSimpleEye(), GoBoardUtil::IsSimpleEyeOfBlock(), GoRegionUtil::IsSingleBlock(), NeighborBlocks(), GoBlockIterator::operator bool(), GoSafetyUtil::ReduceToAnchors(), GoBoardUtil::ReduceToAnchors(), GoBlock::RemoveStone(), GoBoardUtil::SharedLiberties(), and GoRegionBoard::UpdateBlock().

bool GoBoard::AnyRepetitionAllowed (  )  const

Are all repetition moves legal?

See also:
Handling of Ko Moves in Class GoBoard

Definition at line 1233 of file GoBoard.h.

References m_allowAnyRepetition.

Referenced by GoAssertBoardRestored::AssertRestored(), CheckKo(), GoAssertBoardRestored::Init(), and IsLegal().

bool GoBoard::AreInSameBlock ( SgPoint  stone1,
SgPoint  stone2 
) const

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 1238 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 1243 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 1248 of file GoBoard.h.

References NumLiberties().

Referenced by AdjacentBlocks(), CanCapture(), InAtari(), and NeighborBlocks().

const SgBoardConst & GoBoard::BoardConst (  )  const

Definition at line 1293 of file GoBoard.h.

References m_const.

bool GoBoard::CanCapture ( SgPoint  p,
SgBlackWhite  c 
) const

Return whether playing colour c at p can capture anything, ignoring any possible repetition.

Definition at line 1404 of file GoBoard.h.

References AtMostNumLibs(), IsColor(), and SgOppBW().

Referenced by IsLegal().

bool GoBoard::CanUndo (  )  const

Whether there is any move to undo.

Definition at line 1253 of file GoBoard.h.

References 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 1258 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 1263 of file GoBoard.h.

References SgSList< T, SIZE >::IsEmpty(), and m_capturedStones.

Referenced by GoBoardUtil::GetDirtyRegion(), GoLadder::PlayHunterMove(), and GoLadder::PlayPreyMove().

const SgPointSet & GoBoard::Centers (  )  const

See SgBoardConst::Centers.

Definition at line 1268 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 61 of file GoBoard.cpp.

References CheckConsistencyBlock(), CONSISTENCY, 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 Play(), RestoreSnapshot(), and Undo().

void GoBoard::CheckConsistencyBlock ( SgPoint  p  )  const [private]

Definition at line 104 of file GoBoard.cpp.

References GoBoard::Block::Anchor(), GoBoard::Block::Color(), SgSList< T, SIZE >::Contains(), GetColor(), IsBorder(), SgStack< T, SIZE >::IsEmpty(), SgSList< T, SIZE >::Length(), GoBoard::Block::Liberties(), GoBoard::State::m_block, m_state, SgMarker::NewMark(), NumStones(), Occupied(), SgStack< T, SIZE >::Pop(), SgStack< T, SIZE >::Push(), SgSList< T, SIZE >::PushBack(), SgSList< 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)

Returns:
false if isRepetition

Definition at line 138 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.

Returns:
false if move was suicide and suicide not allowed by current rules

Definition at line 759 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

See SgBoardConst::Corners.

Definition at line 1273 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 1278 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 222 of file GoBoard.cpp.

References m_blockList.

Referenced by CreateSingleStoneBlock(), and MergeBlocks().

void GoBoard::CreateSingleStoneBlock ( SgPoint  p,
SgBlackWhite  c 
) [private]

Definition at line 230 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 1283 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 1288 of file GoBoard.h.

References SgBoardConst::FirstBoardPoint(), and m_const.

Referenced by GoBoardCheckPerformance::CheckPerformance().

bool GoBoard::FullBoardRepetition (  )  const [private]

Definition at line 708 of file GoBoard.cpp.

References GoBoard::Block::Color(), GetColor(), GoRules::GetKoRule(), IsPass(), SgSList< T, SIZE >::Iterator, 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, GoBoard::Block::Stones(), GoRules::SUPERKO, and UpdateChanges().

Referenced by CheckKo().

SgPoint GoBoard::Get2ndLastMove (  )  const

2nd Last move = last move by ToPlay().

Conditions similar to GetLastMove().

Definition at line 1298 of file GoBoard.h.

References GoBoard::StackEntry::m_color, GoBoard::StackEntry::m_point, MoveNumber(), SG_NULLMOVE, SgOppBW(), and ToPlay().

SgSList< GoBoard::Block *, 4 > GoBoard::GetAdjacentBlocks ( SgPoint  p,
SgBlackWhite  c 
) const [private]

Definition at line 269 of file GoBoard.cpp.

References SgSList< T, SIZE >::Contains(), IsColor(), GoBoard::State::m_block, m_state, NumNeighbors(), SgSList< T, SIZE >::PushBack(), SG_NS, and SG_WE.

SgSList< GoBoard::Block *, 4 > GoBoard::GetAdjacentBlocks ( SgPoint  p  )  const [private]

Definition at line 248 of file GoBoard.cpp.

References SgSList< T, SIZE >::Contains(), GoBoard::State::m_block, m_state, NumNeighbors(), SgSList< 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 1311 of file GoBoard.h.

References GoBoard::State::m_color, and m_state.

Referenced by CheckConsistencyBlock(), GoEyeUtil::CheckInterior(), GoGtpEngine::CmdPointInfo(), GoGtpEngine::CmdSetup(), GoGtpExtraCommands::CmdStaticLadder(), GoEyeUtil::CountSinglePointEyes2(), GoGtpCommandUtil::EmptyPointArg(), FullBoardRepetition(), GoStaticLadder::IsEdgeLadder(), GoEyeUtil::IsPossibleEye(), GoEyeUtil::IsSimpleEye(), GoEyeUtil::IsSinglePointEye2(), IsSingleStone(), IsSuicide(), GoGtpCommandUtil::ParseMultiStoneArgument(), ScorePositionRecurse(), and GoGtpCommandUtil::StoneArg().

const SgHashCode & GoBoard::GetHashCode (  )  const

Return hash code for this position.

Warning:
Hash code for empty positions is always 0, independent of the board size.

Definition at line 1316 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 1321 of file GoBoard.h.

References GoBoard::HashCode::GetInclToPlay(), GoBoard::State::m_hash, m_state, and ToPlay().

Referenced by GoAutoBookState::ComputeHashCode(), GoSearch::GetHashCode(), GoBook::LookupEntry(), GoAutoBookState::Play(), and GoGtpEngine::WriteBoardInfo().

SgPoint GoBoard::GetLastMove (  )  const

Return last move played.

Returns:
The last move played or SG_NULLMOVE, if
  • No move was played yet
  • The last move was not by the opposite color of the current player

Definition at line 1326 of file GoBoard.h.

References GoBoard::StackEntry::m_color, GoBoard::StackEntry::m_point, MoveNumber(), SG_NULLMOVE, SgOppBW(), and ToPlay().

Referenced by GoBoardUtil::PassWins().

GoMoveInfo GoBoard::GetLastMoveInfo (  )  const

Definition at line 1337 of file GoBoard.h.

References m_moveInfo.

Referenced by GoGtpEngine::CheckLegal().

SgBlackWhite GoBoard::GetStone ( SgPoint  p  )  const

Definition at line 1342 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(), RemoveStoneForUndo(), GoBoardUtil::TestForChain(), and GoLadderUtil::TryLadder().

bool GoBoard::HasDiagonals ( SgPoint  p,
SgBoardColor  c 
) const

Definition at line 1348 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 1356 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]

Definition at line 1361 of file GoBoard.h.

References NumLiberties().

Referenced by CheckSuicide().

bool GoBoard::HasNeighbors ( SgPoint  p,
SgBlackWhite  c 
) const

Definition at line 1366 of file GoBoard.h.

References GoBoard::State::m_nuNeighbors, and m_state.

Referenced by GoRegion::AllEmptyAreLibs(), HasNeighborsOrDiags(), GoRegion::InteriorEmpty(), GoEyeUtil::IsSimpleEye(), GoEyeUtil::IsSinglePointEye(), and Special2x3Cases().

bool GoBoard::HasNeighborsOrDiags ( SgPoint  p,
SgBlackWhite  c 
) const

Definition at line 1371 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 1376 of file GoBoard.h.

References AtMostNumLibs(), Occupied(), and SG_ASSERT.

Referenced by GoLadder::FilterAdjacent(), GoLadderUtil::IsProtectedLiberty(), GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), GoBoardUtil::MoveLegalAndNotAtari(), GoBoardUtil::MoveNotLegalOrAtari(), and GoLadder::PlayHunterMove().

bool GoBoard::InCenter ( SgPoint  p  )  const

Definition at line 1413 of file GoBoard.h.

References Centers().

Referenced by GoGtpEngine::CmdPointInfo().

bool GoBoard::InCorner ( SgPoint  p  )  const

Definition at line 1418 of file GoBoard.h.

References Corners().

Referenced by GoGtpEngine::CmdPointInfo().

void GoBoard::Init ( int  size,
const GoRules rules,
const GoSetup setup = GoSetup() 
)

Re-initializes the board with new size and rules.

Definition at line 423 of file GoBoard.cpp.

References SgBoardConst::ChangeSize(), SgPointSet::Clear(), SgBWSet::Clear(), GoBoard::HashCode::Clear(), SgArray< T, SIZE >::Fill(), SgPointSet::Include(), IsBorder(), IsEmpty(), GoBoard::State::m_all, m_allowAnyRepetition, m_allowKoRepetition, 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, GoBoard::State::m_prisoners, m_rules, m_size, m_state, SgPointUtil::Pt(), SG_ASSERTRANGE, SG_BLACK, SG_BORDER, SG_EMPTY, SG_MAX_SIZE, SG_MAXPOINT, SG_MIN_SIZE, SG_NULLPOINT, and SG_WHITE.

void GoBoard::Init ( int  size,
const GoSetup setup = GoSetup() 
)

Re-initializes the board with new size.

Keeps old GoRules.

Definition at line 1423 of file GoBoard.h.

References m_rules.

Referenced by GoBook::Entry::ApplyTo(), GoGtpEngine::CmdPlaceFreeHandicap(), GoBoard(), GoBook::InsertEntry(), GoGameRecord::OnInitBoard(), GoBoardUpdater::Update(), GoBoardSynchronizer::UpdateFromInit(), and GoBoardRestorer::~GoBoardRestorer().

void GoBoard::InitBlock ( GoBoard::Block block,
SgBlackWhite  c,
SgPoint  anchor 
) [private]

Definition at line 502 of file GoBoard.cpp.

References SgMarker::Clear(), SgSList< 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(), SgSList< T, SIZE >::PushBack(), SG_ASSERT_BW, and SG_EMPTY.

bool GoBoard::IsAdjacentTo ( SgPoint  p,
const Block block 
) const [private]

Definition at line 291 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 1446 of file GoBoard.h.

References m_isBorder, SG_ASSERT, and SG_PASS.

Referenced by CfgDistanceCheck(), CheckConsistency(), CheckConsistencyBlock(), Init(), GoEyeUtil::IsSimpleEye(), GoBoardUtil::IsSimpleEyeOfBlock(), IsSuicide(), IsValidPoint(), and ScorePositionRecurse().

bool GoBoard::IsColor ( SgPoint  p,
int  c 
) const

Definition at line 1452 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::Approx2Libs(), GoLadder::BlockIsAdjToPrey(), GoBoardUtil::BlocksAdjacentToPoints(), CanCapture(), CreateSingleStoneBlock(), GoBoardUtil::DiagonalsOfColor(), GoLadder::FilterAdjacent(), GetAdjacentBlocks(), GoBoardUtil::GetDirtyRegion(), HasDiagonals(), GoRegionBoard::IsColor(), GoRegion::IsInteriorBlock(), GoBoardUtil::IsSimpleEyeOfBlock(), GoRegionUtil::IsSingleBlock(), GoEyeUtil::IsSinglePointEye2(), GoLadder::Ladder(), MergeBlocks(), NeighborBlocks(), GoBoardUtil::NeighborsOfColor(), GoEyeUtil::NumberOfMoveToEye2(), NumDiagonals(), and UpdateBlocksAfterAddStone().

bool GoBoard::IsEmpty ( SgPoint  p  )  const

Definition at line 1459 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(), MergeBlocks(), NeighborBlocks(), GoEyeUtil::NumberOfMoveToEye(), Play(), GoBoardUtil::PlayIfLegal(), GoLadder::PlayPreyMove(), GoLadder::ReduceToBlocks(), GoRegionUtil::StaticIs1VitalAndConnected(), GoRegion::StaticIs1VitalAndConnected(), GoEyeUtil::TestNakade(), and TwoDiagonalStonesInBulkyFour().

bool GoBoard::IsFirst ( SgPoint  p  )  const

Check if move at point would be the first move there.

Definition at line 1465 of file GoBoard.h.

References IsEmpty(), GoBoard::State::m_isFirst, m_state, and SG_ASSERT.

Referenced by GoGtpEngine::CmdPointInfo(), IsLegal(), and Play().

bool GoBoard::IsInBlock ( SgPoint  p,
SgPoint  anchor 
) const

Efficient combined test if point is occupied and belongs to a block.

Returns:
true, if point is occupied and belongs to the block with the given anchor.

Definition at line 1382 of file GoBoard.h.

References GoBoard::Block::Anchor(), Anchor(), GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.

bool GoBoard::IsLegal ( int  p  )  const

Check whether the move at 'p' is legal for color to play.

See also:
IsLegal(int, SgBlackWhite).

Definition at line 1506 of file GoBoard.h.

References IsLegal(), and ToPlay().

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 1471 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(), GoGame::CanPlayHumanMove(), GoGtpEngine::CmdPointInfo(), GoAutoBook::FindBestChild(), GoBoardUtil::GenerateIfLegal(), IsLegal(), GoBook::LookupAllMoves(), and GoEyeUtil::TestNakade().

bool GoBoard::IsLibertyOfBlock ( SgPoint  p,
SgPoint  anchor 
) const

Check if empty point is a liberty of block.

Parameters:
p The point the check.
anchor The anchor of the block.
Returns:
true If point is liberty of block.

Definition at line 1390 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(), GoBlock::HasLiberty(), and IsAdjacentToAll().

bool GoBoard::IsNewPosition (  )  const

Check if board is in a definitely new situation, with no possibility of repetition.

Definition at line 1501 of file GoBoard.h.

References GoBoard::State::m_isNewPosition, and m_state.

Referenced by IsLegal(), and Play().

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 1514 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 1519 of file GoBoard.h.

References GetColor(), NumNeighbors(), and Occupied().

Referenced by GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), and GoBoardUtil::Stones().

bool GoBoard::IsSuicide ( SgPoint  p  )  const

Definition at line 1524 of file GoBoard.h.

References IsSuicide(), and ToPlay().

bool GoBoard::IsSuicide ( SgPoint  p,
SgBlackWhite  toPlay 
) const

Definition at line 1428 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 1529 of file GoBoard.h.

References SgPointUtil::InBoardRange(), and IsBorder().

Referenced by GoBoardUtil::AdjacentStones(), GoBoardUtil::IsSnapback(), GoLadderUtil::Ladder(), GoLadderUtil::LadderStatus(), GoLadder::MarkStonesAsPrey(), NumLiberties(), Play(), GoGtpCommandUtil::PointArg(), Spread(), and GoBoardUtil::Stones().

void GoBoard::KillBlock ( const Block block  )  [private]

Definition at line 687 of file GoBoard.cpp.

References AddLibToAdjBlocks(), GoBoard::Block::Anchor(), GoBoard::Block::Color(), SgSList< T, SIZE >::Length(), GoBoard::State::m_block, m_capturedStones, GoBoard::State::m_koPoint, GoBoard::State::m_numStones, GoBoard::State::m_prisoners, m_state, SgSList< T, SIZE >::PushBack(), RemoveStoneForUndo(), SgOppBW(), and GoBoard::Block::Stones().

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 1534 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 1539 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 1544 of file GoBoard.h.

References m_koLoser.

Referenced by GoAssertBoardRestored::AssertRestored(), and GoAssertBoardRestored::Init().

bool GoBoard::KoModifiesHash (  )  const

Definition at line 1549 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.

Returns:
The ko point or SG_NULLPOINT, if none exists.

Definition at line 1554 of file GoBoard.h.

References GoBoard::State::m_koPoint, and m_state.

bool GoBoard::KoRepetitionAllowed (  )  const

Definition at line 1559 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 1564 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.

See also:
GoMoveInfoFlag

Definition at line 1569 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 1574 of file GoBoard.h.

References SgBoardConst::Left(), and m_const.

SgGrid GoBoard::Line ( SgPoint  p  )  const

See SgBoardConst::Line.

Definition at line 1579 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(), GoEyeUtil::NumberOfMoveToEye2(), and Special2x3Cases().

const SgPointSet & GoBoard::LineSet ( SgGrid  line  )  const

See SgBoardConst::LineSet.

Definition at line 1584 of file GoBoard.h.

References SgBoardConst::LineSet(), and m_const.

Referenced by GoBoardUtil::Lines(), NuEdgePoints(), and Special2x3Cases().

void GoBoard::MergeBlocks ( SgPoint  p,
SgBlackWhite  c,
const SgSList< Block *, 4 > &  adjBlocks 
) [private]

Definition at line 299 of file GoBoard.cpp.

References GoBoard::Block::AppendLiberty(), GoBoard::Block::AppendStone(), SgMarker::Clear(), CreateNewBlock(), GoBoard::Block::Init(), IsColor(), IsEmpty(), GoBoard::State::m_block, m_marker, m_state, SgMarker::NewMark(), NumNeighbors(), SG_ASSERT, SG_NS, SG_UNUSED(), SG_WE, and GoBoard::Block::UpdateAnchor().

Referenced by UpdateBlocksAfterAddStone().

GoPlayerMove GoBoard::Move ( int  i  )  const

Return move with a certain move number.

Parameters:
i The move number (starting with 0).
Returns:
The ith move.

Definition at line 532 of file GoBoard.cpp.

References GoBoard::StackEntry::m_color, and GoBoard::StackEntry::m_point.

Referenced by GoBoardUtil::EndOfGame(), GoBoardSynchronizer::FindNuCommon(), GetSequence(), GoBoardRestorer::GoBoardRestorer(), GoBoardHistory::SetFromBoard(), GoBoardUtil::TwoPasses(), GoBoardSynchronizer::UpdateFromInit(), and GoBoardSynchronizer::UpdateIncremental().

int GoBoard::MoveNumber (  )  const

Return the current number moves.

Definition at line 1589 of file GoBoard.h.

References m_moves.

Referenced by GoAssertBoardRestored::AssertRestored(), GoLadder::CheckMoveOverflow(), GoGtpEngine::CmdSetup(), GoBoardUtil::EndOfGame(), GoBoardSynchronizer::FindNuCommon(), FullBoardRepetition(), Get2ndLastMove(), GetLastMove(), GetSequence(), 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,
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 606 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.

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 584 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().

int GoBoard::NuCapturedStones (  )  const

The stones captured by the most recent move.

See also:
CapturedStones

Definition at line 1604 of file GoBoard.h.

References SgSList< T, SIZE >::Length(), and m_capturedStones.

int GoBoard::Num8EmptyNeighbors ( SgPoint  p  )  const

Includes diagonals.

Definition at line 1599 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 1594 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 1609 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 1623 of file GoBoard.h.

References NumDiagonals(), and SG_EMPTY.

Referenced by GoEyeUtil::IsPossibleEye(), and Num8EmptyNeighbors().

int GoBoard::NumEmptyNeighbors ( SgPoint  p  )  const

Definition at line 1628 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(), Num8EmptyNeighbors(), and TwoDiagonalStonesInBulkyFour().

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 1633 of file GoBoard.h.

References IsValidPoint(), GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.

Referenced by GoBoardUtil::Approx2Libs(), AtLeastNumLibs(), AtMostNumLibs(), GoEyeUtil::CheckInterior(), GoBoardUtil::GetDirtyRegion(), HasLiberties(), GoStaticLadder::IsEdgeLadder(), GoLadderUtil::IsProtectedLiberty(), IsSuicide(), GoLadder::Ladder(), GoBlock::NuLiberties(), Play(), and TheLiberty().

int GoBoard::NumNeighbors ( SgPoint  p,
SgBlackWhite  c 
) const

Definition at line 1640 of file GoBoard.h.

References GoBoard::State::m_nuNeighbors, and m_state.

Referenced by AddLibToAdjBlocks(), AdjacentBlocks(), GoBoardUtil::BlocksAdjacentToPoints(), BulkyFiveNakade(), CheckConsistency(), CreateSingleStoneBlock(), GetAdjacentBlocks(), GoRegion::IsCorridor(), GoStaticLadder::IsEdgeLadder(), GoEyeUtil::IsPossibleEye(), IsSingleStone(), GoEyeUtil::IsVitalPt(), MergeBlocks(), NeighborBlocks(), Num8Neighbors(), GoEyeUtil::NumberOfMoveToEye(), RemoveLibAndKill(), RemoveLibFromAdjBlocks(), TwoDiagonalStonesInBulkyFour(), 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 1645 of file GoBoard.h.

References GoBoard::State::m_prisoners, and m_state.

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 1650 of file GoBoard.h.

References GoBoard::State::m_block, m_state, Occupied(), and SG_ASSERT.

Referenced by BulkyFiveNakade(), CheckConsistencyBlock(), IsNakadeBlock(), GoLadderUtil::IsProtectedLiberty(), and Play().

SgPointSet GoBoard::Occupied (  )  const

Definition at line 1656 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::Occupied ( SgPoint  p  )  const

Check if point is occupied by a stone.

Can be called with border points.

Definition at line 1661 of file GoBoard.h.

References GoBoard::State::m_block, and m_state.

Referenced by GoBook::Add(), GoBoardUtil::AdjacentStones(), GoBoardUtil::AtLeastTwoSharedLibs(), GoBoardUtil::CfgDistance(), CfgDistanceCheck(), GoGtpEngine::CheckLegal(), GoGtpEngine::CmdPointInfo(), GoEyeUtil::CountSinglePointEyes2(), 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::SharedLiberties(), GoBoard::StoneIterator::StoneIterator(), GoBoardUtil::Stones(), GoBoardUpdater::Update(), and GoGtpEngine::WriteBoardInfo().

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 1666 of file GoBoard.h.

References GoBoard::State::m_block, m_state, and GoBoard::Block::NumLiberties().

bool GoBoard::OnEdge ( SgPoint  p  )  const

Definition at line 1672 of file GoBoard.h.

References Edges().

Referenced by GoGtpEngine::CmdPointInfo().

GoBoard& GoBoard::operator= ( const GoBoard  )  [private]

Not implemented.

SgBlackWhite GoBoard::Opponent (  )  const

Opponent of player whose turn it is to play.

Definition at line 1677 of file GoBoard.h.

References m_state, GoBoard::State::m_toPlay, and SgOppBW().

void GoBoard::Play ( GoPlayerMove  move  ) 

Play a move.

See also:
Play(SgPoint,SgBlackWhite);

Definition at line 1682 of file GoBoard.h.

References GoPlayerMove::Color(), Play(), and GoPlayerMove::Point().

void GoBoard::Play ( SgPoint  p  ) 

Play a move for the current player.

See also:
Play(SgPoint,SgBlackWhite);

Definition at line 1687 of file GoBoard.h.

References Play(), and ToPlay().

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 771 of file GoBoard.cpp.

References AddStoneForUndo(), CheckConsistency(), CheckKo(), CheckSuicide(), SgSList< T, SIZE >::Clear(), GO_MOVEFLAG_CAPTURING, GO_MOVEFLAG_ILLEGAL, SgSList< T, SIZE >::IsEmpty(), IsEmpty(), IsFirst(), IsNewPosition(), IsPass(), IsValidPoint(), m_capturedStones, GoBoard::StackEntry::m_color, m_countPlay, GoBoard::State::m_hash, 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(), SaveState(), SG_ASSERT, SG_ASSERT_BW, SG_NULLMOVE, SG_NULLPOINT, SgOppBW(), UpdateBlocksAfterAddStone(), and GoBoard::HashCode::XorCaptured().

Referenced by GoBoardUtil::AddWall(), GoBook::Entry::ApplyTo(), GoGtpEngine::CheckLegal(), GoGtpEngine::CmdPlaceFreeHandicap(), GoBoardSynchronizer::ExecuteSubscriber(), GoLadder::HunterLadder(), IsLegal(), Play(), GoBoardUtil::PlayIfLegal(), GoAutoBookState::Synchronize(), GoBoardUpdater::Update(), and GoBoardRestorer::~GoBoardRestorer().

SgGrid GoBoard::Pos ( SgPoint  p  )  const

See SgBoardConst::Pos.

Definition at line 1692 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 843 of file GoBoard.cpp.

References GetAdjacentBlocks(), KillBlock(), GoBoard::StackEntry::m_killed, NumNeighbors(), SG_BLACK, and SG_WHITE.

Referenced by Play().

void GoBoard::RemoveLibFromAdjBlocks ( SgPoint  p,
SgBlackWhite  c 
) [private]

Definition at line 334 of file GoBoard.cpp.

References GetAdjacentBlocks(), and NumNeighbors().

Referenced by RestoreKill().

void GoBoard::RemoveStone ( SgPoint  p  )  [private]

Definition at line 650 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 RemoveStoneForUndo(), and UpdateBlocksAfterUndo().

void GoBoard::RemoveStoneForUndo ( SgPoint  p  )  [private]

Definition at line 680 of file GoBoard.cpp.

References GetStone(), GoBoard::State::m_hash, m_state, RemoveStone(), SG_ASSERT_BOARDRANGE, and GoBoard::HashCode::XorStone().

Referenced by KillBlock().

void GoBoard::RestoreKill ( Block block,
SgBlackWhite  c 
) [private]

Definition at line 343 of file GoBoard.cpp.

References AddStone(), SgSList< 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.

See also:
TakeSnapshot()

Definition at line 907 of file GoBoard.cpp.

References CheckConsistency(), GoBoard::State::m_block, m_blockList, m_moves, m_snapshot, m_state, MoveNumber(), and SG_ASSERT.

void GoBoard::RestoreState ( const StackEntry entry  )  [private]

Restore state.

Definition at line 862 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.

See also:
Left for more info.

Definition at line 1697 of file GoBoard.h.

References m_const, and SgBoardConst::Right().

const GoRules & GoBoard::Rules (  )  const

Current game rules.

Definition at line 1707 of file GoBoard.h.

References m_rules.

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 1702 of file GoBoard.h.

References m_rules.

Referenced by GoAssertBoardRestored::AssertRestored(), GoGtpEngine::CheckLegal(), GoGtpEngine::CmdFinalScore(), GoGtpEngine::CmdGenMoveCleanup(), GoGtpEngine::CmdGetKomi(), GoGtpEngine::CmdKomi(), GoGtpEngine::CmdLoadSgf(), GoGtpEngine::CmdParamRules(), GoBoardUtil::EndOfGame(), FullBoardRepetition(), GoRestoreRepetitionAndSuicide::GoRestoreRepetitionAndSuicide(), GoRestoreSuicide::GoRestoreSuicide(), GoAssertBoardRestored::Init(), GoGameRecord::InitFromRoot(), IsLegal(), GoBoardUtil::PassWins(), GoGtpEngine::PlaceHandicap(), GoBoardUtil::PlayIfLegal(), GoBoardUtil::RemainingChineseHandicap(), GoBoardHistory::SetFromBoard(), GoGtpEngine::SetNamedRules(), GoBoardSynchronizer::UpdateSubscriber(), GoRestoreKoRule::~GoRestoreKoRule(), GoRestoreRepetitionAndSuicide::~GoRestoreRepetitionAndSuicide(), and GoRestoreSuicide::~GoRestoreSuicide().

void GoBoard::SaveState ( StackEntry entry  )  [private]

Save state.

Parameters:
entry The stack entry to save information to; must already have a valid m_type field.

Definition at line 878 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  ) 

See KoLoser.

Definition at line 1712 of file GoBoard.h.

References KoLevel(), m_koLoser, and SG_ASSERT.

void GoBoard::SetKoModifiesHash ( bool  modify  ) 

Enable modification of hash code by Ko moves.

Can be used if Ko repetition is allowed.

Warning:
You have to disable it in the same position, where it was enabled, otherwise the incremental update of the hash code does not work; use KoHashModifier in GoBoardUtil to do this automatically.

Definition at line 1718 of file GoBoard.h.

References m_koModifiesHash.

void GoBoard::SetToPlay ( SgBlackWhite  player  ) 

Set the current player.

Definition at line 1723 of file GoBoard.h.

References m_state, GoBoard::State::m_toPlay, and SG_ASSERT_BW.

Referenced by GoGtpEngine::CmdSetupPlayer(), GoGtpEngine::GenMove(), GoLadderUtil::IsProtectedLiberty(), GoSearch::SetToPlay(), GoGameRecord::SetToPlay(), GoBoardUtil::TestForChain(), GoBoardUpdater::Update(), GoBoardSynchronizer::UpdateToPlay(), and GoRestoreToPlay::~GoRestoreToPlay().

const GoSetup & GoBoard::Setup (  )  const

Setup information of the first position.

Definition at line 1729 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 1734 of file GoBoard.h.

References m_const, and SgBoardConst::Side().

const SgPointSet & GoBoard::SideExtensions (  )  const

See SgBoardConst::SideExtensions.

Definition at line 1739 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 1744 of file GoBoard.h.

References m_size.

Referenced by GoBook::Add(), GoSafetyUtil::AddToSafe(), GoRegion::AllInsideLibs(), AllPoints(), AlmostFilledByLivingShape(), AlmostFilledByNakade(), GoBook::Entry::ApplyTo(), GoAssertBoardRestored::AssertRestored(), GoRegion::CheckConsistency(), GoRegionBoard::Clear(), GoGtpExtraCommands::CmdCfgDistance(), GoGtpEngine::CmdFixedHandicap(), GoGtpEngine::CmdListStones(), GoGtpEngine::CmdPlaceFreeHandicap(), GoGtpEngine::CmdPointNumbers(), ContainsLivingShape(), GoBook::Delete(), GoRegion::Dep(), GoBoardUtil::DumpBoard(), GoBoardUtil::ExpandToBlocks(), GoSafetyUtil::ExtendedIsTerritory(), GoSafetyUtil::ExtendedMightMakeLife(), Find2ConnectionsForAll(), GoRegion::Find2ConnForAllInterior(), GoRegion::FindBlocks(), GoRegion::FindChains(), GoSafetyUtil::FindDameAndUnsurroundablePoints(), GoInfluence::FindInfluence(), GoRegionBoard::GetBlock(), GoBoardUtil::GetCoordString(), GoRegionUtil::Has2SureLiberties(), GoGameRecord::Init(), GoAssertBoardRestored::Init(), GoGameRecord::InitFromRoot(), GoBook::InsertEntry(), GoStaticLadder::IsEdgeLadder(), GoRegionUtil::IsSingleBlock(), GoRegionUtil::IsSmallRegion(), GoRegion::IsSurrounded(), GoSafetyUtil::IsTerritory(), GoBlock::Liberties(), GoBoardUtil::Lines(), GoBook::LookupEntry(), GoRegionBoard::MergeAdjacentAndAddBlock(), GoSafetyUtil::MightMakeLife(), GoGameRecord::OnInitHandicap(), operator<<(), GoRegionBoard::RemoveBlock(), GoRegion::Safe2Cuts(), GoRegion::SetBlocks(), GoBoardHistory::SetFromBoard(), GoAutoBookState::Synchronize(), GoEyeUtil::TestNakade(), TotalNumEmpty(), TwoDiagonalStonesInBulkyFour(), TwoSeparateEyes(), 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 540 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 894 of file GoBoard.cpp.

References GoBoard::State::m_block, m_blockList, m_snapshot, m_state, and MoveNumber().

SgPoint GoBoard::TheLiberty ( SgPoint  blockInAtari  )  const

Return the liberty of 'blockInAtari' which must have exactly one liberty.

Definition at line 1749 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 1756 of file GoBoard.h.

References m_state, and GoBoard::State::m_toPlay.

Referenced by GoAssertBoardRestored::AssertRestored(), GoSetupUtil::CurrentPosSetup(), GoBoardUtil::EndOfGame(), GoSearch::Execute(), Get2ndLastMove(), GetHashCodeInclToPlay(), GetLastMove(), GoTimeControl::GetPositionInfo(), GoSearch::GetToPlay(), GoAssertBoardRestored::Init(), IsLegal(), GoLadderUtil::IsProtectedLiberty(), IsSuicide(), GoBoardUtil::PassWins(), Play(), GoBoardUtil::PlayIfLegal(), GoGame::PlayOneMove(), GoBoardHistory::SetFromBoard(), GoGameRecord::SetToPlay(), GoBoardUtil::TwoPasses(), GoBoardSynchronizer::UpdateToPlay(), and GoGtpEngine::WriteBoardInfo().

int GoBoard::TotalNumEmpty (  )  const

Number of empty points currently on the board.

Definition at line 1761 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().

int GoBoard::TotalNumStones ( SgBlackWhite  color  )  const

Definition at line 1772 of file GoBoard.h.

References GoBoard::State::m_numStones, and m_state.

const SgBWArray< int > & GoBoard::TotalNumStones (  )  const

Number of stones currently on the board.

Definition at line 1767 of file GoBoard.h.

References GoBoard::State::m_numStones, and m_state.

Referenced by GoAssertBoardRestored::AssertRestored(), GoGtpEngine::CheckBoardEmpty(), GoAssertBoardRestored::Init(), GoBoardUtil::RemainingChineseHandicap(), and GoGtpEngine::WriteBoardInfo().

void GoBoard::Undo (  ) 

Undo the most recent move.

Definition at line 830 of file GoBoard.cpp.

References CheckConsistency(), m_moves, RestoreState(), and UpdateBlocksAfterUndo().

Referenced by GoGtpEngine::CheckLegal(), GoLadder::HunterLadder(), IsLegal(), GoLadderUtil::IsProtectedLiberty(), GoLadder::IsSnapback(), GoBoardUtil::IsSnapback(), GoLadder::PlayHunterMove(), GoBoardUtil::PlayIfLegal(), GoLadder::PlayPreyMove(), 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 1777 of file GoBoard.h.

References m_const, and SgBoardConst::Up().

void GoBoard::UpdateBlocksAfterAddStone ( SgPoint  p,
SgBlackWhite  c,
StackEntry entry 
) [private]

Definition at line 359 of file GoBoard.cpp.

References AddStoneToBlock(), CreateSingleStoneBlock(), GetAdjacentBlocks(), IsColor(), SgSList< 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 388 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, GoBoard::Block::PopStone(), RemoveStone(), RestoreKill(), GoBoard::Block::SetAnchor(), SgOppBW(), and GoBoard::Block::Stones().

Referenced by Undo().


Friends And Related Function Documentation

friend class LibertyCopyIterator [friend]

Definition at line 932 of file GoBoard.h.

friend class LibertyIterator [friend]

Definition at line 933 of file GoBoard.h.

Referenced by GoLadder::HunterLadder(), and GoLadder::PreyLadder().

friend class StoneIterator [friend]

Definition at line 934 of file GoBoard.h.


Member Data Documentation

bool GoBoard::m_allowAnyRepetition [private]

Arbitrary repetition for both players.

Definition at line 836 of file GoBoard.h.

Referenced by AllowAnyRepetition(), AnyRepetitionAllowed(), and Init().

bool GoBoard::m_allowKoRepetition [private]

Allow take-back of ko repetition.

Definition at line 839 of file GoBoard.h.

Referenced by AllowKoRepetition(), Init(), and KoRepetitionAllowed().

SgSList<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 825 of file GoBoard.h.

Referenced by CreateNewBlock(), RestoreSnapshot(), TakeSnapshot(), UpdateBlocksAfterUndo(), and ~GoBoard().

GoPointList GoBoard::m_capturedStones [private]

Definition at line 833 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 807 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 804 of file GoBoard.h.

Referenced by CountPlay(), Init(), and Play().

SgArray<bool,SG_MAXPOINT> GoBoard::m_isBorder [private]

Definition at line 848 of file GoBoard.h.

Referenced by Init(), InitBlock(), and IsBorder().

SgEmptyBlackWhite GoBoard::m_koColor [private]

Definition at line 843 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 846 of file GoBoard.h.

Referenced by CheckKo(), Init(), KoLoser(), RestoreState(), SaveState(), and SetKoLoser().

bool GoBoard::m_koModifiesHash [private]

Definition at line 841 of file GoBoard.h.

Referenced by CheckKo(), Init(), KoModifiesHash(), Play(), RestoreState(), SaveState(), and SetKoModifiesHash().

SgMarker GoBoard::m_marker [mutable, private]

Definition at line 831 of file GoBoard.h.

Referenced by AdjacentBlocks(), InitBlock(), MergeBlocks(), and NeighborBlocks().

GoMoveInfo GoBoard::m_moveInfo [private]

Definition at line 820 of file GoBoard.h.

Referenced by CheckKo(), CheckSuicide(), GetLastMoveInfo(), LastMoveInfo(), and Play().

SgSList<StackEntry,GO_MAX_NUM_MOVES>* GoBoard::m_moves [private]

Definition at line 850 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 815 of file GoBoard.h.

Referenced by CheckSuicide(), Init(), and Rules().

GoSetup GoBoard::m_setup [private]

Setup stones in the root position.

Definition at line 818 of file GoBoard.h.

Referenced by Setup().

SgGrid GoBoard::m_size [private]

The current board size.

Definition at line 810 of file GoBoard.h.

Referenced by Init(), and Size().

std::auto_ptr<Snapshot> GoBoard::m_snapshot [private]

Definition at line 801 of file GoBoard.h.

Referenced by RestoreSnapshot(), and TakeSnapshot().

State GoBoard::m_state [private]

Definition at line 799 of file GoBoard.h.

Referenced by AddStone(), AddStoneForUndo(), 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(), RemoveStoneForUndo(), 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 116 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

See also:
KoModifiesHash()

Definition at line 105 of file GoBoard.h.

Referenced by CheckKo(), and GoBoard::HashCode::XorWinKo().


The documentation for this class was generated from the following files:


17 Jun 2010 Doxygen 1.4.7