diff --git a/src/main.cpp b/src/main.cpp index 6fee591d..2963f75e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,12 +41,13 @@ int main(int argc, char* argv[]) { Search::init(); Eval::init(); Pawns::init(); - Threads.init(); Tablebases::init(Options["SyzygyPath"]); TT.resize(Options["Hash"]); + Threads.init(); UCI::loop(argc, argv); Threads.exit(); + Tablebases::free(); return 0; } diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index e75a0da2..a1e4f304 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1776,7 +1776,7 @@ WDLScore probe_ab(Position& pos, WDLScore alpha, WDLScore beta, int *success) } // namespace -void Tablebases::init(const std::string& paths) +void Tablebases::free() { for (int i = 0; i < TBnum_piece; ++i) free_wdl_entry(&TB_piece[i]); @@ -1794,6 +1794,12 @@ void Tablebases::init(const std::string& paths) TBnum_piece = TBnum_pawn = 0; MaxCardinality = 0; +} + +void Tablebases::init(const std::string& paths) +{ + + Tablebases::free(); TBPaths = paths; if (TBPaths.empty() || TBPaths == "") @@ -2373,4 +2379,3 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, Val return true; } - diff --git a/src/syzygy/tbprobe.h b/src/syzygy/tbprobe.h index 3bc63b8e..616b2d98 100644 --- a/src/syzygy/tbprobe.h +++ b/src/syzygy/tbprobe.h @@ -16,6 +16,7 @@ enum WDLScore { extern int MaxCardinality; void init(const std::string& paths); +void free(); WDLScore probe_wdl(Position& pos, int* success); int probe_dtz(Position& pos, int* success); bool root_probe(Position& pos, Search::RootMoves& rootMoves, Value& score);