From cdbf9d4b280abc1fe1bd140f18c632dd6c7116c1 Mon Sep 17 00:00:00 2001 From: rektdie Date: Tue, 15 Oct 2024 19:07:25 +0200 Subject: [PATCH] major bugfix in ID(used to pass SearchParams as reference) --- .gitignore | 2 +- Makefile | 2 +- source/search.cpp | 9 +++++---- source/search.h | 2 +- source/uci.cpp | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index cb0feea..f60144a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ obj/ # Ignore executable files *.exe -Engine-Eleanor +Eleanor diff --git a/Makefile b/Makefile index ae288ed..9cd34eb 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ OBJ_DIR := obj CXX ?= g++ # Set default executable name, but allow override from the command line -EXE ?= Engine-Eleanor +EXE ?= Eleanor # Determine platform ifeq ($(OS),Windows_NT) diff --git a/source/search.cpp b/source/search.cpp index d2d9756..7908697 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -121,6 +121,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { if (!benchStarted) { auto currTime = std::chrono::high_resolution_clock::now(); int elapsed = std::chrono::duration_cast(currTime - timeStart).count(); + if (elapsed >= timeToSearch) { StopSearch(); return 0; @@ -187,15 +188,15 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { } // Iterative deepening -static SearchResults ID(Board &board, SearchParams ¶ms) { +static SearchResults ID(Board &board, SearchParams params) { timeStart = std::chrono::high_resolution_clock::now(); int fullTime = board.sideToMove ? params.btime : params.wtime; int inc = board.sideToMove ? params.binc : params.winc; SearchResults safeResults; - for (int depth = 1; depth <= 8; depth++) { - int timeRemaining = fullTime / 20 + inc / 2; + for (int depth = 1; depth <= 99; depth++) { + int timeRemaining = (fullTime / 20) + (inc / 2); timeToSearch = timeRemaining; SearchResults currentResults = PVS(board, depth, -50000, 50000); @@ -209,7 +210,7 @@ static SearchResults ID(Board &board, SearchParams ¶ms) { return safeResults; } -void SearchPosition(Board &board, SearchParams ¶ms) { +void SearchPosition(Board &board, SearchParams params) { searchStopped = false; nodes = 0; diff --git a/source/search.h b/source/search.h index a302032..f55806f 100644 --- a/source/search.h +++ b/source/search.h @@ -23,7 +23,7 @@ public: }; SearchResults PVS(Board board, int depth, int alpha, int beta); -void SearchPosition(Board &board, SearchParams ¶ms); +void SearchPosition(Board &board, SearchParams params); void StopSearch(); constexpr int moveScoreTable[6][6] = { diff --git a/source/uci.cpp b/source/uci.cpp index 0bc4b44..96353ff 100644 --- a/source/uci.cpp +++ b/source/uci.cpp @@ -146,7 +146,7 @@ static int ReadParam(std::string param, std::string &command) { std::string result = ""; pos += param.length() + 1; - while(pos <= command.length() && std::isdigit(command[pos])){ + while(pos < command.length() && std::isdigit(command[pos])){ result += command[pos]; pos++; } @@ -165,7 +165,7 @@ void ParseGo(Board &board, std::string &command) { params.binc = ReadParam("binc", command); params.movesToGo = ReadParam("movestogo", command); - auto worker = std::thread(SearchPosition, std::ref(board), std::ref(params)); + auto worker = std::thread(SearchPosition, std::ref(board), params); worker.detach(); }