GoRegionBoard provides GoRegion, GoBlock and optionally GoChain. More...
#include <GoRegionBoard.h>
Public Member Functions | |
GoRegionBoard (const GoBoard &board) | |
Constructor. | |
virtual | ~GoRegionBoard () |
release memory. | |
void | Clear () |
delete all blocks and regions, set board size | |
void | CheckConsistency () const |
For debugging. | |
bool | UpToDate () const |
Have blocks and regions been computed for current board position? | |
bool | ComputedHealthy () const |
bool | ChainsUpToDate () const |
Have chains been computed for current board position? | |
void | ExecuteMovePrologue () |
MUST call before playing move on GoBoard. | |
void | OnExecutedMove (GoPlayerMove playerMove) |
Called after a move or added stone has been successfully executed. | |
void | OnExecutedUncodedMove (int move, SgBlackWhite moveColor) |
Similar to OnExecutedMove, but move is not coded into one int. | |
void | OnUndoneMove () |
Called after a move has been undone. | |
SgVectorOf< GoBlock > & | AllBlocks (SgBlackWhite color) |
All GoBlock's of given color. | |
const SgVectorOf< GoBlock > & | AllBlocks (SgBlackWhite color) const |
All GoBlock's of given color. | |
SgVectorOf< GoChain > & | AllChains (SgBlackWhite color) |
All GoChain's of given color. | |
const SgVectorOf< GoChain > & | AllChains (SgBlackWhite color) const |
All GoChain's of given color. | |
SgVectorOf< GoRegion > & | AllRegions (SgBlackWhite color) |
All GoRegion's of given color. | |
const SgVectorOf< GoRegion > & | AllRegions (SgBlackWhite color) const |
All GoRegion's of given color. | |
const SgPointSet & | All (SgBlackWhite color) const |
See GoBoard::All. | |
const SgPointSet & | AllEmpty () const |
See GoBoard::AllEmpty. | |
const SgPointSet & | AllPoints () const |
See GoBoard::AllPoints. | |
bool | IsColor (SgPoint p, int c) const |
See GoBoard::IsColor. | |
void | WriteBlocks (std::ostream &stream) const |
write information on all GoBlock's | |
void | WriteRegions (std::ostream &stream) const |
write information on all GoRegion's | |
void | GenBlocksRegions () |
generate all blocks and regions | |
void | GenChains () |
Compute all GoChain's. | |
void | ReInitializeBlocksRegions () |
Clear all flags etc. | |
void | SetComputedFlagForAll (GoRegionFlag flag) |
mark all regions that the given attribute has been computed | |
const GoBoard & | Board () const |
GoBlock * | GetBlock (const SgPointSet &boundary, SgBlackWhite color) const |
Searches the list of all blocks for the block. | |
GoRegion * | PreviousRegionAt (SgPoint p, SgBlackWhite color) const |
For incremental update, region where stone was just played. | |
GoRegion * | RegionAt (SgPoint p, SgBlackWhite color) const |
Region of color at point p. | |
void | RegionsAt (const SgPointSet &area, SgBlackWhite color, SgVectorOf< GoRegion > *regions) const |
Region of color in area. | |
void | AdjacentRegions (const SgVector< SgPoint > &points, SgBlackWhite color, SgVectorOf< GoRegion > *regions) const |
Region of color adjacent to points. | |
void | PreviousBlocksAt (const SgVector< SgPoint > &area, SgBlackWhite color, SgVectorOf< GoBlock > *captures) const |
Return GoBlock's just captured on last move, before update. | |
GoBlock * | BlockAt (SgPoint p) const |
GoBlock at point p. | |
GoChain * | ChainAt (SgPoint p) const |
GoChain at point p. | |
bool | IsSafeBlock (SgPoint p) const |
Is block at point p marked as safe? | |
void | SetToSafe (SgPoint p) const |
Set safe flag for block at p. | |
void | SetSafeFlags (const SgBWSet &safe) |
Set safe flags for all blocks in safe. | |
void | SetComputedHealthy () |
Set m_computedHealthy flag to true. | |
Static Public Member Functions | |
static bool | Init () |
class initialization | |
static void | Fini () |
class finalization | |
Private Member Functions | |
void | GenBlocks () |
Generate blocks. | |
void | FindBlocksWithEye () |
Set the m_has1Eye flag for all blocks with 1 eye. | |
GoBlock * | GenBlock (SgPoint anchor, SgBlackWhite color) |
Generate the block with given anchor. | |
GoRegion * | GenRegion (const SgPointSet &area, SgBlackWhite color) |
Generate a region of color in area. | |
void | UpdateBlock (int move, SgBlackWhite moveColor) |
incremental update of block after move | |
void | SetRegionArrays (GoRegion *r) |
Sets m_region elements to point to r. | |
void | AddBlock (GoBlock *b, bool isExecute=true) |
add block to GoRegionBoard | |
void | RemoveBlock (GoBlock *b, bool isExecute, bool removeFromRegions) |
remove block from GoRegionBoard | |
void | AddRegion (GoRegion *r, bool isExecute=true) |
add region to GoRegionBoard | |
void | RemoveRegion (GoRegion *r, bool isExecute=true) |
remove region from GoRegionBoard | |
void | MergeAdjacentAndAddBlock (SgPoint move, SgBlackWhite capturedColor) |
For all captured stones: merge its adjacent previous regions into one. | |
GoRegion * | MergeAll (const SgVectorOf< GoRegion > ®ions, const SgPointSet &captured, SgBlackWhite color) |
Merge all regions and the captured area into new large region. | |
void | PushRegion (int type, GoRegion *r) |
push on m_stack | |
void | PushStone (GoRegion *r, SgPoint move) |
push on m_stack | |
void | PushBlock (int type, GoBlock *b) |
push on m_stack | |
void | AppendStone (GoBlock *b, SgPoint move) |
add stome to b and push information on m_stack | |
Private Attributes | |
SgIncrementalStack | m_stack |
stores incremental state changes for execute/undo moves | |
const GoBoard & | m_board |
SgBWArray< SgPointArray < GoRegion * > > | m_region |
pointer to region, defined only at anchor of region | |
SgPointArray< GoBlock * > | m_block |
pointer from stone to block, 0 if empty point | |
SgBWArray< SgVectorOf< GoBlock > > | m_allBlocks |
All blocks on board. | |
SgBWArray< SgVectorOf< GoChain > > | m_allChains |
All chains on board. | |
SgBWArray< SgVectorOf< GoRegion > > | m_allRegions |
All regions on board. | |
SgHashCode | m_code |
Code for last time block and region information was computed. | |
SgHashCode | m_chainsCode |
Code for last time chain information was computed. | |
bool | m_invalid |
does block and region data match current board? | |
bool | m_computedHealthy |
has healthy count been computed for all blocks? | |
int | m_boardSize |
Boardsize is needed to avoid problems with resizing an empty board. | |
Static Private Attributes | |
static int | s_alloc = 0 |
debugging bookkeeping. | |
static int | s_free = 0 |
GoRegionBoard provides GoRegion, GoBlock and optionally GoChain.
To keep it updated during search, call OnExecutedMove (or OnExecutedUncodedMove) and OnUndoneMove when Executing/Undoing a move.
A GoRegionBoard depends on a GoBoard (supplied at construction) for keeping the low-level board state, Go rules etc.
There is a certain amount of duplication between the private blocks of a GoBoard and the GoBlock's in a GoRegionBoard.
GoChain's are not updated automatically for performance reasons
Definition at line 29 of file GoRegionBoard.h.
GoRegionBoard::GoRegionBoard | ( | const GoBoard & | board | ) | [explicit] |
Constructor.
Definition at line 69 of file GoRegionBoard.cpp.
References GenBlocksRegions(), SgHash< N >::Invalidate(), m_chainsCode, m_code, and s_alloc.
GoRegionBoard::~GoRegionBoard | ( | ) | [virtual] |
void GoRegionBoard::AddBlock | ( | GoBlock * | b, | |
bool | isExecute = true | |||
) | [private] |
add block to GoRegionBoard
Definition at line 381 of file GoRegionBoard.cpp.
References AllBlocks(), GoBlock::Anchor(), Board(), GoBlock::Color(), m_block, SgVectorOf< T >::PushBack(), and PushBlock().
Referenced by GenBlock(), and OnUndoneMove().
void GoRegionBoard::AddRegion | ( | GoRegion * | r, | |
bool | isExecute = true | |||
) | [private] |
add region to GoRegionBoard
Definition at line 614 of file GoRegionBoard.cpp.
References AllRegions(), GoRegion::Color(), GoRegion::ComputeBasicFlags(), GoRegion::FindBlocks(), HEAVYCHECK, SgVectorOf< T >::PushBack(), PushRegion(), SetRegionArrays(), and SG_ASSERT.
Referenced by GenRegion(), and OnUndoneMove().
void GoRegionBoard::AdjacentRegions | ( | const SgVector< SgPoint > & | points, | |
SgBlackWhite | color, | |||
SgVectorOf< GoRegion > * | regions | |||
) | const |
Region of color adjacent to points.
Definition at line 449 of file GoRegionBoard.cpp.
References AllRegions(), and SgVectorOf< T >::PushBack().
const SgPointSet& GoRegionBoard::All | ( | SgBlackWhite | color | ) | const |
See GoBoard::All.
Definition at line 115 of file GoRegionBoard.h.
References GoBoard::All(), and Board().
Referenced by GenBlocksRegions().
const SgVectorOf<GoBlock>& GoRegionBoard::AllBlocks | ( | SgBlackWhite | color | ) | const |
All GoBlock's of given color.
Definition at line 85 of file GoRegionBoard.h.
References m_allBlocks.
SgVectorOf<GoBlock>& GoRegionBoard::AllBlocks | ( | SgBlackWhite | color | ) |
All GoBlock's of given color.
Definition at line 79 of file GoRegionBoard.h.
References m_allBlocks.
Referenced by AddBlock(), CheckConsistency(), Clear(), GoRegion::FindBlocks(), GenChains(), GetBlock(), GoChain::GetBlocks(), ReInitializeBlocksRegions(), SetSafeFlags(), WriteBlocks(), and GoSafetyUtil::WriteStatistics().
const SgVectorOf<GoChain>& GoRegionBoard::AllChains | ( | SgBlackWhite | color | ) | const |
All GoChain's of given color.
Definition at line 97 of file GoRegionBoard.h.
References m_allChains.
SgVectorOf<GoChain>& GoRegionBoard::AllChains | ( | SgBlackWhite | color | ) |
All GoChain's of given color.
Definition at line 91 of file GoRegionBoard.h.
References m_allChains.
Referenced by ChainAt(), Clear(), GoRegion::FindChains(), GenChains(), and GoSafetySolver::Merge().
const SgPointSet& GoRegionBoard::AllEmpty | ( | ) | const |
See GoBoard::AllEmpty.
Definition at line 121 of file GoRegionBoard.h.
References GoBoard::AllEmpty(), and Board().
const SgPointSet& GoRegionBoard::AllPoints | ( | ) | const |
See GoBoard::AllPoints.
Definition at line 124 of file GoRegionBoard.h.
References GoBoard::AllPoints(), and Board().
Referenced by CheckConsistency(), and GenBlocksRegions().
SgVectorOf<GoRegion>& GoRegionBoard::AllRegions | ( | SgBlackWhite | color | ) |
All GoRegion's of given color.
Definition at line 103 of file GoRegionBoard.h.
References m_allRegions.
Referenced by AddRegion(), AdjacentRegions(), CheckConsistency(), Clear(), GoSafetyUtil::ExtendedMightMakeLife(), FindBlocksWithEye(), GenChains(), GoSafetyCommands::GetSafe(), OnExecutedUncodedMove(), OnUndoneMove(), RegionsAt(), ReInitializeBlocksRegions(), SetComputedFlagForAll(), SetSafeFlags(), GoChain::TestFor1Eye(), WriteRegions(), and GoSafetyUtil::WriteStatistics().
const SgVectorOf<GoRegion>& GoRegionBoard::AllRegions | ( | SgBlackWhite | color | ) | const |
All GoRegion's of given color.
Definition at line 109 of file GoRegionBoard.h.
References m_allRegions.
add stome to b and push information on m_stack
Definition at line 168 of file GoRegionBoard.cpp.
References GoBlock::AddStone(), m_block, m_stack, SgIncrementalStack::PushInt(), and SgIncrementalStack::PushPtrEvent().
Referenced by UpdateBlock().
GoBlock at point p.
Definition at line 193 of file GoRegionBoard.h.
References m_block, and SG_ASSERT.
Referenced by IsSafeBlock(), SetToSafe(), and UpdateBlock().
const GoBoard& GoRegionBoard::Board | ( | ) | const |
Definition at line 150 of file GoRegionBoard.h.
References m_board.
Referenced by AddBlock(), All(), AllEmpty(), AllPoints(), ChainAt(), ChainsUpToDate(), CheckConsistency(), GenBlock(), GenBlocks(), GenBlocksRegions(), GenChains(), GenRegion(), GetBlock(), IsColor(), MergeAdjacentAndAddBlock(), OnExecutedUncodedMove(), OnUndoneMove(), PreviousRegionAt(), RegionAt(), RemoveBlock(), UpdateBlock(), UpToDate(), and GoSafetyUtil::WriteStatistics().
GoChain at point p.
Definition at line 730 of file GoRegionBoard.cpp.
References AllChains(), Board(), ChainsUpToDate(), GoBoard::GetStone(), and SG_ASSERT.
bool GoRegionBoard::ChainsUpToDate | ( | ) | const |
Have chains been computed for current board position?
Definition at line 59 of file GoRegionBoard.h.
References Board(), GoBoard::GetHashCode(), m_chainsCode, and UpToDate().
Referenced by ChainAt(), and GenChains().
void GoRegionBoard::CheckConsistency | ( | ) | const |
For debugging.
Definition at line 253 of file GoRegionBoard.cpp.
References AllBlocks(), AllPoints(), AllRegions(), Board(), CHECK, SgPointSet::Contains(), SgPointSet::Disjoint(), m_block, m_region, SgPointUtil::Pt(), SG_ASSERT, SG_DEBUG_ONLY, SG_MAX_SIZE, and UpToDate().
Referenced by GenBlocksRegions(), OnExecutedUncodedMove(), and OnUndoneMove().
void GoRegionBoard::Clear | ( | ) |
delete all blocks and regions, set board size
Definition at line 89 of file GoRegionBoard.cpp.
References AllBlocks(), AllChains(), AllRegions(), SgIncrementalStack::Clear(), SgHash< N >::Invalidate(), m_allBlocks, m_allChains, m_allRegions, m_block, m_board, m_boardSize, m_code, m_computedHealthy, m_invalid, m_region, m_stack, SgPointUtil::Pt(), SG_BLACK, SG_MAX_SIZE, SG_WHITE, SgDebug(), and GoBoard::Size().
Referenced by GenBlocksRegions(), and ~GoRegionBoard().
bool GoRegionBoard::ComputedHealthy | ( | ) | const |
Definition at line 53 of file GoRegionBoard.h.
References m_computedHealthy.
void GoRegionBoard::ExecuteMovePrologue | ( | ) |
MUST call before playing move on GoBoard.
Definition at line 182 of file GoRegionBoard.cpp.
References GenBlocksRegions(), SgDebug(), and UpToDate().
void GoRegionBoard::FindBlocksWithEye | ( | ) | [private] |
Set the m_has1Eye flag for all blocks with 1 eye.
Definition at line 633 of file GoRegionBoard.cpp.
References AllRegions().
Referenced by GenBlocksRegions().
void GoRegionBoard::Fini | ( | ) | [static] |
class finalization
Definition at line 47 of file GoRegionBoard.cpp.
GoBlock * GoRegionBoard::GenBlock | ( | SgPoint | anchor, | |
SgBlackWhite | color | |||
) | [private] |
Generate the block with given anchor.
Definition at line 391 of file GoRegionBoard.cpp.
References AddBlock(), and Board().
Referenced by GenBlocks(), and UpdateBlock().
void GoRegionBoard::GenBlocks | ( | ) | [private] |
Generate blocks.
Definition at line 743 of file GoRegionBoard.cpp.
References Board(), and GenBlock().
Referenced by GenBlocksRegions().
void GoRegionBoard::GenBlocksRegions | ( | ) |
generate all blocks and regions
Definition at line 647 of file GoRegionBoard.cpp.
References All(), AllPoints(), Board(), CheckConsistency(), Clear(), FindBlocksWithEye(), GenBlocks(), GenRegion(), GoBoard::GetHashCode(), HEAVYCHECK, m_code, m_invalid, and UpToDate().
Referenced by ExecuteMovePrologue(), GoStaticSafetySolver::GenBlocksRegions(), and GoRegionBoard().
void GoRegionBoard::GenChains | ( | ) |
Compute all GoChain's.
The merging is only done in GoSafetySolver::GenBlocksRegions() and must be moved here.
Definition at line 671 of file GoRegionBoard.cpp.
References AllBlocks(), AllChains(), AllRegions(), Board(), ChainsUpToDate(), GoBoard::GetHashCode(), m_chainsCode, SgVectorOf< T >::PushBack(), and SG_ASSERT.
Referenced by GoSafetySolver::GenBlocksRegions().
GoRegion * GoRegionBoard::GenRegion | ( | const SgPointSet & | area, | |
SgBlackWhite | color | |||
) | [private] |
Generate a region of color in area.
Definition at line 606 of file GoRegionBoard.cpp.
References AddRegion(), and Board().
Referenced by GenBlocksRegions(), MergeAll(), and OnExecutedUncodedMove().
GoBlock * GoRegionBoard::GetBlock | ( | const SgPointSet & | boundary, | |
SgBlackWhite | color | |||
) | const |
Searches the list of all blocks for the block.
Boundary must belong to a single block.
Definition at line 709 of file GoRegionBoard.cpp.
References AllBlocks(), Board(), SG_ASSERT, SgDebug(), GoBoard::Size(), SgPointSet::SubsetOf(), UpToDate(), and SgPointSet::Write().
static bool GoRegionBoard::Init | ( | ) | [static] |
class initialization
bool GoRegionBoard::IsColor | ( | SgPoint | p, | |
int | c | |||
) | const |
See GoBoard::IsColor.
Definition at line 127 of file GoRegionBoard.h.
References Board(), and GoBoard::IsColor().
Referenced by RegionAt(), and UpdateBlock().
bool GoRegionBoard::IsSafeBlock | ( | SgPoint | p | ) | const |
Is block at point p marked as safe?
Definition at line 37 of file GoRegionBoard.cpp.
References BlockAt(), and GoBlock::IsSafe().
void GoRegionBoard::MergeAdjacentAndAddBlock | ( | SgPoint | move, | |
SgBlackWhite | capturedColor | |||
) | [private] |
For all captured stones: merge its adjacent previous regions into one.
then for all captured stones: add their area to its single adjacent region.
Definition at line 473 of file GoRegionBoard.cpp.
References Board(), MergeAll(), SgVectorOf< T >::NonEmpty(), PreviousBlocksAt(), SgVector< T >::PushBack(), RegionsAt(), RemoveBlock(), SG_ASSERT, SG_UNUSED(), and GoBoard::Size().
Referenced by OnExecutedUncodedMove().
GoRegion * GoRegionBoard::MergeAll | ( | const SgVectorOf< GoRegion > & | regions, | |
const SgPointSet & | captured, | |||
SgBlackWhite | color | |||
) | [private] |
Merge all regions and the captured area into new large region.
Definition at line 458 of file GoRegionBoard.cpp.
References GenRegion(), and RemoveRegion().
Referenced by MergeAdjacentAndAddBlock().
void GoRegionBoard::OnExecutedMove | ( | GoPlayerMove | playerMove | ) |
Called after a move or added stone has been successfully executed.
The board is guaranteed to be in a legal state.
Definition at line 177 of file GoRegionBoard.cpp.
References GoPlayerMove::Color(), OnExecutedUncodedMove(), and GoPlayerMove::Point().
void GoRegionBoard::OnExecutedUncodedMove | ( | int | move, | |
SgBlackWhite | moveColor | |||
) |
Similar to OnExecutedMove, but move is not coded into one int.
Definition at line 192 of file GoRegionBoard.cpp.
References AllRegions(), Board(), CheckConsistency(), GoRegion::ComputeBasicFlags(), GenRegion(), GoBoard::GetHashCode(), GO_MOVEFLAG_CAPTURING, GO_MOVEFLAG_SUICIDE, HEAVYCHECK, SgPointSet::IsEmpty(), GoEyeUtil::IsSplitPt(), GoRegion::IsValid(), GoBoard::LastMoveInfo(), m_code, m_stack, MergeAdjacentAndAddBlock(), GoRegion::OnAddStone(), GoRegion::Points(), PreviousRegionAt(), PushStone(), RemoveRegion(), SG_ASSERT, SG_PASS, SgDebug(), SgOppBW(), SgIncrementalStack::StartMoveInfo(), and UpdateBlock().
Referenced by OnExecutedMove().
void GoRegionBoard::OnUndoneMove | ( | ) |
Called after a move has been undone.
The board is guaranteed to be in a legal state.
Definition at line 501 of file GoRegionBoard.cpp.
References AddBlock(), AddRegion(), AllRegions(), GoRegion::Blocks(), GoRegion::BlocksNonConst(), Board(), CHECK, CheckConsistency(), GoRegion::Color(), SgVectorOf< T >::Contains(), GoBoard::GetHashCode(), HEAVYCHECK, SgVectorOf< T >::Insert(), GoRegion::IsValid(), m_block, m_code, m_region, m_stack, GoRegion::OnRemoveStone(), SgIncrementalStack::PopEvent(), SgIncrementalStack::PopInt(), SgIncrementalStack::PopPtr(), SgVectorOf< T >::PushBack(), RemoveBlock(), RemoveRegion(), GoBlock::RemoveStone(), SG_ASSERT, SG_NEXTMOVE, SG_UNUSED(), and SgDebug().
void GoRegionBoard::PreviousBlocksAt | ( | const SgVector< SgPoint > & | area, | |
SgBlackWhite | color, | |||
SgVectorOf< GoBlock > * | captures | |||
) | const |
Return GoBlock's just captured on last move, before update.
For incremental update. Can be called for any empty point. returns 0 if no previous block there.
Definition at line 399 of file GoRegionBoard.cpp.
References SgVectorOf< T >::Include(), m_block, and SG_UNUSED().
Referenced by MergeAdjacentAndAddBlock().
GoRegion* GoRegionBoard::PreviousRegionAt | ( | SgPoint | p, | |
SgBlackWhite | color | |||
) | const |
For incremental update, region where stone was just played.
Definition at line 161 of file GoRegionBoard.h.
References Board(), m_region, and SG_ASSERT.
Referenced by OnExecutedUncodedMove().
void GoRegionBoard::PushBlock | ( | int | type, | |
GoBlock * | b | |||
) | [private] |
push on m_stack
Definition at line 303 of file GoRegionBoard.cpp.
References m_stack, and SgIncrementalStack::PushPtrEvent().
Referenced by AddBlock(), and RemoveBlock().
void GoRegionBoard::PushRegion | ( | int | type, | |
GoRegion * | r | |||
) | [private] |
push on m_stack
Definition at line 298 of file GoRegionBoard.cpp.
References m_stack, and SgIncrementalStack::PushPtrEvent().
Referenced by AddRegion(), and RemoveRegion().
push on m_stack
Definition at line 308 of file GoRegionBoard.cpp.
References GoRegion::Color(), m_region, m_stack, SgIncrementalStack::PushInt(), and SgIncrementalStack::PushPtrEvent().
Referenced by OnExecutedUncodedMove().
GoRegion* GoRegionBoard::RegionAt | ( | SgPoint | p, | |
SgBlackWhite | color | |||
) | const |
Region of color at point p.
Definition at line 169 of file GoRegionBoard.h.
References Board(), IsColor(), m_region, SG_ASSERT, and UpToDate().
void GoRegionBoard::RegionsAt | ( | const SgPointSet & | area, | |
SgBlackWhite | color, | |||
SgVectorOf< GoRegion > * | regions | |||
) | const |
Region of color in area.
Definition at line 441 of file GoRegionBoard.cpp.
References AllRegions(), and SgVectorOf< T >::PushBack().
Referenced by MergeAdjacentAndAddBlock(), RemoveBlock(), and UpdateBlock().
void GoRegionBoard::ReInitializeBlocksRegions | ( | ) |
Clear all flags etc.
to recompute regions and blocks
Definition at line 592 of file GoRegionBoard.cpp.
References AllBlocks(), AllRegions(), SG_ASSERT, and UpToDate().
Referenced by GoStaticSafetySolver::GenBlocksRegions().
void GoRegionBoard::RemoveBlock | ( | GoBlock * | b, | |
bool | isExecute, | |||
bool | removeFromRegions | |||
) | [private] |
remove block from GoRegionBoard
Definition at line 348 of file GoRegionBoard.cpp.
References Board(), SgPointSet::Border(), GoBlock::Color(), m_allBlocks, m_block, m_stack, PushBlock(), SgIncrementalStack::PushInt(), SgIncrementalStack::PushPtr(), RegionsAt(), SG_ASSERT, SG_UNUSED(), GoBoard::Size(), and GoBlock::Stones().
Referenced by MergeAdjacentAndAddBlock(), OnUndoneMove(), and UpdateBlock().
void GoRegionBoard::RemoveRegion | ( | GoRegion * | r, | |
bool | isExecute = true | |||
) | [private] |
remove region from GoRegionBoard
Definition at line 315 of file GoRegionBoard.cpp.
References GoRegion::Blocks(), GoRegion::Color(), m_allRegions, m_region, GoRegion::Points(), PushRegion(), SG_ASSERT, and SG_UNUSED().
Referenced by MergeAll(), OnExecutedUncodedMove(), and OnUndoneMove().
void GoRegionBoard::SetComputedFlagForAll | ( | GoRegionFlag | flag | ) |
mark all regions that the given attribute has been computed
Definition at line 749 of file GoRegionBoard.cpp.
References AllRegions().
Referenced by GoStaticSafetySolver::FindSafePoints().
void GoRegionBoard::SetComputedHealthy | ( | ) |
Set m_computedHealthy flag to true.
Definition at line 760 of file GoRegionBoard.cpp.
References m_computedHealthy.
Referenced by GoStaticSafetySolver::FindHealthy().
void GoRegionBoard::SetRegionArrays | ( | GoRegion * | r | ) | [private] |
Sets m_region elements to point to r.
Definition at line 338 of file GoRegionBoard.cpp.
References GoRegion::Color(), m_region, and GoRegion::Points().
Referenced by AddRegion().
void GoRegionBoard::SetSafeFlags | ( | const SgBWSet & | safe | ) |
Set safe flags for all blocks in safe.
Definition at line 53 of file GoRegionBoard.cpp.
References AllBlocks(), and AllRegions().
Referenced by GoSafetySolver::FindSafePair(), GoSafetySolver::FindSurroundedSafeAreas(), and GoSafetySolver::FindSurroundedSingleRegion().
void GoRegionBoard::SetToSafe | ( | SgPoint | p | ) | const |
Set safe flag for block at p.
Definition at line 42 of file GoRegionBoard.cpp.
References BlockAt(), and GoBlock::SetToSafe().
void GoRegionBoard::UpdateBlock | ( | int | move, | |
SgBlackWhite | moveColor | |||
) | [private] |
incremental update of block after move
Definition at line 130 of file GoRegionBoard.cpp.
References GoBoard::Anchor(), AppendStone(), BlockAt(), Board(), SgPointSet::Border(), SgVectorOf< T >::Front(), GenBlock(), SgVectorOf< T >::Include(), IsColor(), SgVectorOf< T >::IsLength(), RegionsAt(), RemoveBlock(), GoBoard::Size(), and GoBlock::Stones().
Referenced by OnExecutedUncodedMove().
bool GoRegionBoard::UpToDate | ( | ) | const |
Have blocks and regions been computed for current board position?
Definition at line 46 of file GoRegionBoard.h.
References Board(), GoBoard::GetHashCode(), m_board, m_boardSize, m_code, m_invalid, and GoBoard::Size().
Referenced by ChainsUpToDate(), CheckConsistency(), ExecuteMovePrologue(), GenBlocksRegions(), GetBlock(), RegionAt(), ReInitializeBlocksRegions(), and GoStaticSafetySolver::UpToDate().
void GoRegionBoard::WriteBlocks | ( | std::ostream & | stream | ) | const |
write information on all GoBlock's
Definition at line 689 of file GoRegionBoard.cpp.
References AllBlocks().
void GoRegionBoard::WriteRegions | ( | std::ostream & | stream | ) | const |
write information on all GoRegion's
Definition at line 699 of file GoRegionBoard.cpp.
References AllRegions().
SgBWArray<SgVectorOf<GoBlock> > GoRegionBoard::m_allBlocks [private] |
All blocks on board.
Definition at line 290 of file GoRegionBoard.h.
Referenced by AllBlocks(), Clear(), and RemoveBlock().
SgBWArray<SgVectorOf<GoChain> > GoRegionBoard::m_allChains [private] |
All chains on board.
Definition at line 293 of file GoRegionBoard.h.
Referenced by AllChains(), and Clear().
SgBWArray<SgVectorOf<GoRegion> > GoRegionBoard::m_allRegions [private] |
All regions on board.
Definition at line 296 of file GoRegionBoard.h.
Referenced by AllRegions(), Clear(), and RemoveRegion().
SgPointArray<GoBlock*> GoRegionBoard::m_block [private] |
pointer from stone to block, 0 if empty point
Definition at line 287 of file GoRegionBoard.h.
Referenced by AddBlock(), AppendStone(), BlockAt(), CheckConsistency(), Clear(), OnUndoneMove(), PreviousBlocksAt(), and RemoveBlock().
const GoBoard& GoRegionBoard::m_board [private] |
Definition at line 281 of file GoRegionBoard.h.
Referenced by Board(), Clear(), and UpToDate().
int GoRegionBoard::m_boardSize [private] |
Boardsize is needed to avoid problems with resizing an empty board.
Definition at line 313 of file GoRegionBoard.h.
Referenced by Clear(), and UpToDate().
SgHashCode GoRegionBoard::m_chainsCode [private] |
Code for last time chain information was computed.
Definition at line 302 of file GoRegionBoard.h.
Referenced by ChainsUpToDate(), GenChains(), and GoRegionBoard().
SgHashCode GoRegionBoard::m_code [private] |
Code for last time block and region information was computed.
Definition at line 299 of file GoRegionBoard.h.
Referenced by Clear(), GenBlocksRegions(), GoRegionBoard(), OnExecutedUncodedMove(), OnUndoneMove(), and UpToDate().
bool GoRegionBoard::m_computedHealthy [private] |
has healthy count been computed for all blocks?
Definition at line 310 of file GoRegionBoard.h.
Referenced by Clear(), ComputedHealthy(), and SetComputedHealthy().
bool GoRegionBoard::m_invalid [private] |
does block and region data match current board?
Definition at line 305 of file GoRegionBoard.h.
Referenced by Clear(), GenBlocksRegions(), and UpToDate().
SgBWArray<SgPointArray<GoRegion*> > GoRegionBoard::m_region [private] |
pointer to region, defined only at anchor of region
Definition at line 284 of file GoRegionBoard.h.
Referenced by CheckConsistency(), Clear(), OnUndoneMove(), PreviousRegionAt(), PushStone(), RegionAt(), RemoveRegion(), and SetRegionArrays().
SgIncrementalStack GoRegionBoard::m_stack [private] |
stores incremental state changes for execute/undo moves
Definition at line 265 of file GoRegionBoard.h.
Referenced by AppendStone(), Clear(), OnExecutedUncodedMove(), OnUndoneMove(), PushBlock(), PushRegion(), PushStone(), and RemoveBlock().
int GoRegionBoard::s_alloc = 0 [static, private] |
debugging bookkeeping.
Definition at line 316 of file GoRegionBoard.h.
Referenced by Fini(), and GoRegionBoard().
int GoRegionBoard::s_free = 0 [static, private] |
Definition at line 316 of file GoRegionBoard.h.
Referenced by Fini(), and ~GoRegionBoard().