00001 #ifndef ENDGAME_KINGPIECEVALUES_H
00002 #define ENDGAME_KINGPIECEVALUES_H
00003 #include "osl/container/pieceValues.h"
00004 #include "osl/state/simpleState.h"
00005
00006 namespace osl
00007 {
00008 namespace eval
00009 {
00010 namespace endgame
00011 {
00015 template <class Eval>
00016 struct KingPieceValues
00017 {
00021 static void setValues(const SimpleState&, PieceValues&);
00022 };
00023 }
00024 }
00025 }
00026
00027 template <class Eval>
00028 void osl::eval::endgame::
00029 KingPieceValues<Eval>::setValues(const SimpleState& state, PieceValues& values)
00030 {
00031 values.fill(0);
00032
00033 const Piece king_black = state.getKingPiece(BLACK);
00034 const Piece king_white = state.getKingPiece(WHITE);
00035
00036 for (int i=0; i<Piece::SIZE; i++) {
00037 const Piece target = state.getPieceOf(i);
00038 values[i] = (Eval::valueOf(king_black, target)
00039 + Eval::valueOf(king_white, target));
00040 }
00041 }
00042
00043 #endif
00044
00045
00046
00047