Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoBlock Class Reference

#include <GoBlock.h>

Inheritance diagram for GoBlock:

Inheritance graph
[legend]
List of all members.

Detailed Description

A block augmented by a list of its healthy regions.

Used together with GoRegion in GoRegionBoard.

Todo:
Avoid cyclic dependency with GoBlock

Definition at line 26 of file GoBlock.h.

Public Member Functions

 GoBlock (SgBlackWhite color, SgPoint anchor, const GoBoard &board)
 GoBlock Constructor Parameters: color: color of block anchor: stone identifying block board: the board we are on.
virtual ~GoBlock ()
 Destructor.
void CheckConsistency () const
 For debugging.
virtual void Write (std::ostream &out) const
 Write data for block.
virtual void WriteID (std::ostream &out) const
 Write short identifier for block.
SgBlackWhite Color () const
SgPoint Anchor () const
 The unique stone with smallest number identifying a block.
const SgPointSetStones () const
 set of all stones
int NuLiberties () const
 number of liberties
SgPointSet Liberties () const
 set of all liberties
bool IsSafe () const
 is block proven safe?
virtual bool AllEmptyAreLiberties (const SgPointSet &area) const
 Are all empty points in area our liberties?
bool HasLiberty (SgPoint lib) const
 is lib our liberty?
bool Has1Eye () const
 Does block have a simple eye?
void SetToSafe ()
 Mark block as proven safe.
void TestFor1Eye (const GoRegion *r)
 compute if block has 1 clear eye, if yes set the m_has1Eye flag
virtual void ReInitialize ()
 Clear previous computation.
void AddStone (SgPoint stone)
 For incremental computation: add stone to block.
void RemoveStone (SgPoint stone)
 For undo: remove added stone.
void AddHealthy (GoRegion *r)
 r is healthy for this
void RemoveRegion (GoRegion *r)
 For incremental computation: r is no longer a neighbor region.
bool ContainsHealthy (const GoRegion *r) const
 is r in our healthy list?
const SgVectorOf< GoRegion > & Healthy () const
 list of healthy regions

Static Public Member Functions

static void Fini ()
 class finalization

Protected Member Functions

 GoBlock (const GoBlock *b, const SgPointSet &stones, const SgVectorOf< GoRegion > &healthy)
 This constructor used only in GoChain constructor Stones is set to the union of the merged chains.

Protected Attributes

SgVectorOf< GoRegionm_healthy
 list of healthy regions
bool m_has1Eye
 does block have one eye?
const GoBoardm_bd
 board

Private Attributes

SgBlackWhite m_color
 Color of block.
SgPointSet m_stones
 Stones of block.
SgPoint m_anchor
 Anchor.
bool m_isSafe
 Is block marked as safe?

Static Private Attributes

static int s_alloc = 0
 Bookkeeping for debugging.
static int s_free = 0


Constructor & Destructor Documentation

GoBlock::GoBlock ( SgBlackWhite  color,
SgPoint  anchor,
const GoBoard board 
)

GoBlock Constructor Parameters: color: color of block anchor: stone identifying block board: the board we are on.

Definition at line 35 of file GoBlock.h.

References SgPointSet::Include(), m_stones, and s_alloc.

virtual GoBlock::~GoBlock (  )  [virtual]

Destructor.

Definition at line 48 of file GoBlock.h.

References s_free.

GoBlock::GoBlock ( const GoBlock b,
const SgPointSet stones,
const SgVectorOf< GoRegion > &  healthy 
) [protected]

This constructor used only in GoChain constructor Stones is set to the union of the merged chains.

Definition at line 184 of file GoBlock.h.

References s_alloc.


Member Function Documentation

void GoBlock::AddHealthy ( GoRegion r  ) 

r is healthy for this

Definition at line 136 of file GoBlock.h.

References SgVectorOf< T >::Contains(), m_healthy, SgVectorOf< T >::PushBack(), and SgDebug().

void GoBlock::AddStone ( SgPoint  stone  ) 

For incremental computation: add stone to block.

Definition at line 25 of file GoBlock.cpp.

References GoBoard::Anchor(), SgPointSet::Contains(), HEAVYCHECK, SgPointSet::Include(), m_anchor, m_bd, m_stones, and SG_ASSERT.

Referenced by GoRegionBoard::AppendStone().

bool GoBlock::AllEmptyAreLiberties ( const SgPointSet area  )  const [virtual]

Are all empty points in area our liberties?

Reimplemented in GoChain.

Definition at line 47 of file GoBlock.cpp.

References Anchor(), GoBoard::IsEmpty(), GoBoard::IsLibertyOfBlock(), and m_bd.

Referenced by GoStaticSafetySolver::RegionHealthyForBlock().

SgPoint GoBlock::Anchor (  )  const

The unique stone with smallest number identifying a block.

Definition at line 66 of file GoBlock.h.

References m_anchor.

Referenced by GoRegionBoard::AddBlock(), AllEmptyAreLiberties(), CheckConsistency(), GoRegion::HasBlockLibs(), GoRegion::HasLibsForBlock(), GoRegion::InsideLibs(), GoRegion::IsInteriorBlock(), GoRegion::JointLibs(), GoChain::WriteID(), and WriteID().

void GoBlock::CheckConsistency (  )  const

For debugging.

Definition at line 67 of file GoBlock.cpp.

References GoBoard::All(), GoBoard::Anchor(), Anchor(), Color(), m_bd, SG_ASSERT, and Stones().

SgBlackWhite GoBlock::Color (  )  const

Definition at line 60 of file GoBlock.h.

References m_color.

Referenced by GoRegionBoard::AddBlock(), CheckConsistency(), GoChain::GetBlocks(), GoRegion::IsInteriorBlock(), GoSafetySolver::Merge(), GoRegionBoard::RemoveBlock(), GoRegion::ReplaceChain(), GoChain::TestFor1Eye(), GoChain::WriteID(), and WriteID().

bool GoBlock::ContainsHealthy ( const GoRegion r  )  const

is r in our healthy list?

Definition at line 157 of file GoBlock.h.

References SgVectorOf< T >::Contains(), and m_healthy.

void GoBlock::Fini (  )  [static]

class finalization

Reimplemented in GoChain.

Definition at line 78 of file GoBlock.cpp.

References s_alloc, s_free, and SG_ASSERT.

Referenced by GoRegion::Fini().

bool GoBlock::Has1Eye (  )  const

Does block have a simple eye?

Definition at line 107 of file GoBlock.h.

References m_has1Eye.

Referenced by Write().

bool GoBlock::HasLiberty ( SgPoint  lib  )  const

is lib our liberty?

Definition at line 101 of file GoBlock.h.

References GoBoard::IsLibertyOfBlock(), m_anchor, and m_bd.

const SgVectorOf<GoRegion>& GoBlock::Healthy (  )  const

list of healthy regions

Definition at line 163 of file GoBlock.h.

References m_healthy.

Referenced by GoChain::GoChain(), and Write().

bool GoBlock::IsSafe (  )  const

is block proven safe?

Definition at line 92 of file GoBlock.h.

References m_isSafe.

Referenced by GoChain::GoChain(), GoRegionBoard::IsSafeBlock(), and Write().

SgPointSet GoBlock::Liberties (  )  const

set of all liberties

Todo:
slow

Definition at line 86 of file GoBlock.h.

References GoBoard::AllEmpty(), SgPointSet::Border(), m_bd, m_stones, and GoBoard::Size().

Referenced by GoChain::AllEmptyAreLiberties().

int GoBlock::NuLiberties (  )  const

number of liberties

Definition at line 78 of file GoBlock.h.

References m_anchor, m_bd, and GoBoard::NumLiberties().

virtual void GoBlock::ReInitialize (  )  [virtual]

Clear previous computation.

Definition at line 122 of file GoBlock.h.

References SgVectorOf< T >::Clear(), m_has1Eye, m_healthy, and m_isSafe.

void GoBlock::RemoveRegion ( GoRegion r  ) 

For incremental computation: r is no longer a neighbor region.

Definition at line 150 of file GoBlock.h.

References SgVectorOf< T >::Exclude(), and m_healthy.

void GoBlock::RemoveStone ( SgPoint  stone  ) 

For undo: remove added stone.

Definition at line 38 of file GoBlock.cpp.

References GoBoard::Anchor(), SgPointSet::Contains(), SgPointSet::Exclude(), HEAVYCHECK, m_anchor, m_bd, m_stones, SgPointSet::PointOf(), and SG_ASSERT.

Referenced by GoRegionBoard::OnUndoneMove().

void GoBlock::SetToSafe (  ) 

Mark block as proven safe.

Definition at line 113 of file GoBlock.h.

References m_isSafe.

Referenced by GoChain::GoChain(), and GoRegionBoard::SetToSafe().

const SgPointSet& GoBlock::Stones (  )  const

set of all stones

Definition at line 72 of file GoBlock.h.

References m_stones.

Referenced by CheckConsistency(), GoRegion::Find2ConnForAll(), GoChain::GetBlocks(), GoRegion::ProtectedCuts(), GoRegionBoard::RemoveBlock(), GoRegion::Safe2Cuts(), and Write().

void GoBlock::TestFor1Eye ( const GoRegion r  ) 

compute if block has 1 clear eye, if yes set the m_has1Eye flag

Definition at line 58 of file GoBlock.cpp.

References GoRegion::Blocks(), GoRegion::GetFlag(), GO_REGION_SMALL, SgVectorOf< T >::IsLength(), and m_has1Eye.

void GoBlock::Write ( std::ostream &  out  )  const [virtual]

Write data for block.

Reimplemented in GoChain.

Definition at line 83 of file GoBlock.cpp.

References Has1Eye(), Healthy(), IsSafe(), SgVectorOf< T >::Length(), Stones(), and WriteID().

Referenced by operator<<(), and GoChain::Write().

void GoBlock::WriteID ( std::ostream &  out  )  const [virtual]

Write short identifier for block.

Reimplemented in GoChain.

Definition at line 94 of file GoBlock.cpp.

References Anchor(), Color(), and SgBW().

Referenced by Write().


Member Data Documentation

SgPoint GoBlock::m_anchor [private]

Anchor.

Definition at line 206 of file GoBlock.h.

Referenced by AddStone(), Anchor(), HasLiberty(), NuLiberties(), and RemoveStone().

const GoBoard& GoBlock::m_bd [protected]

board

Definition at line 179 of file GoBlock.h.

Referenced by AddStone(), GoChain::AllEmptyAreLiberties(), AllEmptyAreLiberties(), CheckConsistency(), HasLiberty(), Liberties(), NuLiberties(), and RemoveStone().

SgBlackWhite GoBlock::m_color [private]

Color of block.

Definition at line 200 of file GoBlock.h.

Referenced by Color().

bool GoBlock::m_has1Eye [protected]

does block have one eye?

Definition at line 176 of file GoBlock.h.

Referenced by Has1Eye(), ReInitialize(), GoChain::TestFor1Eye(), and TestFor1Eye().

SgVectorOf<GoRegion> GoBlock::m_healthy [protected]

list of healthy regions

Definition at line 173 of file GoBlock.h.

Referenced by AddHealthy(), ContainsHealthy(), GoChain::GoChain(), Healthy(), ReInitialize(), and RemoveRegion().

bool GoBlock::m_isSafe [private]

Is block marked as safe?

Definition at line 209 of file GoBlock.h.

Referenced by IsSafe(), ReInitialize(), and SetToSafe().

SgPointSet GoBlock::m_stones [private]

Stones of block.

Definition at line 203 of file GoBlock.h.

Referenced by AddStone(), GoBlock(), Liberties(), RemoveStone(), and Stones().

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

Bookkeeping for debugging.

Reimplemented in GoChain.

Definition at line 212 of file GoBlock.h.

Referenced by Fini(), and GoBlock().

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

Reimplemented in GoChain.

Definition at line 212 of file GoBlock.h.

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


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


17 Jun 2010 Doxygen 1.4.7