Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes

GoBlock Class Reference

A block augmented by a list of its healthy regions. More...

#include <GoBlock.h>

Inheritance diagram for GoBlock:
Inheritance graph
[legend]

List of all members.

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

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 24 of file GoBlock.h.


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 32 of file GoBlock.h.

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

virtual GoBlock::~GoBlock (  )  [virtual]

Destructor.

Definition at line 45 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 179 of file GoBlock.h.

References s_alloc, and SG_NULLPOINT.


Member Function Documentation

void GoBlock::AddHealthy ( GoRegion r  ) 

r is healthy for this

Definition at line 132 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 24 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 46 of file GoBlock.cpp.

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

Referenced by GoStaticSafetySolver::RegionHealthyForBlock().

SgPoint GoBlock::Anchor (  )  const
void GoBlock::CheckConsistency (  )  const

For debugging.

Definition at line 66 of file GoBlock.cpp.

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

SgBlackWhite GoBlock::Color (  )  const
bool GoBlock::ContainsHealthy ( const GoRegion r  )  const

is r in our healthy list?

Definition at line 153 of file GoBlock.h.

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

void GoBlock::Fini (  )  [static]

class finalization

Reimplemented in GoChain.

Definition at line 77 of file GoBlock.cpp.

References s_alloc, s_free, and SG_ASSERT.

bool GoBlock::Has1Eye (  )  const

Does block have a simple eye?

Definition at line 103 of file GoBlock.h.

References m_has1Eye.

Referenced by Write().

bool GoBlock::HasLiberty ( SgPoint  lib  )  const

is lib our liberty?

Definition at line 97 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 159 of file GoBlock.h.

References m_healthy.

Referenced by GoStaticSafetySolver::FindClosure(), GoSafetySolver::FindClosure(), GoChain::GoChain(), and Write().

bool GoBlock::IsSafe (  )  const

is block proven safe?

Definition at line 88 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 82 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 75 of file GoBlock.h.

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

virtual void GoBlock::ReInitialize (  )  [virtual]

Clear previous computation.

Definition at line 118 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 146 of file GoBlock.h.

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

void GoBlock::RemoveStone ( SgPoint  stone  ) 

For undo: remove added stone.

Definition at line 37 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 109 of file GoBlock.h.

References m_isSafe.

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

const SgPointSet& GoBlock::Stones (  )  const
void GoBlock::TestFor1Eye ( const GoRegion r  ) 

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

Definition at line 57 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 82 of file GoBlock.cpp.

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

Referenced by operator<<().

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

Write short identifier for block.

Reimplemented in GoChain.

Definition at line 93 of file GoBlock.cpp.

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

Referenced by Write().


Member Data Documentation

Anchor.

Definition at line 201 of file GoBlock.h.

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

const GoBoard& GoBlock::m_bd [protected]

Color of block.

Definition at line 195 of file GoBlock.h.

Referenced by Color().

bool GoBlock::m_has1Eye [protected]

does block have one eye?

Definition at line 172 of file GoBlock.h.

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

list of healthy regions

Definition at line 169 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 204 of file GoBlock.h.

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

Stones of block.

Definition at line 198 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 207 of file GoBlock.h.

Referenced by Fini(), and GoBlock().

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

Reimplemented in GoChain.

Definition at line 207 of file GoBlock.h.

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


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


Sun Mar 13 2011 Doxygen 1.7.1