00001
00002
00003 #ifndef EVAL_PPAIR_PIECEPAIRWITHSTAND_H
00004 #define EVAL_PPAIR_PIECEPAIRWITHSTAND_H
00005
00006 #include "osl/eval/ppair/piecePairEval.h"
00007 #include "osl/eval/pieceEval.h"
00008
00009 namespace osl
00010 {
00011 namespace eval
00012 {
00013 namespace ppair
00014 {
00021 template <class Table>
00022 class PiecePairWithStand
00023 : public PiecePairEval<PiecePairWithStand<Table>,Table>
00024 {
00025 public:
00026 static int standBonus(PtypeO ptypeo)
00027 {
00028 assert(isBasic(getPtype(ptypeo)));
00029 if (isMajorBasic(getPtype(ptypeo)))
00030 return Ptype_Eval_Table.value(newPtypeO(getOwner(ptypeo), PAWN));
00031 return 0;
00032 }
00033 static int standBonus(const SimpleState& state);
00034
00035 typedef PiecePairEval<PiecePairWithStand<Table>, Table> base_t;
00036 explicit PiecePairWithStand(const SimpleState& state);
00037 protected:
00038 ~PiecePairWithStand() {}
00039 public:
00040 static int diffAfterDropMove(const SimpleState& state,Position to,PtypeO ptypeo)
00041 {
00042 const int bonus = standBonus(ptypeo);
00043 return base_t::diffAfterDropMove(state,to,ptypeo) - Ptype_Eval_Table.value(ptypeo) - bonus;
00044 }
00045 static int diffAfterCaptureMove(const SimpleState& state,
00046 Position from, Position to,
00047 PtypeO victim,int promote_mask)
00048 {
00049 const PtypeO captured = osl::captured(victim);
00050 const int bonus = standBonus(captured);
00051 return base_t::diffAfterCaptureMove(state,from,to,victim,promote_mask)
00052 + Ptype_Eval_Table.value(captured) + bonus;
00053 }
00054 static int diffWithUpdate(const SimpleState& new_state, Move last_move)
00055 {
00056 int diff = base_t::diffWithUpdate(new_state, last_move);
00057 if (last_move.isDrop()) {
00058 const int bonus = standBonus(last_move.ptypeO());
00059 return diff - Ptype_Eval_Table.value(last_move.ptypeO()) - bonus;
00060 }
00061 if (last_move.capturePtype() != PTYPE_EMPTY) {
00062 const PtypeO captured = osl::captured(last_move.capturePtypeO());
00063 const int bonus = standBonus(captured);
00064 return diff + Ptype_Eval_Table.value(captured) + bonus;
00065 }
00066 return diff;
00067 }
00068 static void setValues(const SimpleState&, container::PieceValues&);
00069 };
00070
00071 }
00072 }
00073 }
00074
00075
00076 #endif
00077
00078
00079
00080