Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

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.
bool IsNakadeShape (const SgPointSet &area)
 Check if area is one of the classical nakade shapes: ,**,***, **, ***, **, ***, * , * .
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 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, SgVector< SgPoint > &eyes)
 As IsSinglePointEye2, but specifying points assumed to be eyes.
bool IsSinglePointEye2 (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 As IsSinglePointEye, but allows diagonal points to be eyes.
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 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 IsSplitPt (SgPoint p, const SgPointSet &s)
 Does removing p split s into two or more parts?
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.
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 IsVitalPt (const SgPointSet &points, SgPoint p, SgBlackWhite opp, const GoBoard &bd)
 Vital point in small shape - usually has most liberties See implementation for details.
bool CheckInterior (const GoBoard &bd, const SgPointSet &area, SgBlackWhite opp, bool checkBlocks)
bool IsTreeShape (const SgPointSet &area)
 Area is tree shape if it does not contain a 2x2 square.
template<class BOARD>
SgPoint EmptyNeighbor (const BOARD &bd, SgPoint p)
 Return an empty neighbor of p.
bool IsSimpleEye (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 Check if point is a single point eye with one or two adjacent blocks.
template<class BOARD>
bool MakesNakadeShape (const BOARD &bd, SgPoint p, SgBlackWhite toPlay)
 does playing at p create one of the standard nakade shapes?
template<class BOARD>
bool IsTwoPointEye (const BOARD &bd, SgPoint p, SgBlackWhite c)
 p is in a 2 point eye surrounded by a single chain
template<class BOARD>
SgPoint EmptyNeighbor (const BOARD &bd, SgPoint p)
 Return an empty neighbor of p.
bool IsSimpleEye (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 Check if point is a single point eye with one or two adjacent blocks.
template<class BOARD>
bool IsTwoPointEye (const BOARD &bd, SgPoint p, SgBlackWhite color)
 p is in a 2 point eye surrounded by a single chain
template<class BOARD>
bool MakesNakadeShape (const BOARD &bd, SgPoint p, SgBlackWhite toPlay)
 does playing at p create one of the standard nakade shapes?

Variables

const int NAKADE_LIMIT = 6
 size of largest standard nakade shape


Function Documentation

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 403 of file GoEyeUtil.cpp.

Referenced by BulkyFiveNakade(), Is2x3Area(), IsAliveBlock(), IsAlwaysAliveBlock(), IsBulkyFive(), IsBulkyFour(), IsCross(), IsRabbitySix(), IsTShape(), and Special2x3Cases().

long GoEyeUtil::DegreeCode8 ( const SgPointSet points  ) 

Like DegreeCode, but also count diagonal neighbors.

Definition at line 425 of file GoEyeUtil.cpp.

Referenced by IsAlwaysAliveBlock(), and Special2x3Cases().

bool GoEyeUtil::IsNakadeShape ( const SgPointSet area  ) 

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

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

Definition at line 451 of file GoEyeUtil.cpp.

References IsBulkyFive(), IsBulkyFour(), IsCross(), IsRabbitySix(), IsTShape(), and SgPointSet::Size().

Referenced by IsNakadeBlock(), and MakesNakadeShape().

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

Definition at line 466 of file GoEyeUtil.cpp.

References GoBoard::HasDiagonals(), GoBoard::HasEmptyNeighbors(), GoBoard::HasNeighbors(), GoBoard::IsEmpty(), GoBoard::Line(), GoBoard::NumDiagonals(), SG_ASSERT, SG_EMPTY, and SgOppBW().

Referenced by GoGtpEngine::CmdPointInfo().

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 478 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::NumberOfMoveToEye ( const GoBoard board,
SgBlackWhite  color,
SgPoint  p,
int &  number 
)

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

Definition at line 517 of file GoEyeUtil.cpp.

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

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

As IsSinglePointEye2, but specifying points assumed to be eyes.

Definition at line 548 of file GoEyeUtil.cpp.

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

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

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 583 of file GoEyeUtil.cpp.

References IsSinglePointEye2().

bool GoEyeUtil::NumberOfMoveToEye2 ( const GoBoard board,
SgBlackWhite  color,
SgPoint  p,
int &  nummoves 
)

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

Definition at line 590 of file GoEyeUtil.cpp.

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

int GoEyeUtil::CountSinglePointEyes2 ( const GoBoard board,
SgPoint  p 
)

Count number of single point eyes for block p.

Definition at line 704 of file GoEyeUtil.cpp.

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

Referenced by SinglePointSafe2().

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

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

Definition at line 721 of file GoEyeUtil.cpp.

References CountSinglePointEyes2().

Referenced by NumberOfMoveToEye2().

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 727 of file GoEyeUtil.cpp.

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

Referenced by IsSplitPt().

bool GoEyeUtil::IsSplitPt ( SgPoint  p,
const SgPointSet points 
)

Does removing p split s into two or more parts?

Definition at line 764 of file GoEyeUtil.cpp.

References SgPointSet::Exclude(), SgPointSet::IsConnected(), IsLocalSplitPt(), and SG_ASSERT.

Referenced by GoRegion::GetDivideMiaiPairs(), GoRegion::GetIPs(), Has2IntersectionPoints(), GoRegion::Has2IntersectionPoints(), GoRegion::Has2IPs(), IsVitalPt(), and GoRegionBoard::OnExecutedUncodedMove().

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 774 of file GoEyeUtil.cpp.

References GoBoard::Line(), and SG_ASSERT.

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

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 802 of file GoEyeUtil.cpp.

References GoBoard::AllEmpty(), AlmostFilledByLivingShape(), AlmostFilledByNakade(), BulkyFiveNakade(), ContainsLivingShape(), Is2x3Area(), IsBentFour(), IsBulkyFour(), GoBoard::IsEmpty(), GoBoard::IsLegal(), IsVitalPt(), ProcessStatus(), SG_ASSERT, SG_NULLPOINT, SG_UNUSED(), SgOppBW(), GoBoard::Size(), SgPointSet::Size(), Special2x3Cases(), SgPointSet::SubsetOf(), and TwoDiagonalStonesInBulkyFour().

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

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 927 of file GoEyeUtil.cpp.

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

Referenced by TestNakade().

bool GoEyeUtil::CheckInterior ( const GoBoard bd,
const SgPointSet area,
SgBlackWhite  opp,
bool  checkBlocks 
)

Definition at line 954 of file GoEyeUtil.cpp.

References GoBoard::Anchor(), GoBoard::GetColor(), GoBoard::IsEmpty(), GoBoard::NumLiberties(), SG_NS, and SG_WE.

bool GoEyeUtil::IsTreeShape ( const SgPointSet area  ) 

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

Definition at line 994 of file GoEyeUtil.cpp.

References SG_NS, and SG_WE.

Referenced by IsVitalPt().

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

Return an empty neighbor of p.

Precondition: one must exist.

Definition at line 180 of file GoEyeUtil.h.

References SG_ASSERT, SG_NS, SG_NULLPOINT, and SG_WE.

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 194 of file GoEyeUtil.h.

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

Referenced by GoGtpEngine::CmdPointInfo().

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 280 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().

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 253 of file GoEyeUtil.h.

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

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

Return an empty neighbor of p.

Precondition: one must exist.

Definition at line 180 of file GoEyeUtil.h.

References SG_ASSERT, SG_NS, SG_NULLPOINT, and SG_WE.

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 194 of file GoEyeUtil.h.

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

Referenced by GoGtpEngine::CmdPointInfo().

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

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

Definition at line 253 of file GoEyeUtil.h.

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

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 280 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().


Variable Documentation

const int GoEyeUtil::NAKADE_LIMIT = 6

size of largest standard nakade shape

Definition at line 19 of file GoEyeUtil.h.

Referenced by MakesNakadeShape().


17 Jun 2010 Doxygen 1.4.7