A block augmented by a list of its healthy regions. More...
#include <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 SgPointSet & | Stones () 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< GoRegion > | m_healthy |
| list of healthy regions | |
| bool | m_has1Eye |
| does block have one eye? | |
| const GoBoard & | m_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 |
A block augmented by a list of its healthy regions.
Used together with GoRegion in GoRegionBoard.
Definition at line 24 of file GoBlock.h.
| GoBlock::GoBlock | ( | SgBlackWhite | color, | |
| SgPoint | anchor, | |||
| const GoBoard & | board | |||
| ) |
| virtual GoBlock::~GoBlock | ( | ) | [virtual] |
| 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.
| 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 |
The unique stone with smallest number identifying a block.
Definition at line 63 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 66 of file GoBlock.cpp.
References GoBoard::All(), GoBoard::Anchor(), Anchor(), Color(), m_bd, SG_ASSERT, and Stones().
| SgBlackWhite GoBlock::Color | ( | ) | const |
Definition at line 57 of file GoBlock.h.
References m_color.
Referenced by GoRegionBoard::AddBlock(), CheckConsistency(), GoChain::GetBlocks(), GoRegion::IsInteriorBlock(), GoSafetySolver::Merge(), GoRegionBoard::RemoveBlock(), GoRegion::ReplaceChain(), GoStaticSafetySolver::TestAlive(), GoChain::TestFor1Eye(), GoChain::WriteID(), and WriteID().
| 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] |
| bool GoBlock::Has1Eye | ( | ) | const |
| 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
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] |
| 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 |
set of all stones
Definition at line 69 of file GoBlock.h.
References m_stones.
Referenced by CheckConsistency(), GoRegion::Find2ConnForAll(), GoChain::GetBlocks(), GoRegion::ProtectedCuts(), GoRegionBoard::RemoveBlock(), GoRegion::Safe2Cuts(), GoRegionBoard::UpdateBlock(), 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 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] |
SgPoint GoBlock::m_anchor [private] |
Anchor.
Definition at line 201 of file GoBlock.h.
Referenced by AddStone(), Anchor(), HasLiberty(), NuLiberties(), and RemoveStone().
const GoBoard& GoBlock::m_bd [protected] |
board
Definition at line 175 of file GoBlock.h.
Referenced by AddStone(), GoChain::AllEmptyAreLiberties(), AllEmptyAreLiberties(), CheckConsistency(), HasLiberty(), Liberties(), NuLiberties(), and RemoveStone().
SgBlackWhite GoBlock::m_color [private] |
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().
SgVectorOf<GoRegion> GoBlock::m_healthy [protected] |
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().
SgPointSet GoBlock::m_stones [private] |
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] |
int GoBlock::s_free = 0 [static, private] |
Reimplemented in GoChain.
Definition at line 207 of file GoBlock.h.
Referenced by Fini(), and ~GoBlock().