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