00001 //---------------------------------------------------------------------------- 00002 /** @file GoUctDefaultPriorKnowledge.h */ 00003 //---------------------------------------------------------------------------- 00004 00005 #ifndef GOUCT_DEFAULTPRIORKNOWLEDGE_H 00006 #define GOUCT_DEFAULTPRIORKNOWLEDGE_H 00007 00008 #include "GoUctPlayoutPolicy.h" 00009 #include "SgUctSearch.h" 00010 00011 //---------------------------------------------------------------------------- 00012 00013 /** Base knowledge class. */ 00014 class GoUctKnowledge 00015 { 00016 public: 00017 GoUctKnowledge(const GoBoard& bd); 00018 00019 virtual ~GoUctKnowledge(); 00020 00021 virtual void ProcessPosition(std::vector<SgMoveInfo>& moves)=0; 00022 00023 protected: 00024 const GoBoard& m_bd; 00025 00026 SgArray<SgStatisticsBase<float,std::size_t>,SG_PASS+1> m_values; 00027 00028 void Add(SgPoint p, float value, std::size_t count); 00029 00030 void Initialize(SgPoint p, float value, std::size_t count); 00031 00032 void ClearValues(); 00033 00034 void TransferValues(std::vector<SgMoveInfo>& outmoves) const; 00035 }; 00036 00037 //---------------------------------------------------------------------------- 00038 00039 /** Default prior knowledge heuristic. 00040 Mainly uses GoUctPlayoutPolicy to generate prior knowledge. 00041 */ 00042 class GoUctDefaultPriorKnowledge 00043 : public GoUctKnowledge 00044 { 00045 public: 00046 GoUctDefaultPriorKnowledge(const GoBoard& bd, 00047 const GoUctPlayoutPolicyParam& param); 00048 00049 void ProcessPosition(std::vector<SgMoveInfo>& moves); 00050 00051 bool FindGlobalPatternAndAtariMoves(SgPointSet& pattern, 00052 SgPointSet& atari, 00053 GoPointList& empty) const; 00054 private: 00055 00056 GoUctPlayoutPolicy<GoBoard> m_policy; 00057 00058 void AddLocalityBonus(GoPointList& emptyPoints, bool isSmallBoard); 00059 00060 }; 00061 00062 //---------------------------------------------------------------------------- 00063 00064 #endif // GOUCT_DEFAULTPRIORKNOWLEDGE_H