From 27e675aec44cd620f6cbf8cc372b4efc49216cf1 Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Mon, 30 Jan 2023 16:36:39 -0500 Subject: [PATCH] Added key check before TT write. --- src/search.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/search.c b/src/search.c index 1a79d2e..870fceb 100644 --- a/src/search.c +++ b/src/search.c @@ -280,6 +280,11 @@ int pvSearch(Board *board, int depth, int alpha, int beta, const int nullmove) { flag = LOWER_BOUND; // Always replace the entry for the TT + // UNLESS the position currently in there has a different key and goes deeper + if (tt[index].key != board->key && tt[index].depth > depth) { + return bestScore; + } + tt[index] = compressEntry(board->key, &bestMove, bestScore, depth, flag); return bestScore;