Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoSafetyUtil.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file GoSafetyUtil.h
00003     Utility functions for the static and search-based safety solvers.
00004 */
00005 //----------------------------------------------------------------------------
00006 
00007 #ifndef GO_SAFETYUTIL_H
00008 #define GO_SAFETYUTIL_H
00009 
00010 #include "SgBlackWhite.h"
00011 #include "SgMiaiStrategy.h"
00012 #include "SgPoint.h"
00013 #include "SgVector.h"
00014 
00015 class GoBoard;
00016 class GoRegion;
00017 class GoRegionBoard;
00018 class SgBWSet;
00019 class SgPointSet;
00020 
00021 //----------------------------------------------------------------------------
00022 
00023 namespace GoSafetyUtil
00024 {
00025 
00026     /** Add pts to *safe[color] */
00027     void AddToSafe(const GoBoard& board, const SgPointSet& pts,
00028                    SgBlackWhite color, SgBWSet* safe, const char* reason,
00029                    int depth, bool addBoundary);
00030 
00031     /** Stronger version of IsTerritory that uses region information
00032         This version checks for opponent nakade inside the area.
00033         Useful for proving safe semeai test cases after resolving semeai.
00034     */
00035     bool ExtendedIsTerritory(const GoBoard& board, GoRegionBoard* regions,
00036                              const SgPointSet& pts,
00037                              const SgPointSet& safe, SgBlackWhite color);
00038 
00039     /** See FindDameAndUnsurroundablePoints */
00040     SgPointSet FindDamePoints(const GoBoard& board, const SgPointSet& empty,
00041                               const SgBWSet& safe);
00042 
00043     /** Find dame and unsurroundable points.
00044         Given sets of empty points and safe points, compute subset of dame
00045         points. Given safe B+W stones, find empty which are surely dame,
00046         using the algorithm of [Mueller1995].
00047         Unsurroundable points are empty points that can not be surrounded
00048         by either player because they are adjacent to both player's safe
00049         stones. However, they can potentially have an effect on unsafe stones
00050         or on other empty points. Dame points are a subset of unsurroundable
00051         points that have no effect on other points - no matter if they will
00052         be occupied by Black, White, or remain empty.
00053     */
00054     void FindDameAndUnsurroundablePoints(const GoBoard& bd,
00055                                          const SgPointSet& empty,
00056                                          const SgBWSet& safe,
00057                                          SgPointSet* dame,
00058                                          SgPointSet* unsurroundable);
00059 
00060     /** Simple static territory check for surrounded area */
00061     bool IsTerritory(const GoBoard& board, const SgPointSet& pts,
00062                      const SgPointSet& safe, SgBlackWhite color);
00063 
00064     /** Given set of stones, reduce to block anchors */
00065     void ReduceToAnchors(const GoBoard& board, const SgPointSet& stones,
00066                          SgVector<SgPoint>* anchors);
00067 
00068     /** Helper function for 1-vitality test.
00069         Try to find two matching liberties for point p, subtract them from
00070         libs if found.
00071     */
00072     bool Find2Libs(SgPoint p, SgPointSet* libs);
00073 
00074     /** Helper function for 1-vitality test.
00075         Similar to Find2Libs(), but try to find miaiPair of two best liberties
00076         (not shared with other interior points).
00077     */
00078     bool Find2BestLibs(SgPoint p, const SgPointSet& libs,
00079                        SgPointSet interior, SgMiaiPair* miaiPair);
00080 
00081     /** Extended version of MightMakeLife.
00082         Recognizes some nakade shapes as dead. Useful mostly for semeai
00083         solver.
00084     */
00085     bool ExtendedMightMakeLife(const GoBoard& board, GoRegionBoard* regions,
00086                                const SgPointSet& area, const SgPointSet& safe,
00087                                SgBlackWhite color);
00088 
00089     /** Test whether color can make 2 eyes inside a surrounded area.
00090         Precondition: area surrounded by safe stones of opponent.
00091         Basic test, handles 1 and 2 point eyes only.
00092     */
00093     bool MightMakeLife(const GoBoard& board, const SgPointSet& area,
00094                        const SgPointSet& safe, SgBlackWhite color);
00095 
00096     /** Write statistics about the safe points */
00097     void WriteStatistics(const std::string& heading,
00098                       const GoRegionBoard* regions,
00099                       const SgBWSet* safe);
00100                       
00101 } // namespace GoSafetyUtil
00102 
00103 //----------------------------------------------------------------------------
00104 
00105 #endif // GO_SAFETYUTIL_H


17 Jun 2010 Doxygen 1.4.7