00001
00002
00003 #include "osl/category/moveEvaluation.h"
00004 #include "osl/category/categoryUtil.h"
00005 #include "osl/checkmate/checkmateIfCapture.h"
00006 #include "osl/effect_util/shadowEffect.h"
00007 #include "osl/search/historyTable.h"
00008
00009 int osl::category::
00010 MoveEvaluation::evalDetailed(const CategoryEnv& env, Move move,
00011 const Position8& sendoffs)
00012 {
00013 const NumEffectState& state = *env.state;
00014 int diff = evalLight(state, move);
00015 if (env.history_table)
00016 diff = std::min(diff, env.history_table->logp(move));
00017
00018
00019 if (diff < 0)
00020 {
00021 if (checkmate::CheckmateIfCapture::effectiveAttack
00022 (const_cast<NumEffectState&>(state), move, 0))
00023 {
00024 diff = CategoryUtilBase::CaptureIfCheckmateBonus;
00025 if (move.capturePtype() != PTYPE_EMPTY)
00026 {
00027 diff += eval::Ptype_Eval_Table.value(move.capturePtype())
00028 + eval::Ptype_Eval_Table.value(unpromote(move.capturePtype()));
00029 }
00030 if (move.isPromote())
00031 diff += abs(eval::Ptype_Eval_Table.promoteValue(move.ptypeO()));
00032 }
00033 }
00034
00035
00036 if (sendoffs.isMember(move.to()))
00037 diff = std::max(diff, (const int)CategoryUtilBase::SendOffBonus);
00038
00039
00040 if (diff < 0)
00041 {
00042 const int attack = state.countEffect(move.player(), move.to())
00043 + (move.isDrop() ? 1 : 0);
00044 const int defense = state.countEffect(alt(move.player()), move.to());
00045 if ((attack <= defense)
00046 && (attack + ShadowEffect::count2(state, move.to(), move.player())
00047 > defense))
00048 diff = 0;
00049 }
00050 return diff;
00051 }
00052
00053
00054
00055
00056
00057