X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=34a87771aea96a120e14f5858ffebd510f73d60f;hp=be53a73ee886633bc7775c3453856a50531e78e6;hb=a9e93fa6a56d985e98f16a480a8b0d166fdea324;hpb=d3ffd0ffcad5e467fffd67d82d031fa1cbdba7d2 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index be53a73e..34a87771 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -17,10 +17,10 @@ along with this program. If not, see . */ +#include #include #include #include -#include #include "bitcount.h" #include "evaluate.h" @@ -787,11 +787,18 @@ namespace { sf = ScaleFactor(50 * sf / SCALE_FACTOR_NORMAL); } + // Stealmate detection + Color stm = pos.side_to_move(); + if ( (ei.attackedBy[stm][ALL_PIECES] == ei.attackedBy[stm][KING]) + && (!(ei.attackedBy[stm][KING] & ~ei.attackedBy[~stm][ALL_PIECES])) + && !MoveList(pos).size()) + sf = SCALE_FACTOR_DRAW; + // Interpolate between a middlegame and a (scaled by 'sf') endgame score Value v = mg_value(score) * int(ei.mi->game_phase()) + eg_value(score) * int(PHASE_MIDGAME - ei.mi->game_phase()) * sf / SCALE_FACTOR_NORMAL; - v /= PHASE_MIDGAME; + v /= int(PHASE_MIDGAME); // In case of tracing add all single evaluation contributions for both white and black if (Trace)