Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoEyeUtil.cpp File Reference


Detailed Description

See GoEyeUtil.h.

Definition in file GoEyeUtil.cpp.

#include "SgSystem.h"
#include "GoEyeUtil.h"
#include "GoBoardUtil.h"
#include "GoEyeCount.h"
#include "SgNbIterator.h"

Go to the source code of this file.

Functions

int NuEdgePoints (const GoBoard &bd, const SgPointSet &points)
 Count number of points on edge of board (Line 1).
bool IsBulkyFour (const SgPointSet &points)
 Recognizes 2x2 block of points.
bool IsTShape (const SgPointSet &block)
bool IsBulkyFive (const SgPointSet &block)
bool IsCross (const SgPointSet &block)
bool IsRabbitySix (const SgPointSet &block)
bool Is2x3Area (const SgPointSet &area)
bool IsAliveBlock (const SgPointSet &block)
 Block has a shape that gives the opponent two eyes, if it gets captured by a single opponent surrounding block.
bool CheckAlwaysAlive8Code (int code)
bool IsAlwaysAliveBlock (const SgPointSet &block)
 Block has a shape that gives the opponent two eyes, and cannot be extended into a nakade shape.
bool IsNakadeBlock (const GoBoard &bd, const SgPointSet &block)
 Is single block, and has one of the standard nakade shapes.
bool AlmostFilledByLivingShape (const GoBoard &bd, const SgPointSet &points, SgBlackWhite stoneColor)
 area is all filled by stones, except for one empty point These stones are in an alive shape (two eyes for opponent).
bool ContainsLivingShape (const GoBoard &bd, const SgPointSet &points, SgBlackWhite stoneColor)
 Area contains stones in an alive shape (two eyes for opponent).
bool AlmostFilledByNakade (const GoBoard &bd, const SgPointSet &points, SgBlackWhite stoneColor)
 area is all filled by stones, except for one empty point.
GoEyeStatus BulkyFiveNakade (const GoBoard &bd, const SgPointSet &points, SgBlackWhite stoneColor)
 Test for the case of a 3 stone block in a bulky 5 shape, which is not handled well by the standard heuristics.
GoEyeStatus Special2x3Cases (const GoBoard &bd, const SgPointSet &points, SgBlackWhite stoneColor)
 Exceptional 2x3 areas that are not handled correctly by heuristics.
bool TestDiagonal (const SgPointSet &set, SgPoint p, int ns, int we)
 is p+ns, p+we locally split?
bool TestOpposite (const SgPointSet &set, SgPoint p, int ns, int we)
 is p+ns, p-ns locally split?
bool IsBentFour (const SgPointSet &points, int boardSize, SgPoint *vital)
 Check for bent four in the corner.
bool TwoDiagonalStonesInBulkyFour (const GoBoard &bd, const SgPointSet &points, SgBlackWhite stoneColor)
 The pattern with 2 diagonal stones is the only one that is unsettled.
bool ProcessStatus (GoEyeStatus status, bool &isNakade, bool &makeNakade)
int GoEyeUtil::DegreeCode (const SgPointSet &points)
 Code for how many points of each degree there are.
long GoEyeUtil::DegreeCode8 (const SgPointSet &points)
 Like DegreeCode, but also count diagonal neighbors.
bool GoEyeUtil::IsNakadeShape (const SgPointSet &area)
 Check if area is one of the classical nakade shapes: ,**,***, **, ***, **, ***, * , * .
bool GoEyeUtil::IsSinglePointEye (const GoBoard &bd, SgPoint p, SgBlackWhite c)
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.
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.
bool GoEyeUtil::IsSinglePointEye2 (const GoBoard &bd, SgPoint p, SgBlackWhite c, SgVector< SgPoint > &eyes)
 As IsSinglePointEye2, but specifying points assumed to be eyes.
bool GoEyeUtil::IsSinglePointEye2 (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 As IsSinglePointEye, but allows diagonal points to be eyes.
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.
int GoEyeUtil::CountSinglePointEyes2 (const GoBoard &bd, SgPoint p)
 Count number of single point eyes for block p.
bool GoEyeUtil::SinglePointSafe2 (const GoBoard &bd, SgPoint p)
 Does block at p have two or more single point eyes?
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.
bool GoEyeUtil::IsSplitPt (SgPoint p, const SgPointSet &s)
 Does removing p split s into two or more parts?
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.
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.
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.
bool GoEyeUtil::CheckInterior (const GoBoard &bd, const SgPointSet &area, SgBlackWhite opp, bool checkBlocks)
bool GoEyeUtil::IsTreeShape (const SgPointSet &area)
 Area is tree shape if it does not contain a 2x2 square.


Function Documentation

bool @5::AlmostFilledByLivingShape ( const GoBoard bd,
const SgPointSet points,
SgBlackWhite  stoneColor 
) [static]

area is all filled by stones, except for one empty point These stones are in an alive shape (two eyes for opponent).

Definition at line 125 of file GoEyeUtil.cpp.

References GoBoard::All(), GoBoard::AllEmpty(), SgPointSet::Border(), IsAliveBlock(), SG_ASSERT, SgOppBW(), and GoBoard::Size().

Referenced by GoEyeUtil::TestNakade().

bool @5::AlmostFilledByNakade ( const GoBoard bd,
const SgPointSet points,
SgBlackWhite  stoneColor 
) [static]

area is all filled by stones, except for one empty point.

These stones are in a nakade shape (only one eye).

Definition at line 152 of file GoEyeUtil.cpp.

References GoBoard::All(), GoBoard::AllEmpty(), SgPointSet::Border(), IsNakadeBlock(), SG_ASSERT, SgOppBW(), and GoBoard::Size().

Referenced by GoEyeUtil::TestNakade().

GoEyeStatus @5::BulkyFiveNakade ( const GoBoard bd,
const SgPointSet points,
SgBlackWhite  stoneColor 
) [static]

Test for the case of a 3 stone block in a bulky 5 shape, which is not handled well by the standard heuristics.

It is almost always nakade, except when one empty point is not a liberty of the block.

Definition at line 171 of file GoEyeUtil.cpp.

References GoBoard::All(), GoBoard::AllEmpty(), GoEyeUtil::DegreeCode(), EYE_ONE, EYE_ONE_AND_HALF, EYE_TWO, EYE_UNKNOWN, IsBulkyFive(), SgPointSet::IsSize(), GoBoard::NumNeighbors(), GoBoard::NumStones(), SgPointSet::PointOf(), and SG_ASSERT.

Referenced by GoEyeUtil::TestNakade().

bool @5::CheckAlwaysAlive8Code ( int  code  )  [static]

Definition at line 89 of file GoEyeUtil.cpp.

Referenced by IsAlwaysAliveBlock().

bool @5::ContainsLivingShape ( const GoBoard bd,
const SgPointSet points,
SgBlackWhite  stoneColor 
) [static]

Area contains stones in an alive shape (two eyes for opponent).

It cannot be extended into a nakade shape.

Definition at line 139 of file GoEyeUtil.cpp.

References GoBoard::All(), SgPointSet::Border(), IsAlwaysAliveBlock(), SG_ASSERT, SgOppBW(), and GoBoard::Size().

Referenced by GoEyeUtil::TestNakade().

bool @5::Is2x3Area ( const SgPointSet area  )  [static]

Definition at line 67 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode().

Referenced by GoEyeUtil::TestNakade().

bool @5::IsAliveBlock ( const SgPointSet block  )  [static]

Block has a shape that gives the opponent two eyes, if it gets captured by a single opponent surrounding block.

Todo:
needs to check if all points in block are adjacent to defender's stones - to avoid bent 4, 3x2 in corner etc.

Definition at line 77 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode().

Referenced by AlmostFilledByLivingShape().

bool @5::IsAlwaysAliveBlock ( const SgPointSet block  )  [static]

Block has a shape that gives the opponent two eyes, and cannot be extended into a nakade shape.

Todo:
needs to check if all points in block are adjacent to defender's stones - to avoid bent 4, 3x2 in corner etc.

Definition at line 101 of file GoEyeUtil.cpp.

References CheckAlwaysAlive8Code(), GoEyeUtil::DegreeCode(), and GoEyeUtil::DegreeCode8().

Referenced by ContainsLivingShape().

bool @5::IsBentFour ( const SgPointSet points,
int  boardSize,
SgPoint vital 
) [static]

Check for bent four in the corner.

brute force check of all eight cases.

Todo:
rewrite using the pattern symmetry functions

Definition at line 294 of file GoEyeUtil.cpp.

References SgPointSet::Contains(), SgPointSet::IsSize(), SgPointUtil::Pt(), and SG_ASSERT.

Referenced by GoEyeUtil::TestNakade().

bool @5::IsBulkyFive ( const SgPointSet block  )  [static]

Definition at line 52 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode().

Referenced by BulkyFiveNakade(), and GoEyeUtil::IsNakadeShape().

bool @5::IsBulkyFour ( const SgPointSet points  )  [static]

Recognizes 2x2 block of points.

Relies on the current implementation where SgSetIterator produces set members in sorted order, such that bulky four points have values p, p+WE, p+NS, p+WE+NS

Definition at line 29 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode(), SgPointSet::IsSize(), SG_ASSERT, SG_NS, and SG_WE.

Referenced by GoEyeUtil::IsNakadeShape(), and GoEyeUtil::TestNakade().

bool @5::IsCross ( const SgPointSet block  )  [static]

Definition at line 57 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode().

Referenced by GoEyeUtil::IsNakadeShape().

bool @5::IsNakadeBlock ( const GoBoard bd,
const SgPointSet block 
) [static]

Is single block, and has one of the standard nakade shapes.

Definition at line 113 of file GoEyeUtil.cpp.

References GoEyeUtil::IsNakadeShape(), and GoBoard::NumStones().

Referenced by AlmostFilledByNakade().

bool @5::IsRabbitySix ( const SgPointSet block  )  [static]

Definition at line 62 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode().

Referenced by GoEyeUtil::IsNakadeShape().

bool @5::IsTShape ( const SgPointSet block  )  [static]

Definition at line 47 of file GoEyeUtil.cpp.

References GoEyeUtil::DegreeCode().

Referenced by GoEyeUtil::IsNakadeShape().

int @5::NuEdgePoints ( const GoBoard bd,
const SgPointSet points 
) [static]

Count number of points on edge of board (Line 1).

Definition at line 19 of file GoEyeUtil.cpp.

References GoBoard::LineSet().

Referenced by Special2x3Cases().

bool @5::ProcessStatus ( GoEyeStatus  status,
bool &  isNakade,
bool &  makeNakade 
) [static]

Definition at line 390 of file GoEyeUtil.cpp.

References EYE_ONE, EYE_ONE_AND_HALF, and EYE_UNKNOWN.

Referenced by GoEyeUtil::TestNakade().

GoEyeStatus @5::Special2x3Cases ( const GoBoard bd,
const SgPointSet points,
SgBlackWhite  stoneColor 
) [static]

Exceptional 2x3 areas that are not handled correctly by heuristics.

Definition at line 207 of file GoEyeUtil.cpp.

References GoBoard::All(), GoEyeUtil::DegreeCode(), GoEyeUtil::DegreeCode8(), EYE_ONE, EYE_ONE_AND_HALF, EYE_TWO, EYE_UNKNOWN, GoBoard::HasNeighbors(), GoBoard::Line(), GoBoard::LineSet(), NuEdgePoints(), SgPointSet::PointOf(), SgOppBW(), and SgPointSet::Size().

Referenced by GoEyeUtil::TestNakade().

bool @5::TestDiagonal ( const SgPointSet set,
SgPoint  p,
int  ns,
int  we 
) [static]

is p+ns, p+we locally split?

Definition at line 272 of file GoEyeUtil.cpp.

Referenced by GoEyeUtil::IsLocalSplitPt().

bool @5::TestOpposite ( const SgPointSet set,
SgPoint  p,
int  ns,
int  we 
) [static]

is p+ns, p-ns locally split?

Definition at line 284 of file GoEyeUtil.cpp.

Referenced by GoEyeUtil::IsLocalSplitPt().

bool @5::TwoDiagonalStonesInBulkyFour ( const GoBoard bd,
const SgPointSet points,
SgBlackWhite  stoneColor 
) [static]

The pattern with 2 diagonal stones is the only one that is unsettled.

All others are nakade - only 1 eye

Definition at line 369 of file GoEyeUtil.cpp.

References GoBoard::All(), GoBoard::AllEmpty(), SgPointSet::Border(), GoBoard::IsEmpty(), GoBoard::NumEmptyNeighbors(), GoBoard::NumNeighbors(), SG_ASSERT, SgOppBW(), and GoBoard::Size().

Referenced by GoEyeUtil::TestNakade().


17 Jun 2010 Doxygen 1.4.7