From a9e93fa6a56d985e98f16a480a8b0d166fdea324 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 3 May 2014 12:09:56 +0200 Subject: [PATCH] Fully correct stealmate detection In the (rare) cases when the two conditions are true, then fully check again with a slow but correct MoveList(pos).size(). This is able to detect false positives like this one: 8/8/8/Q7/5k1p/5P2/4KP2/8 b - - 0 17 When we have a possible simple pawn push that is not stored in attacks[] array. Because the third condition triggers very rarely, even if it is slow, it does not alters in a measurable way the average speed of the engine. bench: 8678654 --- src/evaluate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 29d71ea9..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" @@ -790,7 +790,8 @@ namespace { // 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]))) + && (!(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 -- 2.39.2