pieceEval.cc
Go to the documentation of this file.
00001 #include "osl/eval/ml/pieceEval.h"
00002 #include "osl/eval/pieceEval.h"
00003 
00004 osl::misc::CArray<int, osl::PTYPEO_SIZE> osl::eval::ml::PieceEval::table;
00005 
00006 void osl::eval::ml::
00007 PieceEval::setUp(const Weights &weights)
00008 {
00009   table.fill(0);
00010   // WHITE 0-15, BLACK 16-31
00011   for (size_t i = 0; i < weights.dimension(); ++i)
00012   {
00013     table[i - (size_t)PTYPEO_MIN] = weights.value(i);
00014     table[i] = -weights.value(i);
00015   }
00016   table[newPtypeO(BLACK,KING)-PTYPEO_MIN] = osl::eval::Ptype_Eval_Table.value(KING);
00017   table[newPtypeO(WHITE,KING)-PTYPEO_MIN] = -osl::eval::Ptype_Eval_Table.value(KING);
00018 }
00019 
00020 int osl::eval::ml::
00021 PieceEval::eval(const NumEffectState &state)
00022 {
00023   int value = 0;
00024   for (int i = 0; i < Piece::SIZE; ++i)
00025   {
00026     const Piece piece = state.pieceOf(i);
00027     value += table[piece.ptypeO() - PTYPEO_MIN];
00028   }
00029   return value;
00030 }
00031 
00032 int osl::eval::ml::
00033 PieceEval::value(PtypeO ptypeO)
00034 {
00035   return table[ptypeO - PTYPEO_MIN];
00036 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines