From dd6f0b94f52230adf38a5e63c6e31fef8aec1584 Mon Sep 17 00:00:00 2001 From: rektdie Date: Fri, 11 Apr 2025 03:59:05 +0200 Subject: [PATCH] encapsulated killerMoves and changed it to std::array --- source/benchmark.cpp | 2 -- source/datagen.cpp | 2 -- source/search.cpp | 8 ++++---- source/search.h | 6 +++--- source/uci.cpp | 3 ++- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/source/benchmark.cpp b/source/benchmark.cpp index 72e702c..4c24ac1 100644 --- a/source/benchmark.cpp +++ b/source/benchmark.cpp @@ -69,7 +69,6 @@ void RunBenchmark() { // Clearing TT.Clear(); - std::memset(killerMoves, 0, sizeof(killerMoves)); SearchContext ctx; @@ -82,6 +81,5 @@ void RunBenchmark() { std::cout << ctx.nodes << " nodes " << int(ctx.nodes/sw.GetElapsedSec()) << " nps" << std::endl; TT.Clear(); - std::memset(killerMoves, 0, sizeof(killerMoves)); positionIndex = 0; } diff --git a/source/datagen.cpp b/source/datagen.cpp index 6668f07..573f47a 100644 --- a/source/datagen.cpp +++ b/source/datagen.cpp @@ -102,8 +102,6 @@ void PlayGame(std::atomic& positions, U64 targetPositions, std::vector= beta) { if (!currMove.IsCapture()) { - killerMoves[1][ply] = killerMoves[0][ply]; - killerMoves[0][ply] = currMove; + ctx.killerMoves[1][ply] = ctx.killerMoves[0][ply]; + ctx.killerMoves[0][ply] = currMove; int bonus = depth * depth; diff --git a/source/search.h b/source/search.h index e897898..dd0ce78 100644 --- a/source/search.h +++ b/source/search.h @@ -22,9 +22,6 @@ constexpr int MAX_HISTORY = 16384; constexpr int inf = 100000; -// [id][ply] -inline int killerMoves[2][MAX_PLY]; - inline int lmrTable[MAX_DEPTH+1][MAX_MOVES]; void InitLMRTable(); @@ -115,12 +112,15 @@ public: PVLine pvLine; History history; + std::array, 2> killerMoves{}; + Stopwatch sw; SearchContext(){ pvLine.Clear(); history.Clear(); sw.Restart(); + killerMoves = {}; } }; diff --git a/source/uci.cpp b/source/uci.cpp index 3097a92..01e131a 100644 --- a/source/uci.cpp +++ b/source/uci.cpp @@ -136,9 +136,10 @@ void UCILoop(Board &board) { // Clearing TT.Clear(); - std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves)); + ctx.killerMoves = {}; ctx.history.Clear(); + positionIndex = 0; continue;