diff --git a/source/main.cpp b/source/main.cpp index db3c6d0..6135535 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -44,12 +44,16 @@ int main(int argc, char* argv[]) { - MOVEGEN::initLeaperAttacks(); - MOVEGEN::initSliderAttacks(); - UTILS::InitZobrist(); - SEARCH::InitLMRTable(); - - Board board; + MOVEGEN::initLeaperAttacks(); + MOVEGEN::initSliderAttacks(); + UTILS::InitZobrist(); + #ifdef TUNING + SEARCH::RefreshTunableCaches(); + #else + SEARCH::InitLMRTable(); + #endif + + Board board; if (argc > 1) { if (std::string(argv[1]) == "bench") { diff --git a/source/search.cpp b/source/search.cpp index 424bbde..56a67bb 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -50,6 +50,19 @@ void InitLMRTable() { } } +#ifdef TUNING +void InitSEEPieceValues() { + SEEPieceValues = { + seePawnValue, seeKnightValue, seeBishopValue, seeRookValue, seeQueenValue, 0 + }; +} + +void RefreshTunableCaches() { + InitLMRTable(); + InitSEEPieceValues(); +} +#endif + int16_t ContHistory::GetNPly(Board& board, Move& move, SearchContext* ctx, int ply, int n) { int prevType = ctx->ss[ply-n].pieceType; int prevTo = ctx->ss[ply-n].moveTo; diff --git a/source/search.h b/source/search.h index 10af2e2..21d075f 100644 --- a/source/search.h +++ b/source/search.h @@ -48,6 +48,12 @@ constexpr std::array SEEPieceValues = { #endif void InitLMRTable(); + +#ifdef TUNING +void InitSEEPieceValues(); +void RefreshTunableCaches(); +#endif + class SearchContext; class CaptHistory { diff --git a/source/uci.cpp b/source/uci.cpp index 26354b4..1f71a8b 100644 --- a/source/uci.cpp +++ b/source/uci.cpp @@ -206,6 +206,7 @@ static void SetOption(std::string& command, SEARCH::SearchContext* ctx) { if (v < min_val) v = min_val; \ if (v > max_val) v = max_val; \ paramName = v; \ + SEARCH::RefreshTunableCaches(); \ return; \ } @@ -215,6 +216,7 @@ static void SetOption(std::string& command, SEARCH::SearchContext* ctx) { if (v < min_val) v = min_val; \ if (v > max_val) v = max_val; \ paramName = v; \ + SEARCH::RefreshTunableCaches(); \ return; \ }