From 855bee20409c9647fe72e694beb29ed0957fad71 Mon Sep 17 00:00:00 2001 From: syzygy1 <3028851+syzygy1@users.noreply.github.com> Date: Wed, 1 Jul 2020 23:01:01 +0200 Subject: [PATCH] Bugfix See https://github.com/syzygy1/Cfish/commit/bcfb5f50bb05df8121f683a3ec746bb51b0180c3 --- src/ntsearch.c | 8 ++++---- src/search.c | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ntsearch.c b/src/ntsearch.c index ea2c2f12..75a87301 100644 --- a/src/ntsearch.c +++ b/src/ntsearch.c @@ -57,8 +57,8 @@ Value search_NonPV(Pos *pos, Stack *ss, Value alpha, Depth depth, int cutNode) Move ttMove, move, excludedMove, bestMove; Depth extension, newDepth; Value bestValue, value, ttValue, eval, maxValue; - int ttHit, ttPv, inCheck, givesCheck, improving, didLMR; - bool doFullDepthSearch, moveCountPruning; + int ttHit, ttPv, inCheck, givesCheck, didLMR; + bool improving, doFullDepthSearch, moveCountPruning; bool ttCapture, captureOrPromotion, singularLMR; Piece movedPiece; int moveCount, captureCount, quietCount; @@ -228,7 +228,7 @@ Value search_NonPV(Pos *pos, Stack *ss, Value alpha, Depth depth, int cutNode) // Step 6. Static evaluation of the position if (inCheck) { ss->staticEval = eval = VALUE_NONE; - improving = 0; + improving = false; goto moves_loop; // Skip early pruning when in check } else if (ttHit) { // Never assume anything about values stored in TT @@ -458,7 +458,7 @@ Value search_NonPV(Pos *pos, Stack *ss, Value alpha, Depth depth, int cutNode) && bestValue > VALUE_MATED_IN_MAX_PLY) { // Skip quiet moves if movecount exceeds our FutilityMoveCount threshold - moveCountPruning = moveCount >= FutilityMoveCounts[improving][depth]; + moveCountPruning = moveCount >= futility_move_count(improving, depth); if ( !captureOrPromotion && !givesCheck) diff --git a/src/search.c b/src/search.c index 5995cc15..e7d599d9 100644 --- a/src/search.c +++ b/src/search.c @@ -63,8 +63,7 @@ INLINE int futility_margin(Depth d, int improving) { return 217 * (d - improving); } -// Futility and reductions lookup tables, initialized at startup -static int FutilityMoveCounts[2][16]; // [improving][depth] +// Reductions lookup table, initialized at startup static int Reductions[MAX_MOVES]; // [depth or moveNumber] INLINE Depth reduction(int i, Depth d, int mn) @@ -73,6 +72,11 @@ INLINE Depth reduction(int i, Depth d, int mn) return ((r + 511) / 1024 + (!i && r > 1007)); } +INLINE int futility_move_count(bool improving, Depth depth) +{ + return improving ? 5 + depth * depth - 1 : (5 + depth * depth) / 2 - 1; +} + // History and stats update bonus, based on depth static Value stat_bonus(Depth depth) { @@ -130,11 +134,6 @@ void search_init(void) { for (int i = 1; i < MAX_MOVES; i++) Reductions[i] = (24.8 + log(Threads.numThreads)) * log(i); - - for (int d = 0; d < 16; ++d) { - FutilityMoveCounts[0][d] = (5 + d * d) / 2 - 1; - FutilityMoveCounts[1][d] = 5 + d * d - 1; - } }