From: Marco Costalba Date: Sun, 11 May 2014 08:56:25 +0000 (+0200) Subject: Save stalemates in TT X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=696d6cedb9b1fc6e588d5cc586dc5cf3ee59c9e5;ds=inline 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 --- 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;