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