From 696d6cedb9b1fc6e588d5cc586dc5cf3ee59c9e5 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 11 May 2014 10:56:25 +0200 Subject: [PATCH] Save stalemates in TT When there aren't legal moves after a search, instead of returning imediately, save bestValue in TT as in the usual case. There is really no reason to special case this one. With this patch is fully fixed (again) follwing position: 7k/6p1/6B1/5K1P/8/8/8/8 w - - 0 1 Also in SMP case. bench: 8802105 --- src/search.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index dfe690b4..3d755586 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1017,18 +1017,18 @@ moves_loop: // When in check and at SpNode search starts from here // must be mate or stalemate. If we are in a singular extension search then // return a fail low score. if (!moveCount) - return excludedMove ? alpha - : inCheck ? mated_in(ss->ply) : DrawValue[pos.side_to_move()]; + bestValue = excludedMove ? alpha + : inCheck ? mated_in(ss->ply) : DrawValue[pos.side_to_move()]; + + // Quiet best move: update killers, history, countermoves and followupmoves + else if (bestValue >= beta && !pos.capture_or_promotion(bestMove) && !inCheck) + update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount - 1); TT.store(posKey, value_to_tt(bestValue, ss->ply), bestValue >= beta ? BOUND_LOWER : PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER, depth, bestMove, ss->staticEval); - // Quiet best move: update killers, history, countermoves and followupmoves - if (bestValue >= beta && !pos.capture_or_promotion(bestMove) && !inCheck) - update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount - 1); - assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE); return bestValue; -- 2.39.2