From 68b5168a400bc8746b79cb679fe75843bf77b04f Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 17:50:40 +0100 Subject: [PATCH 1/6] storing to TT after checking if search stopped | bench 684523 --- source/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/search.cpp b/source/search.cpp index 31c7d2b..99696c8 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -303,8 +303,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { } } - TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove); if (searchStopped) return 0; + TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove); return results; } From b9f8a5be5a98a6d9db1ecf02f29f6f291f2ded11 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 20:50:47 +0100 Subject: [PATCH 2/6] fixed it in beta cutoff as well | bench 684523 --- source/search.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/search.cpp b/source/search.cpp index 99696c8..c0814fd 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -281,6 +281,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { history.Update(board.sideToMove, currMove, depth * depth); } + if (searchStopped) return 0; TT.WriteEntry(board.hashKey, depth, score, CutNode, Move()); return score; } From be0ea7ba3091d441896a78321e59bae5c6831406 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 21:05:57 +0100 Subject: [PATCH 3/6] checking for stop before history update | bench 684523 --- source/search.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/search.cpp b/source/search.cpp index c0814fd..b4c3175 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -278,6 +278,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { killerMoves[1][ply] = killerMoves[0][ply]; killerMoves[0][ply] = currMove; + if (searchStopped) return 0; history.Update(board.sideToMove, currMove, depth * depth); } From 7e123bdb944a0c44711a889080e3ba3b1c7a4bcd Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 21:10:49 +0100 Subject: [PATCH 4/6] bugfix in ID | bench 684523 --- source/search.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index b4c3175..4e4f001 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -351,10 +351,6 @@ static SearchResults ID(Board &board, SearchParams params) { beta = currentResults.score + delta; delta = 50; - if (currentResults.bestMove) { - safeResults = currentResults; - } - if (searchStopped) { break; } else { @@ -362,6 +358,10 @@ static SearchResults ID(Board &board, SearchParams params) { StopSearch(); break; } + + if (currentResults.bestMove) { + safeResults = currentResults; + } } std::cout << "info "; From 249806f51c3fc77eb8cbd770ffccb69918686508 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 21:18:13 +0100 Subject: [PATCH 5/6] setting safeResults before checking softtime | bench 684523 --- source/search.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 4e4f001..62c7a24 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -351,19 +351,6 @@ static SearchResults ID(Board &board, SearchParams params) { beta = currentResults.score + delta; delta = 50; - if (searchStopped) { - break; - } else { - if (sw.GetElapsedMS() >= softTime) { - StopSearch(); - break; - } - - if (currentResults.bestMove) { - safeResults = currentResults; - } - } - std::cout << "info "; std::cout << "depth " << depth; std::cout << " score cp " << safeResults.score; @@ -372,6 +359,19 @@ static SearchResults ID(Board &board, SearchParams params) { std::cout << " pv "; pvLine.Print(0); std::cout << std::endl; + + if (searchStopped) { + break; + } else { + if (currentResults.bestMove) { + safeResults = currentResults; + } + + if (sw.GetElapsedMS() >= softTime) { + StopSearch(); + break; + } + } } return safeResults; From 0181e53e74d23d1f81de3c9202d6f19a844fad63 Mon Sep 17 00:00:00 2001 From: rektdie Date: Thu, 27 Mar 2025 00:12:08 +0100 Subject: [PATCH 6/6] final touches | bench 684523 --- .gitignore | 3 +++ source/search.cpp | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index f60144a..52d905e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ obj/ # Ignore executable files *.exe Eleanor + +# Other +.vscode \ No newline at end of file diff --git a/source/search.cpp b/source/search.cpp index 62c7a24..b542487 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -274,15 +274,15 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { // Fail high (beta cutoff) if (score >= beta) { + if (searchStopped) return 0; if (!currMove.IsCapture()) { killerMoves[1][ply] = killerMoves[0][ply]; killerMoves[0][ply] = currMove; - if (searchStopped) return 0; + history.Update(board.sideToMove, currMove, depth * depth); } - if (searchStopped) return 0; TT.WriteEntry(board.hashKey, depth, score, CutNode, Move()); return score; } @@ -351,21 +351,21 @@ static SearchResults ID(Board &board, SearchParams params) { beta = currentResults.score + delta; delta = 50; - std::cout << "info "; - std::cout << "depth " << depth; - std::cout << " score cp " << safeResults.score; - std::cout << " nodes " << nodes << " nps " << int(nodes/sw.GetElapsedSec()); - std::cout << " hashfull " << TT.GetUsedPercentage(); - std::cout << " pv "; - pvLine.Print(0); - std::cout << std::endl; - if (searchStopped) { break; } else { if (currentResults.bestMove) { safeResults = currentResults; } + + std::cout << "info "; + std::cout << "depth " << depth; + std::cout << " score cp " << safeResults.score; + std::cout << " nodes " << nodes << " nps " << int(nodes/sw.GetElapsedSec()); + std::cout << " hashfull " << TT.GetUsedPercentage(); + std::cout << " pv "; + pvLine.Print(0); + std::cout << std::endl; if (sw.GetElapsedMS() >= softTime) { StopSearch();