All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
pieceEval.cc
Go to the documentation of this file.
1 #include "osl/eval/pieceEval.h"
2 #include "osl/eval/pieceEval.tcc"
3 #include "osl/eval/evalTraits.h"
6 #include "osl/pieceTable.h"
7 
8 namespace osl
9 {
10  // explicit template instantiation
11  template int PieceEval::computeDiffAfterMove<BLACK>
12  (const NumEffectState&, Move);
13  template int PieceEval::computeDiffAfterMove<WHITE>
14  (const NumEffectState&, Move);
15 
16 #ifndef DFPNSTATONE
17 #ifndef MINIMAL
18  template void
19  EffectUtil::findThreat<PieceEval>(const NumEffectState& state,
20  Square position,
21  PtypeO ptypeo,
22  PieceVector& out);
23 #endif
24 #endif
25 }
26 
27 osl::PieceEval::PieceEval(const NumEffectState& state)
28 {
29  int ret=0;
30  for (int num=0;num<Piece::SIZE;num++) {
31  if (state.standMask(BLACK).test(num))
32  {
34  }
35  else if (state.standMask(WHITE).test(num))
36  {
38  }
39  else{
40  assert(state.isOnBoard(num));
41  Piece p=state.pieceOf(num);
42  ret+=Ptype_Eval_Table.value(p.ptypeO());
43  }
44  }
45  val=ret;
46 }
47 
50 {
51  *this = PieceEval(NumEffectState());
52 }
53 
55 {
56  const CArray<int, PTYPE_SIZE> values = {{
57  0, 0,
61  //
63  //
67  }};
68  reset(values);
69 }
71 {
72 }
73 
74 void osl::eval::PtypeEvalTable::reset(const CArray<int,PTYPE_SIZE>& values)
75 {
76  ptypeO2Val.fill(0);
77  std::copy(values.begin(), values.end(), ptypeO2Val.begin()+16);
78  for(int i=PTYPE_MIN;i<=PTYPE_MAX;i++)
79  {
80  Ptype ptype=static_cast<Ptype>(i);
81  ptypeO2Val[newPtypeO(WHITE,ptype)-PTYPEO_MIN]=
82  -ptypeO2Val[newPtypeO(BLACK,ptype)-PTYPEO_MIN];
83  }
84  for(int i=PTYPEO_MIN;i<=PTYPEO_MAX;i++)
85  {
86  PtypeO ptypeO=static_cast<PtypeO>(i);
87  PtypeO basicPtypeO=unpromote(ptypeO);
88  // note: value() depends on ptypeO2Val
89  promoteVal[i-PTYPEO_MIN]=this->value(ptypeO)-this->value(basicPtypeO);
90  }
91  // EMPTYのcapture
92  captureVal[0]=0;
93  for(int i=PTYPEO_MIN;i<=PTYPEO_MAX;i++)
94  {
95  PtypeO ptypeO=static_cast<PtypeO>(i);
96  // note: value() depends on ptypeO2Val
97  if(isPiece(ptypeO))
98  captureVal[i-PTYPEO_MIN]=this->value(captured(ptypeO))-
99  this->value(ptypeO);
100  else
101  captureVal[i-PTYPEO_MIN]=0;
102  }
103 }
104 
105 
106 // ;;; Local Variables:
107 // ;;; mode:c++
108 // ;;; c-basic-offset:2
109 // ;;; coding:utf-8
110 // ;;; End: