Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Functions | Variables

GoEyeUtil Namespace Reference

Functions

int DegreeCode (const SgPointSet &points)
 Code for how many points of each degree there are.
long DegreeCode8 (const SgPointSet &points)
 Like DegreeCode, but also count diagonal neighbors.
template<class BOARD >
SgPoint EmptyNeighbor (const BOARD &bd, SgPoint p)
 Return an empty neighbor of p.
bool IsNakadeShape (const SgPointSet &area)
 Check if area is one of the classical nakade shapes: ,**,***, **, ***, **, ***, * , * .
bool IsSimpleEye (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 Check if point is a single point eye with one or two adjacent blocks.
bool IsSinglePointEye (const GoBoard &bd, SgPoint p, SgBlackWhite c)
bool IsPossibleEye (const GoBoard &board, SgBlackWhite color, SgPoint p)
 Return true if a point can become an eye by adding one more defender's move.
bool CanBecomeSinglePointEye (const GoBoard &board, SgPoint p, const SgPointSet &oppSafe)
 Given opponent's safe stones, can p ever become an eye? Checks direct and diagonal neighbors.
template<class BOARD >
bool MakesNakadeShape (const BOARD &bd, SgPoint p, SgBlackWhite toPlay)
 does playing at p create one of the standard nakade shapes?
bool NumberOfMoveToEye (const GoBoard &bd, SgBlackWhite c, SgPoint p, int &number)
 Return true if a point can become an eye by adding number of defender's move.
bool IsSinglePointEye2 (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 As IsSinglePointEye, but allows diagonal points to be eyes.
bool IsSinglePointEye2 (const GoBoard &bd, SgPoint p, SgBlackWhite c, SgVector< SgPoint > &eyes)
 As IsSinglePointEye2, but specifying points assumed to be eyes.
template<class BOARD >
bool IsTwoPointEye (const BOARD &bd, SgPoint p, SgBlackWhite c)
 p is in a 2 point eye surrounded by a single chain
bool NumberOfMoveToEye2 (const GoBoard &bd, SgBlackWhite c, SgPoint p, int &nummoves)
 As NumberOfMoveToEye2, but includes existing diagonal eyes, and allows opponent stones to be captured.
int CountSinglePointEyes2 (const GoBoard &bd, SgPoint p)
 Count number of single point eyes for block p.
bool SinglePointSafe2 (const GoBoard &bd, SgPoint p)
 Does block at p have two or more single point eyes?
bool IsSplitPt (SgPoint p, const SgPointSet &s)
 Does removing p split s into two or more parts?
bool IsLocalSplitPt (SgPoint p, const SgPointSet &set)
 Does p locally,within a 3x3 region, split its neighbors in s? Even if the reply is 'yes', s might still be connected outside the region.
bool IsTreeShape (const SgPointSet &area)
 Area is tree shape if it does not contain a 2x2 square.
bool IsVitalPt (const SgPointSet &points, SgPoint p, SgBlackWhite opp, const GoBoard &bd)
 Vital point in small shape - usually has most liberties See implementation for details.
void TestNakade (const SgPointSet &points, const GoBoard &bd, SgBlackWhite color, bool isFullyEnclosed, bool &isNakade, bool &makeNakade, bool &makeFalse, bool &maybeSeki, bool &sureSeki, SgPoint *vital)
 Analyze small region locally for number of eyes.
bool CheckInterior (const GoBoard &bd, const SgPointSet &area, SgBlackWhite opp, bool checkBlocks)

Variables

const int NAKADE_LIMIT = 6
 size of largest standard nakade shape

Function Documentation

bool GoEyeUtil::CanBecomeSinglePointEye ( const GoBoard board,
SgPoint  p,
const SgPointSet oppSafe 
)

Given opponent's safe stones, can p ever become an eye? Checks direct and diagonal neighbors.

Definition at line 764 of file GoEyeUtil.cpp.

References GoBoard::Line(), and SG_ASSERT.

Referenced by GoSafetyUtil::ExtendedMightMakeLife(), and GoSafetyUtil::MightMakeLife().

bool GoEyeUtil::CheckInterior ( const GoBoard bd,
const SgPointSet area,
SgBlackWhite  opp,
bool  checkBlocks 
)
int GoEyeUtil::CountSinglePointEyes2 ( const GoBoard bd,
SgPoint  p 
)

Count number of single point eyes for block p.

Definition at line 694 of file GoEyeUtil.cpp.

References GoBoard::GetColor(), IsSinglePointEye2(), and GoBoard::Occupied().

Referenced by SinglePointSafe2().

int GoEyeUtil::DegreeCode ( const SgPointSet points  ) 

Code for how many points of each degree there are.

The degree measures how many of the (up to 4) neighbors are also in the set of points.

code = 1 * # degree 0 + 10 * # degree 1 + 100 * # degree 2 + 1000 * # degree 3 + 10000 * # degree 4

This is a different format, but has the same information as the Cazenave/Vila "neighbour classification". E.g. their code 112224 means 2x degree 1, 3x degree 2, 1x degree 4, so the DegreeCode is 10320.

The DegreeCode is not strong enough for graph isomorphism testing - there are nonisomorphic graphs with the same code - but it is good for distinguishing small graphs.

For example, it can not distinguish between a "straight" and a "bent" line of three.

Definition at line 393 of file GoEyeUtil.cpp.

References SgPointSet::Contains().

long GoEyeUtil::DegreeCode8 ( const SgPointSet points  ) 

Like DegreeCode, but also count diagonal neighbors.

Definition at line 415 of file GoEyeUtil.cpp.

References SgPointSet::Contains().

template<class BOARD >
SgPoint GoEyeUtil::EmptyNeighbor ( const BOARD &  bd,
SgPoint  p 
)

Return an empty neighbor of p.

Precondition: one must exist.

Definition at line 169 of file GoEyeUtil.h.

References SG_ASSERT, SG_NS, SG_NULLPOINT, and SG_WE.

bool GoEyeUtil::IsLocalSplitPt ( SgPoint  p,
const SgPointSet set 
)

Does p locally,within a 3x3 region, split its neighbors in s? Even if the reply is 'yes', s might still be connected outside the region.

Definition at line 717 of file GoEyeUtil.cpp.

References SG_NS, and SG_WE.

Referenced by IsSplitPt().

bool GoEyeUtil::IsNakadeShape ( const SgPointSet area  ) 

Check if area is one of the classical nakade shapes: ,**,***, **, ***, **, ***, * , * .

* ** ** *** *** **

Definition at line 441 of file GoEyeUtil.cpp.

References SgPointSet::Size().

Referenced by MakesNakadeShape().

bool GoEyeUtil::IsPossibleEye ( const GoBoard board,
SgBlackWhite  color,
SgPoint  p 
)

Return true if a point can become an eye by adding one more defender's move.

Definition at line 468 of file GoEyeUtil.cpp.

References GoBoard::GetColor(), GoBoard::Line(), GoBoard::Num8EmptyNeighbors(), GoBoard::Num8Neighbors(), GoBoard::NumDiagonals(), GoBoard::NumEmptyDiagonals(), GoBoard::NumNeighbors(), GoBoard::Pos(), SG_ASSERT, and SgOppBW().

Referenced by GoGtpEngine::CmdPointInfo().

bool GoEyeUtil::IsSimpleEye ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c 
)

Check if point is a single point eye with one or two adjacent blocks.

This is a fast eye detection routine, which can be used instead of Benson's static life detection, when end-of-game detection is a performance bottle-neck (e.g. for machine-learning or monte-carlo). It detects single-point eyes surrounded by a single block or by two blocks that share another single point eye. Larger eyes can be reduced to simple eyes (assuming chinese rules, so that playing on does not change the score).

Todo:
Add example to documentation where this method fails

Definition at line 183 of file GoEyeUtil.h.

References GoBoard::Anchor(), SgArrayList< T, SIZE >::Contains(), GoBoard::GetColor(), GoBoard::HasEmptyNeighbors(), GoBoard::HasNeighbors(), GoBoard::IsBorder(), SgArrayList< T, SIZE >::Length(), SgArrayList< T, SIZE >::PushBack(), SG_ASSERT, and SgOppBW().

Referenced by GoGtpEngine::CmdPointInfo().

bool GoEyeUtil::IsSinglePointEye ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c 
)
bool GoEyeUtil::IsSinglePointEye2 ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c 
)

As IsSinglePointEye, but allows diagonal points to be eyes.

Slightly slower, but identifies more single point eyes. E.g:

        # X X X . .
        # O O X X X
        # O . O O X
        # . O . O X
        ###########
        

Definition at line 573 of file GoEyeUtil.cpp.

Referenced by CountSinglePointEyes2(), IsSinglePointEye2(), and NumberOfMoveToEye2().

bool GoEyeUtil::IsSinglePointEye2 ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c,
SgVector< SgPoint > &  eyes 
)

As IsSinglePointEye2, but specifying points assumed to be eyes.

Definition at line 538 of file GoEyeUtil.cpp.

References SgVector< T >::Contains(), GoBoard::GetColor(), GoBoard::IsColor(), IsSinglePointEye2(), GoBoard::Line(), SgVector< T >::PopBack(), SgVector< T >::PushBack(), SG_EMPTY, and SgOppBW().

bool GoEyeUtil::IsSplitPt ( SgPoint  p,
const SgPointSet s 
)
bool GoEyeUtil::IsTreeShape ( const SgPointSet area  ) 

Area is tree shape if it does not contain a 2x2 square.

Definition at line 984 of file GoEyeUtil.cpp.

References SgPointSet::Contains(), SG_NS, and SG_WE.

Referenced by IsVitalPt().

template<class BOARD >
bool GoEyeUtil::IsTwoPointEye ( const BOARD &  bd,
SgPoint  p,
SgBlackWhite  c 
)

p is in a 2 point eye surrounded by a single chain

Definition at line 242 of file GoEyeUtil.h.

References GoBoardUtil::FindNeighbor(), SG_ASSERT, SG_EMPTY, SG_ENDPOINT, and SgOppBW().

bool GoEyeUtil::IsVitalPt ( const SgPointSet points,
SgPoint  p,
SgBlackWhite  opp,
const GoBoard bd 
)

Vital point in small shape - usually has most liberties See implementation for details.

Definition at line 917 of file GoEyeUtil.cpp.

References GoBoard::IsEmpty(), IsSplitPt(), IsTreeShape(), GoBoard::NumEmptyNeighbors(), and GoBoard::NumNeighbors().

Referenced by TestNakade().

template<class BOARD >
bool GoEyeUtil::MakesNakadeShape ( const BOARD &  bd,
SgPoint  p,
SgBlackWhite  toPlay 
)

does playing at p create one of the standard nakade shapes?

Definition at line 269 of file GoEyeUtil.h.

References SgVector< T >::Back(), SgPointSet::Contains(), SgPointSet::Include(), IsNakadeShape(), NAKADE_LIMIT, SgVector< T >::NonEmpty(), SgVector< T >::PopBack(), and SgVector< T >::PushBack().

Referenced by GoGtpEngine::CmdPointInfo().

bool GoEyeUtil::NumberOfMoveToEye ( const GoBoard bd,
SgBlackWhite  c,
SgPoint  p,
int &  number 
)

Return true if a point can become an eye by adding number of defender's move.

Definition at line 507 of file GoEyeUtil.cpp.

References GoBoard::IsEmpty(), GoBoard::Line(), GoBoard::Num8EmptyNeighbors(), GoBoard::Num8Neighbors(), GoBoard::NumNeighbors(), SG_ASSERT, and SgOppBW().

bool GoEyeUtil::NumberOfMoveToEye2 ( const GoBoard bd,
SgBlackWhite  c,
SgPoint  p,
int &  nummoves 
)

As NumberOfMoveToEye2, but includes existing diagonal eyes, and allows opponent stones to be captured.

Definition at line 580 of file GoEyeUtil.cpp.

References SgPointSet::Include(), GoBoard::IsColor(), IsSinglePointEye2(), GoBoard::Line(), GoBoard::NumLiberties(), SgVector< T >::PushBack(), SG_EMPTY, SG_NULLPOINT, SgOppBW(), SinglePointSafe2(), and SgPointSet::Size().

bool GoEyeUtil::SinglePointSafe2 ( const GoBoard bd,
SgPoint  p 
)

Does block at p have two or more single point eyes?

Definition at line 711 of file GoEyeUtil.cpp.

References CountSinglePointEyes2().

Referenced by NumberOfMoveToEye2().

void GoEyeUtil::TestNakade ( const SgPointSet points,
const GoBoard bd,
SgBlackWhite  color,
bool  isFullyEnclosed,
bool &  isNakade,
bool &  makeNakade,
bool &  makeFalse,
bool &  maybeSeki,
bool &  sureSeki,
SgPoint vital 
)

Analyze small region locally for number of eyes.

color: the player surrounding the area. isNakade: only one eye makeNakade: attacker can reduce to one eye, defender can live locally. makeFalse: attacker can make the area into a false eye. maybeSeki, sureSeki: can there be, or is there, a seki between boundary stones and interior opponent stones?

Todo:
: seki support is primitive only. vital is set iff makeNakade or makeFalse

Definition at line 792 of file GoEyeUtil.cpp.

References GoBoard::AllEmpty(), GoBoard::IsEmpty(), GoBoard::IsLegal(), IsVitalPt(), SG_ASSERT, SG_NULLPOINT, SG_UNUSED(), SgOppBW(), GoBoard::Size(), SgPointSet::Size(), and SgPointSet::SubsetOf().

Referenced by GoRegion::ComputeMultipleBlockEyeSpace(), GoRegion::ComputeNakade(), and GoRegion::ComputeSingleBlockEyeSpace().


Variable Documentation

const int GoEyeUtil::NAKADE_LIMIT = 6

size of largest standard nakade shape

Definition at line 18 of file GoEyeUtil.h.

Referenced by MakesNakadeShape().


Sun Mar 13 2011 Doxygen 1.7.1