00001 /* checkmate.cc 00002 */ 00003 #include "osl/rating/feature/checkmate.h" 00004 #include "osl/apply_move/applyMove.h" 00005 00006 struct osl::rating::Threatmate::Helper 00007 { 00008 bool& result; 00009 NumEffectState& state; 00010 void operator()(Position) 00011 { 00012 if (EffectUtil::isKingInCheck(state.getTurn(), state) 00013 || EffectUtil::isKingInCheck(alt(state.getTurn()), state)) { 00014 result = false; 00015 return; 00016 } 00017 state.changeTurn(); 00018 result = ImmediateCheckmate::hasCheckmateMove(state.getTurn(), state); 00019 state.changeTurn(); 00020 } 00021 }; 00022 00023 bool osl::rating::Threatmate::match(const NumEffectState& cstate, Move move, const RatingEnv&) const 00024 { 00025 NumEffectState& state = const_cast<NumEffectState&>(cstate); 00026 bool result = false; 00027 Helper helper = { result, state }; 00028 ApplyMoveOfTurn::doUndoMove(state, move, helper); 00029 return result; 00030 } 00031 00032 /* ------------------------------------------------------------------------- */