Merge pull request #7 from rektdie/fixedTimeout

Fixed timeout
This commit was merged in pull request #7.
This commit is contained in:
rektdie authored and GitHub committed 2025-03-05 00:51:45 +01:00
commit 43bf5a20a4
1 file changed
+4 -7
+4 -7
View File
@@ -84,8 +84,6 @@ void ListScores(Board &board) {
} }
static SearchResults Quiescence(Board board, int alpha, int beta) { static SearchResults Quiescence(Board board, int alpha, int beta) {
if (searchStopped) return beta - alpha;
if (!benchStarted) { if (!benchStarted) {
auto currTime = std::chrono::high_resolution_clock::now(); auto currTime = std::chrono::high_resolution_clock::now();
int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count(); int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count();
@@ -131,12 +129,11 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
} }
results.score = alpha; results.score = alpha;
if (searchStopped) return 0;
return results; return results;
} }
SearchResults PVS(Board board, int depth, int alpha, int beta) { SearchResults PVS(Board board, int depth, int alpha, int beta) {
if (searchStopped) return beta - alpha;
if (!benchStarted) { if (!benchStarted) {
auto currTime = std::chrono::high_resolution_clock::now(); auto currTime = std::chrono::high_resolution_clock::now();
int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count(); int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count();
@@ -221,6 +218,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
results.score = alpha; results.score = alpha;
WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove); WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
if (searchStopped) return 0;
return results; return results;
} }
@@ -235,11 +233,10 @@ static SearchResults ID(Board &board, SearchParams params) {
safeResults.score = -inf; safeResults.score = -inf;
for (int depth = 1; depth <= 99; depth++) { for (int depth = 1; depth <= 99; depth++) {
int timeRemaining = (fullTime / 20) + (inc / 2); timeToSearch = (fullTime / 20) + (inc / 2);
timeToSearch = timeRemaining;
SearchResults currentResults = PVS(board, depth, -inf, inf); SearchResults currentResults = PVS(board, depth, -inf, inf);
if (currentResults.score >= safeResults.score) { if (currentResults.bestMove) {
safeResults = currentResults; safeResults = currentResults;
} }