Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoChain Class Reference

#include <GoChain.h>

Inheritance diagram for GoChain:

Inheritance graph
[legend]
List of all members.

Detailed Description

Set of GoBlock's that are a connected unit.

Definition at line 98 of file GoChain.h.

Public Member Functions

 GoChain (const GoBlock *b, const GoBoard &board)
 Constructor from single block.
 GoChain (const GoChain *c1, const GoChain *c2, GoChainCondition *cond)
 Constructor by merging two chains.
virtual ~GoChain ()
 Destructor.
void CheckConsistency (const GoBoard &bd) const
 For debugging.
void Write (std::ostream &out) const
 Write data of chain.
void WriteID (std::ostream &out) const
 Write short identifier.
virtual bool AllEmptyAreLiberties (const SgPointSet &area) const
 are all empty points in area liberties of this?
bool IsSingleBlock () const
 Does the chain consist of a single block, or more than one?
void TestFor1Eye (const GoRegionBoard *ra)
 does chain have one eye? Uses blocks' eyes and 1vc regions
const SgPointSetFreeLiberties () const
 Free liberties are liberties not used to define chains.
const SgVectorOf< GoChainCondition > & ChainConditions () const
 See m_chainConditions.
void GetBlocks (const GoRegionBoard *ra, SgVectorOf< GoBlock > *blocks) const
 returns list of all blocks in chain
void CheckConsistency () const
 For debugging.
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?
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 Attributes

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

Private Member Functions

void FreeChainConditions ()

Private Attributes

bool m_isSingleBlock
 Does the chain consist of a single block, or more than one?
SgPointSet m_freeLiberties
 Free liberties are liberties not used to define chains.
SgVectorOf< GoChainConditionm_chainConditions
 All conditions used to create chain.

Static Private Attributes

static int s_alloc = 0
 Used for debugging only.
static int s_free = 0


Constructor & Destructor Documentation

GoChain::GoChain ( const GoBlock b,
const GoBoard board 
)

Constructor from single block.

Definition at line 103 of file GoChain.h.

References GoBlock::IsSafe(), s_alloc, and GoBlock::SetToSafe().

GoChain::GoChain ( const GoChain c1,
const GoChain c2,
GoChainCondition cond 
)

Constructor by merging two chains.

Definition at line 18 of file GoChain.cpp.

References SgPointSet::Contains(), SgPointSet::Exclude(), GoBlock::Healthy(), m_chainConditions, m_freeLiberties, GoBlock::m_healthy, GoChainCondition::Overlaps(), SgVectorOf< T >::PushBack(), s_alloc, SG_ASSERT, and SgVectorOf< T >::Union().

virtual GoChain::~GoChain (  )  [virtual]

Destructor.

Definition at line 116 of file GoChain.h.

References FreeChainConditions(), and s_free.


Member Function Documentation

void GoBlock::AddHealthy ( GoRegion r  )  [inherited]

r is healthy for this

Definition at line 136 of file GoBlock.h.

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

void GoBlock::AddStone ( SgPoint  stone  )  [inherited]

For incremental computation: add stone to block.

Definition at line 25 of file GoBlock.cpp.

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

Referenced by GoRegionBoard::AppendStone().

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

are all empty points in area liberties of this?

Reimplemented from GoBlock.

Definition at line 78 of file GoChain.cpp.

References GoBoard::AllEmpty(), GoBlock::Liberties(), and GoBlock::m_bd.

SgPoint GoBlock::Anchor (  )  const [inherited]

The unique stone with smallest number identifying a block.

Definition at line 66 of file GoBlock.h.

References GoBlock::m_anchor.

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

const SgVectorOf<GoChainCondition>& GoChain::ChainConditions (  )  const

See m_chainConditions.

Definition at line 147 of file GoChain.h.

References m_chainConditions.

Referenced by Write().

void GoBlock::CheckConsistency (  )  const [inherited]

For debugging.

Definition at line 67 of file GoBlock.cpp.

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

void GoChain::CheckConsistency ( const GoBoard bd  )  const

For debugging.

SgBlackWhite GoBlock::Color (  )  const [inherited]

Definition at line 60 of file GoBlock.h.

References GoBlock::m_color.

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

bool GoBlock::ContainsHealthy ( const GoRegion r  )  const [inherited]

is r in our healthy list?

Definition at line 157 of file GoBlock.h.

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

void GoChain::Fini (  )  [static]

class Finalization

Reimplemented from GoBlock.

Definition at line 89 of file GoChain.cpp.

References s_alloc, s_free, and SG_ASSERT.

Referenced by GoRegion::Fini().

void GoChain::FreeChainConditions (  )  [private]

Definition at line 61 of file GoChain.cpp.

References SgVectorOf< T >::Clear(), and m_chainConditions.

Referenced by ~GoChain().

const SgPointSet& GoChain::FreeLiberties (  )  const

Free liberties are liberties not used to define chains.

Definition at line 144 of file GoChain.h.

References m_freeLiberties.

Referenced by GoRegion::Find2FreeLibs(), and GoRegion::Has2ConnForChains().

void GoChain::GetBlocks ( const GoRegionBoard ra,
SgVectorOf< GoBlock > *  blocks 
) const

returns list of all blocks in chain

Definition at line 68 of file GoChain.cpp.

References GoRegionBoard::AllBlocks(), GoBlock::Color(), SgPointSet::Contains(), SgVectorOf< T >::PushBack(), and GoBlock::Stones().

Referenced by TestFor1Eye().

bool GoBlock::Has1Eye (  )  const [inherited]

Does block have a simple eye?

Definition at line 107 of file GoBlock.h.

References GoBlock::m_has1Eye.

Referenced by GoBlock::Write().

bool GoBlock::HasLiberty ( SgPoint  lib  )  const [inherited]

is lib our liberty?

Definition at line 101 of file GoBlock.h.

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

const SgVectorOf<GoRegion>& GoBlock::Healthy (  )  const [inherited]

list of healthy regions

Definition at line 163 of file GoBlock.h.

References GoBlock::m_healthy.

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

bool GoBlock::IsSafe (  )  const [inherited]

is block proven safe?

Definition at line 92 of file GoBlock.h.

References GoBlock::m_isSafe.

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

bool GoChain::IsSingleBlock (  )  const

Does the chain consist of a single block, or more than one?

Definition at line 135 of file GoChain.h.

References m_isSingleBlock.

SgPointSet GoBlock::Liberties (  )  const [inherited]

set of all liberties

Todo:
slow

Definition at line 86 of file GoBlock.h.

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

Referenced by AllEmptyAreLiberties().

int GoBlock::NuLiberties (  )  const [inherited]

number of liberties

Definition at line 78 of file GoBlock.h.

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

virtual void GoBlock::ReInitialize (  )  [virtual, inherited]

Clear previous computation.

Definition at line 122 of file GoBlock.h.

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

void GoBlock::RemoveRegion ( GoRegion r  )  [inherited]

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

Definition at line 150 of file GoBlock.h.

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

void GoBlock::RemoveStone ( SgPoint  stone  )  [inherited]

For undo: remove added stone.

Definition at line 38 of file GoBlock.cpp.

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

Referenced by GoRegionBoard::OnUndoneMove().

void GoBlock::SetToSafe (  )  [inherited]

Mark block as proven safe.

Definition at line 113 of file GoBlock.h.

References GoBlock::m_isSafe.

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

const SgPointSet& GoBlock::Stones (  )  const [inherited]

set of all stones

Definition at line 72 of file GoBlock.h.

References GoBlock::m_stones.

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

void GoBlock::TestFor1Eye ( const GoRegion r  )  [inherited]

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 GoBlock::m_has1Eye.

void GoChain::TestFor1Eye ( const GoRegionBoard ra  ) 

does chain have one eye? Uses blocks' eyes and 1vc regions

Definition at line 40 of file GoChain.cpp.

References GoRegionBoard::AllRegions(), GoBlock::Color(), GetBlocks(), GO_REGION_1VC, and GoBlock::m_has1Eye.

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

Write data of chain.

Reimplemented from GoBlock.

Definition at line 94 of file GoChain.cpp.

References ChainConditions(), and GoBlock::Write().

Referenced by operator<<().

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

Write short identifier.

Reimplemented from GoBlock.

Definition at line 83 of file GoChain.cpp.

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


Member Data Documentation

const GoBoard& GoBlock::m_bd [protected, inherited]

board

Definition at line 179 of file GoBlock.h.

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

SgVectorOf<GoChainCondition> GoChain::m_chainConditions [private]

All conditions used to create chain.

Definition at line 169 of file GoChain.h.

Referenced by ChainConditions(), FreeChainConditions(), and GoChain().

SgPointSet GoChain::m_freeLiberties [private]

Free liberties are liberties not used to define chains.

Definition at line 166 of file GoChain.h.

Referenced by FreeLiberties(), and GoChain().

bool GoBlock::m_has1Eye [protected, inherited]

does block have one eye?

Definition at line 176 of file GoBlock.h.

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

SgVectorOf<GoRegion> GoBlock::m_healthy [protected, inherited]

list of healthy regions

Definition at line 173 of file GoBlock.h.

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

bool GoChain::m_isSingleBlock [private]

Does the chain consist of a single block, or more than one?

Definition at line 163 of file GoChain.h.

Referenced by IsSingleBlock().

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

Used for debugging only.

Reimplemented from GoBlock.

Definition at line 172 of file GoChain.h.

Referenced by Fini(), and GoChain().

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

Reimplemented from GoBlock.

Definition at line 172 of file GoChain.h.

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


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


17 Jun 2010 Doxygen 1.4.7