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

GoSafetySolver Class Reference

Improved static detection of safe blocks and regions Uses static rules to find 1-vital, 2-vital and safely surrounded areas. More...

#include <GoSafetySolver.h>

Inheritance diagram for GoSafetySolver:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 GoSafetySolver (GoBoard &board, GoRegionBoard *regions=0)
 Constructor,.
void FindSafePoints (SgBWSet *safe)
 Main function, compute safe points.
virtual void FindSurroundedSafeAreas (SgBWSet *safe, SgBlackWhite color)
 Find areas surrounded by safe blocks where the opponent cannot live.
virtual void FindHealthy ()
 call virtual RegionHealthyForBlock
virtual bool UpToDate () const
 Check if internal state matches board.
Accessors

const GoBoardBoard () const
 our board
Forwarding accessors for GoRegionBoard

const GoRegionBoardRegions () const
 our regions

Protected Member Functions

virtual bool RegionHealthyForBlock (const GoRegion &r, const GoBlock &b) const
 See GoStaticSafetySolver::RegionHealthyForBlock.
virtual void GenBlocksRegions ()
 Compute all GoBlock's, GoChain's and GoRegion's on m_board.
virtual void FindClosure (SgVectorOf< GoBlock > *blocks) const
 Like.
virtual void FindTestSets (SgVectorOf< SgVectorOf< GoBlock > > *sets, SgBlackWhite color) const
 Like.
virtual void Test2Vital (GoRegion *r, SgBWSet *safe)
 static test if r is 2-vital.
void Find2VitalAreas (SgBWSet *safe)
 call Test2Vital for regions, add 2-vital ones to safe set
bool FindSafePair (SgBWSet *safe, SgBlackWhite color, const SgPointSet &anySafe, const GoRegion *r1)
 try to find a safe pair of regions r1 + other, call AddToSafe()
void Merge (GoChain *c1, GoChain *c2, GoRegion *r, bool bySearch)
 create new chain representing both chains connected in this region
GoRegionBoardRegions ()
 our regions
void TestAlive (SgVectorOf< GoBlock > *blocks, SgBWSet *safe, SgBlackWhite color)
 Test if list of Benson blocks forms a living group.
void TestAdjacent (SgVectorOf< GoRegion > *regions, const SgVectorOf< GoBlock > &blocks) const
 Reduce regions: keep only if completely surrounded by blocks.

Private Member Functions

bool FindSurroundedRegionPair (SgBWSet *safe, SgBlackWhite color)
 find pairs of regions that are safe together.
bool FindSurroundedSingleRegion (SgBWSet *safe, SgBlackWhite color)
 Find new safe region.

Private Attributes

SgHashCode m_code
 for chain info

Detailed Description

Improved static detection of safe blocks and regions Uses static rules to find 1-vital, 2-vital and safely surrounded areas.

Definition at line 18 of file GoSafetySolver.h.


Constructor & Destructor Documentation

GoSafetySolver::GoSafetySolver ( GoBoard board,
GoRegionBoard regions = 0 
) [explicit]

Constructor,.

See also:
GoStaticSafetySolver

Definition at line 22 of file GoSafetySolver.h.

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


Member Function Documentation

const GoBoard & GoStaticSafetySolver::Board (  )  const [inherited]
void GoSafetySolver::Find2VitalAreas ( SgBWSet safe  )  [protected]

call Test2Vital for regions, add 2-vital ones to safe set

Definition at line 113 of file GoSafetySolver.cpp.

References SgBWSet::AssertDisjoint(), GoStaticSafetySolver::Regions(), SG_BLACK, SG_WHITE, and Test2Vital().

Referenced by FindSafePoints().

void GoSafetySolver::FindClosure ( SgVectorOf< GoBlock > *  blocks  )  const [protected, virtual]
void GoSafetySolver::FindHealthy (  )  [virtual]

call virtual RegionHealthyForBlock

Reimplemented from GoStaticSafetySolver.

Definition at line 32 of file GoSafetySolver.cpp.

References GoRegion::Chains(), GO_REGION_STATIC_1VITAL, RegionHealthyForBlock(), and GoStaticSafetySolver::Regions().

bool GoSafetySolver::FindSafePair ( SgBWSet safe,
SgBlackWhite  color,
const SgPointSet anySafe,
const GoRegion r1 
) [protected]
void GoSafetySolver::FindSafePoints ( SgBWSet safe  )  [virtual]
bool GoSafetySolver::FindSurroundedRegionPair ( SgBWSet safe,
SgBlackWhite  color 
) [private]
void GoSafetySolver::FindSurroundedSafeAreas ( SgBWSet safe,
SgBlackWhite  color 
) [virtual]

Find areas surrounded by safe blocks where the opponent cannot live.

Definition at line 131 of file GoSafetySolver.cpp.

References FindSurroundedRegionPair(), FindSurroundedSingleRegion(), GoStaticSafetySolver::Regions(), and GoRegionBoard::SetSafeFlags().

Referenced by FindSafePoints().

bool GoSafetySolver::FindSurroundedSingleRegion ( SgBWSet safe,
SgBlackWhite  color 
) [private]
void GoSafetySolver::FindTestSets ( SgVectorOf< SgVectorOf< GoBlock > > *  sets,
SgBlackWhite  color 
) const [protected, virtual]

Like.

See also:
GoStaticSafetySolver::FindTestSets, but uses GoChain's

Reimplemented from GoStaticSafetySolver.

Definition at line 77 of file GoSafetySolver.cpp.

References FindClosure(), SgVectorOf< T >::PushBack(), GoStaticSafetySolver::Regions(), and SG_ASSERT.

void GoSafetySolver::GenBlocksRegions (  )  [protected, virtual]
void GoSafetySolver::Merge ( GoChain c1,
GoChain c2,
GoRegion r,
bool  bySearch 
) [protected]
bool GoSafetySolver::RegionHealthyForBlock ( const GoRegion r,
const GoBlock b 
) const [protected, virtual]

See GoStaticSafetySolver::RegionHealthyForBlock.

This implementation uses 1-vital information

Reimplemented from GoStaticSafetySolver.

Definition at line 98 of file GoSafetySolver.cpp.

References GoRegion::GetFlag(), and GO_REGION_STATIC_1VITAL.

Referenced by FindHealthy().

const GoRegionBoard * GoStaticSafetySolver::Regions (  )  const [inherited]
GoRegionBoard * GoStaticSafetySolver::Regions (  )  [protected, inherited]

our regions

Definition at line 114 of file GoStaticSafetySolver.h.

References GoStaticSafetySolver::m_regions, and SG_ASSERT.

void GoSafetySolver::Test2Vital ( GoRegion r,
SgBWSet safe 
) [protected, virtual]

static test if r is 2-vital.

If yes add to safe set

Definition at line 106 of file GoSafetySolver.cpp.

References GoSafetyUtil::AddToSafe(), GoStaticSafetySolver::Board(), GoRegion::Color(), GoRegion::ComputeAndGetFlag(), GO_REGION_STATIC_2V, and GoRegion::Points().

Referenced by Find2VitalAreas().

void GoStaticSafetySolver::TestAdjacent ( SgVectorOf< GoRegion > *  regions,
const SgVectorOf< GoBlock > &  blocks 
) const [protected, inherited]

Reduce regions: keep only if completely surrounded by blocks.

Definition at line 81 of file GoStaticSafetySolver.cpp.

References SgVectorOf< T >::PushBack().

Referenced by GoStaticSafetySolver::TestAlive().

void GoStaticSafetySolver::TestAlive ( SgVectorOf< GoBlock > *  blocks,
SgBWSet safe,
SgBlackWhite  color 
) [protected, inherited]

Test if list of Benson blocks forms a living group.

Each block must have a sure liberty count of at least 2. A region provides one sure liberty if it is healthy and its boundary consists only of blocks in the list.

Definition at line 91 of file GoStaticSafetySolver.cpp.

References GoSafetyUtil::AddToSafe(), SgVectorOf< T >::Clear(), GoBlock::Color(), SgVectorOf< T >::Contains(), SgVectorOf< T >::Exclude(), SgVectorOf< T >::Front(), GoStaticSafetySolver::m_board, SgVectorOf< T >::MinLength(), SgVectorOf< T >::NonEmpty(), SgVectorOf< T >::PushBack(), GoStaticSafetySolver::Regions(), SG_ASSERT, SG_DEBUG_ONLY, and GoStaticSafetySolver::TestAdjacent().

Referenced by GoStaticSafetySolver::FindSafePoints().

virtual bool GoSafetySolver::UpToDate (  )  const [virtual]

Check if internal state matches board.

Reimplemented from GoStaticSafetySolver.

Definition at line 38 of file GoSafetySolver.h.

References GoStaticSafetySolver::Board(), GoBoard::GetHashCode(), and m_code.

Referenced by GenBlocksRegions().


Member Data Documentation

for chain info

Definition at line 84 of file GoSafetySolver.h.

Referenced by GenBlocksRegions(), GoSafetySolver(), and UpToDate().


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


Sun Mar 13 2011 Doxygen 1.7.1