All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ml/pieceEval.cc
Go to the documentation of this file.
2 #include "osl/eval/pieceEval.h"
3 
5 
7 PieceEval::setUp(const Weights &weights)
8 {
9  table.fill(0);
10  // WHITE 0-15, BLACK 16-31
11  for (size_t i = 0; i < weights.dimension(); ++i)
12  {
13  table[i - (size_t)PTYPEO_MIN] = weights.value(i);
14  table[i] = -weights.value(i);
15  }
18 }
19 
21 PieceEval::eval(const NumEffectState &state)
22 {
23  int value = 0;
24  for (int i = 0; i < Piece::SIZE; ++i)
25  {
26  const Piece piece = state.pieceOf(i);
27  value += table[piece.ptypeO() - PTYPEO_MIN];
28  }
29  return value;
30 }
31 
34 {
35  return table[ptypeO - PTYPEO_MIN];
36 }