From 7d04b8b237e974797cbd45e5073d85a5e876e77c Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 10 Aug 2026 17:47:58 +0200 Subject: fixing isseu #1 --- src/bot.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/bot.cpp') diff --git a/src/bot.cpp b/src/bot.cpp index 4682998..ef6f647 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -307,6 +307,15 @@ Move GetBestMove(Game *b, int maxDepth, move_options options) { while (continueSearching) { SearchResult result = SearchDepth(b, depth, &bestMove); + + // If the clock expired inside this iteration, the returned score/move may + // come from a partially searched tree. Keep the last fully completed + // iteration instead of reporting INF as a fake mate or playing a random + // first move. + if (searchStopped) { + break; + } + bestMove = result.bestMove; auto now = std::chrono::steady_clock::now(); @@ -335,9 +344,6 @@ Move GetBestMove(Game *b, int maxDepth, move_options options) { if (elapsedSeconds >= MAXIMUM_TIME_PER_MOVE && usingDefaultDepth) { continueSearching = false; } - if (searchStopped) { - continueSearching = false; - } } return bestMove; -- cgit v1.2.3