00001 /* pieceEval.h 00002 */ 00003 00004 #ifndef EVAL_ML_PIECEEVAL_H 00005 #define EVAL_ML_PIECEEVAL_H 00006 00007 #include "osl/ptype.h" 00008 #include "osl/misc/carray.h" 00009 #include "osl/state/numEffectState.h" 00010 #include "osl/eval/ml/weights.h" 00011 00012 namespace osl 00013 { 00014 namespace eval 00015 { 00016 namespace ml 00017 { 00018 class PieceEval 00019 { 00020 static CArray<int, PTYPEO_SIZE> table; 00021 public: 00022 static void setUp(const Weights &weights); 00023 static int eval(const NumEffectState &state); 00024 template<Player P> 00025 static int evalWithUpdate(const NumEffectState &, 00026 Move moved, int last_value) 00027 { 00028 assert(moved.player()==P); 00029 int value = last_value; 00030 if (moved.isPass() || moved.isDrop()) 00031 return last_value; 00032 if (moved.isPromotion()) 00033 { 00034 value -= table[moved.oldPtypeO() - PTYPEO_MIN]; 00035 value += table[moved.ptypeO() - PTYPEO_MIN]; 00036 } 00037 Ptype captured = moved.capturePtype(); 00038 if (captured != PTYPE_EMPTY) 00039 { 00040 value -= table[newPtypeO(alt(P), captured) - PTYPEO_MIN]; 00041 value += table[newPtypeO(P, unpromote(captured)) - PTYPEO_MIN]; 00042 } 00043 return value; 00044 } 00045 static int value(PtypeO ptypeO); 00046 }; 00047 } 00048 } 00049 } 00050 #endif // EVAL_ML_PIECEEVAL_H 00051 // ;;; Local Variables: 00052 // ;;; mode:c++ 00053 // ;;; c-basic-offset:2 00054 // ;;; End: