00001 //---------------------------------------------------------------------------- 00002 /** @file GoRegionUtil.h 00003 Utility functions for GoRegion and GoRegionBoard. */ 00004 //---------------------------------------------------------------------------- 00005 00006 #ifndef GO_REGIONUTIL_H 00007 #define GO_REGIONUTIL_H 00008 00009 #include "SgBlackWhite.h" 00010 #include "SgVector.h" 00011 #include "SgPoint.h" 00012 00013 class GoBoard; 00014 class SgPointSet; 00015 00016 //---------------------------------------------------------------------------- 00017 00018 namespace GoRegionUtil 00019 { 00020 /** Check for 1-vitality, as explained in [Mueller 95, p.****] */ 00021 bool StaticIs1VitalAndConnected(const GoBoard& board, 00022 const SgPointSet& pts, 00023 SgBlackWhite color); 00024 00025 /** Test if a point set is 2-vital for color */ 00026 bool Has2SureLiberties(const GoBoard& board, const SgPointSet& pts, 00027 SgBlackWhite color, 00028 const SgVector<SgPoint>& boundaryAnchors); 00029 00030 /** Test if pts has 2 IP or eyes. 00031 Has2IPorEyes is called after all interior points are 2conn proved. 00032 It returns true if two intersection points are found or single 00033 boundary block forms two separate eyes. */ 00034 bool Has2IPorEyes(const GoBoard& board, const SgPointSet& pts, 00035 SgBlackWhite color, 00036 const SgVector<SgPoint>& boundaryAnchors); 00037 00038 /** Do pts belong to only one block? 00039 pts must be non-empty. */ 00040 bool IsSingleBlock(const GoBoard& board, const SgPointSet& pts, 00041 SgBlackWhite color); 00042 00043 /** A region is called small iff its interior is completely filled 00044 by opponent stones (or there is no interior). 00045 This definition (and the name "small") is due to Benson. 00046 pts must be a region completely surrounded by opponent stones. */ 00047 bool IsSmallRegion(const GoBoard& board, const SgPointSet& pts, 00048 SgBlackWhite opp); 00049 00050 /** Find anchors of all blocks represented by origAnchors 00051 that are present in current board position. 00052 Some of the origAnchors may have been captured in the meantime, and 00053 some anchors may have changed by extending and/or merging of blocks. */ 00054 void FindCurrentAnchors(const GoBoard& board, 00055 const SgVector<SgPoint>& origAnchors, 00056 SgVector<SgPoint>* currentAnchors); 00057 00058 } // namespace GoRegionUtil 00059 00060 //---------------------------------------------------------------------------- 00061 00062 #endif // GO_REGIONUTIL_H