X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=d095aefeb6a6f875746a67ab68d782e32d031e28;hp=208cb0b1279d07f23f0b530c8b599b1444ab9bcb;hb=e385f194e970f0675bd4c3509bca4a6c81b6df5e;hpb=7b4c9852e1421ebe6ec326c38f04ad575ad91053;ds=sidebyside diff --git a/src/thread.cpp b/src/thread.cpp index 208cb0b1..d095aefe 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -35,6 +35,7 @@ ThreadPool Threads; // Global object Thread::Thread(size_t n) : idx(n), stdThread(&Thread::idle_loop, this) { wait_for_search_finished(); + clear(); // Zero-init histories (based on std::array) } @@ -51,6 +52,20 @@ Thread::~Thread() { } +/// Thread::clear() reset histories, usually before a new game + +void Thread::clear() { + + counterMoves.fill(MOVE_NONE); + mainHistory.fill(0); + + for (auto& to : contHistory) + for (auto& h : to) + h.fill(0); + + contHistory[NO_PIECE][0].fill(Search::CounterMovePruneThreshold - 1); +} + /// Thread::start_searching() wakes up the thread that will start the search void Thread::start_searching() {