pieceEval.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ml/pieceEval.h
Go to the documentation of this file.
1 /* pieceEval.h
2 */
3
4 #ifndef EVAL_ML_PIECEEVAL_H
5 #define EVAL_ML_PIECEEVAL_H
6
7 #include "osl/ptype.h"
8 #include "osl/misc/carray.h"
9 #include "osl/state/numEffectState.h"
10 #include "osl/eval/ml/weights.h"
11
12 namespace osl
13 {
14 namespace eval
15 {
16 namespace ml
17 {
18 class PieceEval
19 {
20 static CArray<int, PTYPEO_SIZE> table;
21 public:
22 static void setUp(const Weights &weights);
23 static int eval(const NumEffectState &state);
24 template<Player P>
25 static int evalWithUpdate(const NumEffectState &,
26 Move moved, int last_value)
27 {
28 assert(moved.player()==P);
29 int value = last_value;
30 if (moved.isPass() || moved.isDrop())
31 return last_value;
32 if (moved.isPromotion())
33 {
34 value -= table[moved.oldPtypeO() - PTYPEO_MIN];
35 value += table[moved.ptypeO() - PTYPEO_MIN];
36 }
37 Ptype captured = moved.capturePtype();
38 if (captured != PTYPE_EMPTY)
39 {
40 value -= table[newPtypeO(alt(P), captured) - PTYPEO_MIN];
41 value += table[newPtypeO(P, unpromote(captured)) - PTYPEO_MIN];
42 }
43 return value;
44 }
45 static int value(PtypeO ptypeO);
46 };
47 }
48 }
49 }
50 #endif // EVAL_ML_PIECEEVAL_H
51 // ;;; Local Variables:
52 // ;;; mode:c++
53 // ;;; c-basic-offset:2
54 // ;;; End: