From 762e250122b2da6770fcd903d0d6f2031a7f8906 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 5 Mar 2025 00:40:40 +0100 Subject: [PATCH] changed search stop returning logic --- source/search.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index e9e10d7..5973400 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -84,8 +84,6 @@ void ListScores(Board &board) { } static SearchResults Quiescence(Board board, int alpha, int beta) { - if (searchStopped) return 0; - if (!benchStarted) { auto currTime = std::chrono::high_resolution_clock::now(); int elapsed = std::chrono::duration_cast(currTime - timeStart).count(); @@ -114,8 +112,6 @@ static SearchResults Quiescence(Board board, int alpha, int beta) { SearchResults results; for (int i = 0; i < board.currentMoveIndex; i++) { - if (searchStopped) return 0; - if (board.moveList[i].IsCapture()) { Board copy = board; copy.MakeMove(board.moveList[i]); @@ -133,12 +129,11 @@ static SearchResults Quiescence(Board board, int alpha, int beta) { } results.score = alpha; + if (searchStopped) return 0; return results; } SearchResults PVS(Board board, int depth, int alpha, int beta) { - if (searchStopped) return 0; - if (!benchStarted) { auto currTime = std::chrono::high_resolution_clock::now(); int elapsed = std::chrono::duration_cast(currTime - timeStart).count(); @@ -181,8 +176,6 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { // For all moves for (int i = 0; i < board.currentMoveIndex; i++) { - if (searchStopped) return 0; - Board copy = board; copy.MakeMove(copy.moveList[i]); @@ -225,6 +218,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { results.score = alpha; WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove); + if (searchStopped) return 0; return results; } @@ -242,7 +236,7 @@ static SearchResults ID(Board &board, SearchParams params) { timeToSearch = (fullTime / 20) + (inc / 2); SearchResults currentResults = PVS(board, depth, -inf, inf); - if (currentResults.bestMove && currentResults.score >= safeResults.score) { + if (currentResults.bestMove) { safeResults = currentResults; }