00001 /* categoryTraits.h 00002 */ 00003 #ifndef _CATEGORYTRAITS_H 00004 #define _CATEGORYTRAITS_H 00005 00006 #include "osl/category/probTable.h" 00007 #include "osl/misc/loki.h" 00008 #include "osl/move.h" 00009 00010 namespace osl 00011 { 00012 namespace category 00013 { 00014 struct CategoryTraits 00015 { 00016 static size_t maxProb() { return 2000; } 00017 }; 00018 00019 00020 struct CategoryEnv; 00021 00027 struct CategoryRoot 00028 { 00034 static const bool IsKingEscape = false; 00039 static const bool FirstMatchOnly = false; 00043 static const bool AdjustSendOff = false; 00048 static const bool IsClassifier = false; 00049 }; 00050 00052 enum ProbabilityType { 00054 FIXED, 00058 STANDARD_TABLE, 00063 TABLE, 00065 SPECIAL, 00066 }; 00067 00068 struct FixedProbabilityCategory : public CategoryRoot 00069 { 00070 static const ProbabilityType probType = FIXED; 00071 static int getIndex(const CategoryEnv&, Move, int) 00072 { 00073 return 0; 00074 } 00075 static int indexMax() { return 1; } 00076 }; 00077 struct StandardProbabilityCategory : public CategoryRoot 00078 { 00079 static const ProbabilityType probType = STANDARD_TABLE; 00080 static int getIndex(const CategoryEnv&, Move, int pieceValue) 00081 { 00082 return PieceValueTable::getIndex(pieceValue); 00083 } 00084 static int indexMax() { return PieceValueTable::indexMax(); } 00085 }; 00086 struct TableProbabilityCategory : public CategoryRoot 00087 { 00088 static const ProbabilityType probType = TABLE; 00089 // ʲҥ饹 00090 // static int getIndex(const CategoryEnv&, Move, int pieceValue); 00091 }; 00092 struct SpecialProbabilityCategory : public CategoryRoot 00093 { 00094 static const ProbabilityType probType = SPECIAL; 00095 }; 00096 00100 template <class Category> 00101 struct MinProb 00102 { 00103 private: 00104 static int minProb(Int2Type<true>) 00105 { 00106 return Category::probTable.minProb(); 00107 } 00108 static int minProb(Int2Type<false>) 00109 { 00110 return Category::minProb(); 00111 } 00112 public: 00113 static int minProb() 00114 { 00115 return minProb(Int2Type<Category::probType!=SPECIAL>()); 00116 } 00117 }; 00118 00119 } // namespace category 00120 } // namespace osl 00121 00122 #endif /* _CATEGORYTRAITS_H */ 00123 // ;;; Local Variables: 00124 // ;;; mode:c++ 00125 // ;;; c-basic-offset:2 00126 // ;;; End: