aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-10 17:47:58 +0200
committerAdam <adammegarules1@gmail.com>2026-08-10 17:47:58 +0200
commit7d04b8b237e974797cbd45e5073d85a5e876e77c (patch)
tree30b12c9c289b458a244b6427c921bd71fe74e2f4 /src
parentfce224ff7c02fb416ae9269f7d9ca64f3522adc6 (diff)
fixing isseu #1
Diffstat (limited to 'src')
-rw-r--r--src/bot.cpp12
1 files changed, 9 insertions, 3 deletions
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;