Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoRegionBoard Class Reference

#include <GoRegionBoard.h>

List of all members.


Detailed Description

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 31 of file 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 SgPointSetAll (SgBlackWhite color) const
 See GoBoard::All.
const SgPointSetAllEmpty () const
 See GoBoard::AllEmpty.
const SgPointSetAllPoints () 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 GoBoardBoard () const
GoBlockGetBlock (const SgPointSet &boundary, SgBlackWhite color) const
 Searches the list of all blocks for the block.
GoRegionPreviousRegionAt (SgPoint p, SgBlackWhite color) const
 For incremental update, region where stone was just played.
GoRegionRegionAt (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.
GoBlockBlockAt (SgPoint p) const
 GoBlock at point p.
GoChainChainAt (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.
GoBlockGenBlock (SgPoint anchor, SgBlackWhite color)
 Generate the block with given anchor.
GoRegionGenRegion (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.
GoRegionMergeAll (const SgVectorOf< GoRegion > &regions, 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 GoBoardm_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


Constructor & Destructor Documentation

GoRegionBoard::GoRegionBoard ( const GoBoard board  )  [explicit]

Constructor.

Definition at line 70 of file GoRegionBoard.cpp.

References GenBlocksRegions(), SgHash< N >::Invalidate(), m_chainsCode, m_code, and s_alloc.

GoRegionBoard::~GoRegionBoard (  )  [virtual]

release memory.

Calls Clear()

Definition at line 84 of file GoRegionBoard.cpp.

References Clear(), and s_free.


Member Function Documentation

void GoRegionBoard::AddBlock ( GoBlock b,
bool  isExecute = true 
) [private]

add block to GoRegionBoard

Definition at line 382 of file GoRegionBoard.cpp.

References AllBlocks(), GoBlock::Anchor(), Board(), GoBlock::Color(), m_block, SgVectorOf< T >::PushBack(), PushBlock(), and REGION_ADD_BLOCK.

Referenced by GenBlock(), and OnUndoneMove().

void GoRegionBoard::AddRegion ( GoRegion r,
bool  isExecute = true 
) [private]

add region to GoRegionBoard

Definition at line 615 of file GoRegionBoard.cpp.

References AllRegions(), GoRegion::Color(), GoRegion::ComputeBasicFlags(), Contains(), GoRegion::FindBlocks(), HEAVYCHECK, SgVectorOf< T >::PushBack(), PushRegion(), REGION_ADD, 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 450 of file GoRegionBoard.cpp.

References AllRegions(), and SgVectorOf< T >::PushBack().

const SgPointSet& GoRegionBoard::All ( SgBlackWhite  color  )  const

See GoBoard::All.

Definition at line 119 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 89 of file GoRegionBoard.h.

References m_allBlocks.

SgVectorOf<GoBlock>& GoRegionBoard::AllBlocks ( SgBlackWhite  color  ) 

All GoBlock's of given color.

Definition at line 83 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 101 of file GoRegionBoard.h.

References m_allChains.

SgVectorOf<GoChain>& GoRegionBoard::AllChains ( SgBlackWhite  color  ) 

All GoChain's of given color.

Definition at line 95 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 125 of file GoRegionBoard.h.

References GoBoard::AllEmpty(), and Board().

const SgPointSet& GoRegionBoard::AllPoints (  )  const

See GoBoard::AllPoints.

Definition at line 128 of file GoRegionBoard.h.

References GoBoard::AllPoints(), and Board().

Referenced by CheckConsistency(), and GenBlocksRegions().

const SgVectorOf<GoRegion>& GoRegionBoard::AllRegions ( SgBlackWhite  color  )  const

All GoRegion's of given color.

Definition at line 113 of file GoRegionBoard.h.

References m_allRegions.

SgVectorOf<GoRegion>& GoRegionBoard::AllRegions ( SgBlackWhite  color  ) 

All GoRegion's of given color.

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

void GoRegionBoard::AppendStone ( GoBlock b,
SgPoint  move 
) [private]

add stome to b and push information on m_stack

Definition at line 169 of file GoRegionBoard.cpp.

References GoBlock::AddStone(), m_block, m_stack, SgIncrementalStack::PushInt(), SgIncrementalStack::PushPtrEvent(), and REGION_ADD_STONE_TO_BLOCK.

Referenced by UpdateBlock().

GoBlock* GoRegionBoard::BlockAt ( SgPoint  p  )  const

GoBlock at point p.

Definition at line 200 of file GoRegionBoard.h.

References m_block, and SG_ASSERT.

Referenced by IsSafeBlock(), SetToSafe(), and UpdateBlock().

const GoBoard& GoRegionBoard::Board (  )  const

Definition at line 155 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 * GoRegionBoard::ChainAt ( SgPoint  p  )  const

GoChain at point p.

Definition at line 731 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 61 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 254 of file GoRegionBoard.cpp.

References AllBlocks(), AllPoints(), AllRegions(), Board(), CHECK, Contains(), 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 90 of file GoRegionBoard.cpp.

References AllBlocks(), AllChains(), AllRegions(), SgIncrementalStack::Clear(), DEBUG_REGION_BOARD, 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 55 of file GoRegionBoard.h.

References m_computedHealthy.

void GoRegionBoard::ExecuteMovePrologue (  ) 

MUST call before playing move on GoBoard.

Definition at line 183 of file GoRegionBoard.cpp.

References DEBUG_REGION_BOARD, GenBlocksRegions(), SgDebug(), and UpToDate().

void GoRegionBoard::FindBlocksWithEye (  )  [private]

Set the m_has1Eye flag for all blocks with 1 eye.

Definition at line 634 of file GoRegionBoard.cpp.

References AllRegions().

Referenced by GenBlocksRegions().

void GoRegionBoard::Fini (  )  [static]

class finalization

Definition at line 48 of file GoRegionBoard.cpp.

References s_alloc, s_free, and SG_ASSERT.

Referenced by GoRegion::Fini().

GoBlock * GoRegionBoard::GenBlock ( SgPoint  anchor,
SgBlackWhite  color 
) [private]

Generate the block with given anchor.

Definition at line 392 of file GoRegionBoard.cpp.

References AddBlock(), and Board().

Referenced by GenBlocks(), and UpdateBlock().

void GoRegionBoard::GenBlocks (  )  [private]

Generate blocks.

Definition at line 744 of file GoRegionBoard.cpp.

References Board(), and GenBlock().

Referenced by GenBlocksRegions().

void GoRegionBoard::GenBlocksRegions (  ) 

generate all blocks and regions

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

Todo:
currently this only creates 1 chain for each block. The merging is only done in GoSafetySolver::GenBlocksRegions() and must be moved here.

Definition at line 672 of file GoRegionBoard.cpp.

References AllBlocks(), AllChains(), AllRegions(), Board(), ChainsUpToDate(), GoBoard::GetHashCode(), m_chainsCode, 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 607 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 710 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 131 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 38 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 474 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 459 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 178 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 193 of file GoRegionBoard.cpp.

References AllRegions(), Board(), CheckConsistency(), DEBUG_REGION_BOARD, GenRegion(), GoBoard::GetHashCode(), GO_MOVEFLAG_CAPTURING, GO_MOVEFLAG_SUICIDE, HEAVYCHECK, SgPointSet::IsEmpty(), GoEyeUtil::IsSplitPt(), 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 502 of file GoRegionBoard.cpp.

References AddBlock(), AddRegion(), AllRegions(), GoRegion::Blocks(), GoRegion::BlocksNonConst(), Board(), CHECK, CheckConsistency(), GoRegion::Color(), SgVectorOf< T >::Contains(), DEBUG_REGION_BOARD, GoBoard::GetHashCode(), HEAVYCHECK, SgVectorOf< T >::Insert(), m_block, m_code, m_region, m_stack, GoRegion::OnRemoveStone(), SgIncrementalStack::PopEvent(), SgIncrementalStack::PopInt(), SgIncrementalStack::PopPtr(), SgVectorOf< T >::PushBack(), REGION_ADD, REGION_ADD_BLOCK, REGION_ADD_STONE, REGION_ADD_STONE_TO_BLOCK, REGION_REMOVE, REGION_REMOVE_BLOCK, 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 400 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 167 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 304 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 299 of file GoRegionBoard.cpp.

References m_stack, and SgIncrementalStack::PushPtrEvent().

Referenced by AddRegion(), and RemoveRegion().

void GoRegionBoard::PushStone ( GoRegion r,
SgPoint  move 
) [private]

push on m_stack

Definition at line 309 of file GoRegionBoard.cpp.

References GoRegion::Color(), m_region, m_stack, SgIncrementalStack::PushInt(), SgIncrementalStack::PushPtrEvent(), and REGION_ADD_STONE.

Referenced by OnExecutedUncodedMove().

GoRegion* GoRegionBoard::RegionAt ( SgPoint  p,
SgBlackWhite  color 
) const

Region of color at point p.

Definition at line 175 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 442 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 593 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 349 of file GoRegionBoard.cpp.

References Board(), SgPointSet::Border(), GoBlock::Color(), m_allBlocks, m_block, m_stack, PushBlock(), SgIncrementalStack::PushInt(), SgIncrementalStack::PushPtr(), REGION_REMOVE_BLOCK, 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 316 of file GoRegionBoard.cpp.

References GoRegion::Blocks(), GoRegion::Color(), m_allRegions, m_region, GoRegion::Points(), PushRegion(), REGION_REMOVE, 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 750 of file GoRegionBoard.cpp.

References AllRegions().

Referenced by GoStaticSafetySolver::FindSafePoints().

void GoRegionBoard::SetComputedHealthy (  ) 

Set m_computedHealthy flag to true.

Definition at line 761 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 339 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 54 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 43 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 131 of file GoRegionBoard.cpp.

References GoBoard::Anchor(), AppendStone(), BlockAt(), Board(), SgVectorOf< T >::Front(), GenBlock(), SgVectorOf< T >::Include(), IsColor(), SgVectorOf< T >::IsLength(), RegionsAt(), RemoveBlock(), and GoBoard::Size().

Referenced by OnExecutedUncodedMove().

bool GoRegionBoard::UpToDate (  )  const

Have blocks and regions been computed for current board position?

Definition at line 48 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 690 of file GoRegionBoard.cpp.

References AllBlocks().

void GoRegionBoard::WriteRegions ( std::ostream &  stream  )  const

write information on all GoRegion's

Definition at line 700 of file GoRegionBoard.cpp.

References AllRegions().


Member Data Documentation

SgBWArray<SgVectorOf<GoBlock> > GoRegionBoard::m_allBlocks [private]

All blocks on board.

Definition at line 298 of file GoRegionBoard.h.

Referenced by AllBlocks(), Clear(), and RemoveBlock().

SgBWArray<SgVectorOf<GoChain> > GoRegionBoard::m_allChains [private]

All chains on board.

Definition at line 301 of file GoRegionBoard.h.

Referenced by AllChains(), and Clear().

SgBWArray<SgVectorOf<GoRegion> > GoRegionBoard::m_allRegions [private]

All regions on board.

Definition at line 304 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 295 of file GoRegionBoard.h.

Referenced by AddBlock(), AppendStone(), BlockAt(), CheckConsistency(), Clear(), OnUndoneMove(), PreviousBlocksAt(), and RemoveBlock().

const GoBoard& GoRegionBoard::m_board [private]

Definition at line 289 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 322 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 310 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 307 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?

Todo:
in fully incremental mode, this should be determined locally for each block, not globally.

Definition at line 319 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 313 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 292 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 273 of file GoRegionBoard.h.

Referenced by AppendStone(), Clear(), OnExecutedUncodedMove(), OnUndoneMove(), PushBlock(), PushRegion(), PushStone(), and RemoveBlock().

int GoRegionBoard::s_alloc = 0 [static, private]

debugging bookkeeping.

Todo:
do it in debug only

Definition at line 325 of file GoRegionBoard.h.

Referenced by Fini(), and GoRegionBoard().

int GoRegionBoard::s_free = 0 [static, private]

Definition at line 325 of file GoRegionBoard.h.

Referenced by Fini(), and ~GoRegionBoard().


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


17 Jun 2010 Doxygen 1.4.7