00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef GO_SAFETYSOLVER_H
00011 #define GO_SAFETYSOLVER_H
00012
00013 #include "GoStaticSafetySolver.h"
00014
00015
00016
00017
00018
00019
00020 class GoSafetySolver : public GoStaticSafetySolver
00021 {
00022 public:
00023
00024 explicit GoSafetySolver(GoBoard& board, GoRegionBoard* regions = 0)
00025 : GoStaticSafetySolver(board, regions)
00026 {
00027 m_code.Invalidate();
00028 }
00029
00030
00031 void FindSafePoints(SgBWSet* safe);
00032
00033
00034 virtual void FindSurroundedSafeAreas(SgBWSet* safe, SgBlackWhite color);
00035
00036
00037 virtual void FindHealthy();
00038
00039
00040 virtual bool UpToDate() const
00041 {
00042 return GoStaticSafetySolver::UpToDate()
00043 && m_code == Board().GetHashCode();
00044 }
00045
00046 protected:
00047
00048
00049
00050
00051 virtual bool RegionHealthyForBlock(const GoRegion& r,
00052 const GoBlock& b) const;
00053
00054
00055 virtual void GenBlocksRegions();
00056
00057
00058 virtual void FindClosure(SgVectorOf<GoBlock>* blocks) const;
00059
00060
00061 virtual void FindTestSets(SgVectorOf<SgVectorOf<GoBlock> >* sets,
00062 SgBlackWhite color) const;
00063
00064
00065 virtual void Test2Vital(GoRegion* r, SgBWSet* safe);
00066
00067
00068 void Find2VitalAreas(SgBWSet* safe);
00069
00070
00071 bool FindSafePair(SgBWSet* safe,
00072 SgBlackWhite color,
00073 const SgPointSet& anySafe,
00074 const GoRegion* r1);
00075
00076
00077 void Merge(GoChain* c1, GoChain* c2, GoRegion* r, bool bySearch);
00078
00079 private:
00080
00081 bool FindSurroundedRegionPair(SgBWSet* safe, SgBlackWhite color);
00082
00083
00084 bool FindSurroundedSingleRegion(SgBWSet* safe, SgBlackWhite color);
00085
00086
00087 SgHashCode m_code;
00088 };
00089
00090
00091
00092 #endif // GO_SAFETYSOLVER_H