]> git.sesse.net Git - stockfish/commitdiff
Do not prune the move if we are still under mate
authorMarco Costalba <mcostalba@gmail.com>
Wed, 14 Oct 2009 08:18:16 +0000 (09:18 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 15 Oct 2009 17:52:21 +0000 (18:52 +0100)
If after the first tried 2 + int(depth) moves we still
have no any move that takes us out of a mate then do
not prune the following move, it is more important to
escape mate then speed up search.

This fixes an odd behaviour regarding mates, as example
the following diagram is a mate in 4, not in 3 as bogusly
reported before this patch.

1B2n3/8/2R5/5p2/3kp1n1/4p3/B3K3/8 w - - bm #4;

The performance impact should be minimal, the increment
in searched nodes is less then 0.1 %%

Idea and patch by Joona

After 999 games at 1+0
Mod vs Orig +193 =604 -202  -3 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index c0b6507ce9ecddeffac44bc2bea2df64ed7d2de7..53811de04701c4705053dc0d3ed1e52049db0aed 100644 (file)
@@ -1369,7 +1369,8 @@ namespace {
       {
           // History pruning. See ok_to_prune() definition
           if (   moveCount >= 2 + int(depth)
       {
           // History pruning. See ok_to_prune() definition
           if (   moveCount >= 2 + int(depth)
-              && ok_to_prune(pos, move, ss[ply].threatMove, depth))
+              && ok_to_prune(pos, move, ss[ply].threatMove, depth)
+              && bestValue > value_mated_in(PLY_MAX))
               continue;
 
           // Value based pruning
               continue;
 
           // Value based pruning