diff --git a/engine/src/agents/util/loggerthread.cpp b/engine/src/agents/util/loggerthread.cpp deleted file mode 100644 index 06c21e80..00000000 --- a/engine/src/agents/util/loggerthread.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - CrazyAra, a deep learning chess variant engine - Copyright (C) 2018 Johannes Czech, Moritz Willig, Alena Beyer - Copyright (C) 2019-2020 Johannes Czech - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - * @file: loggerthread.cpp - * Created on 23.04.2020 - * @author: queensgambit - */ - -#include "loggerthread.h" -#include -#include - -LoggerThread::LoggerThread(Node* rootNode, EvalInfo* evalInfo, size_t updateIntervalMS, vector& searchThreads): - KillableThread(), - rootNode(rootNode), - searchThreads(searchThreads), - evalInfo(evalInfo), - updateIntervalMS(updateIntervalMS) -{ - -} - -void LoggerThread::wait_and_log() -{ - while(isRunning) { - if (wait_for(chrono::milliseconds(updateIntervalMS))){ - evalInfo->end = chrono::steady_clock::now(); - update_eval_info(*evalInfo, rootNode, get_tb_hits(searchThreads), get_max_depth(searchThreads)); - info_score(*evalInfo); - } - } -} - -void run_logger_thread(LoggerThread *t) -{ - t->wait_and_log(); -} - -size_t get_avg_depth(const vector& searchThreads) -{ - size_t avgDetph = 0; - for (SearchThread* searchThread : searchThreads) { - avgDetph += searchThread->get_avg_depth(); - } - avgDetph = size_t(double(avgDetph) / searchThreads.size() + 0.5); - return avgDetph; -} - -size_t get_max_depth(const vector& searchThreads) -{ - size_t maxDepth = 0; - for (SearchThread* searchThread : searchThreads) { - maxDepth = max(maxDepth, searchThread->get_max_depth()); - } - return maxDepth; -} - -size_t get_tb_hits(const vector& searchThreads) -{ - size_t tbHits = 0; - for (SearchThread* searchThread : searchThreads) { - tbHits += searchThread->get_tb_hits(); - } - return tbHits; -} diff --git a/engine/src/agents/util/loggerthread.h b/engine/src/agents/util/loggerthread.h deleted file mode 100644 index 9ac0bb5d..00000000 --- a/engine/src/agents/util/loggerthread.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - CrazyAra, a deep learning chess variant engine - Copyright (C) 2018 Johannes Czech, Moritz Willig, Alena Beyer - Copyright (C) 2019-2020 Johannes Czech - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - * @file: loggerthread.h - * Created on 23.04.2020 - * @author: queensgambit - * - * The logger thread handles all logging tree functionality of the mcts - */ - -#ifndef LOGGERTHREAD_H -#define LOGGERTHREAD_H - -#include -#include -#include "../../node.h" -#include "../../evalinfo.h" -#include "../../searchthread.h" -#include "../../util/killablethread.h" - -using namespace std; - -/** - * @brief The LoggerThread class continues to log the evaluation information until the thread is stopped - */ -class LoggerThread : public KillableThread -{ -private: - Node* rootNode; - vector searchThreads; - - EvalInfo* evalInfo; - size_t updateIntervalMS; -public: - /** - * @brief wait_and_log Logs indefinetly with a certain logging interval until the conditional variable is triggered - */ - void wait_and_log(); - - LoggerThread(Node* rootNode, EvalInfo* evalInfo, size_t updateIntervalMS, vector& searchThreads); -}; - -/** - * @brief run_logger_thread Runner function for the LoggerThread - * @param t logger thread object - */ -void run_logger_thread(LoggerThread *t); - -/** - * @brief get_tb_hits Returns the number of current table base hits during search - * @param searchThreads MCTS search threads - * @return number of table base hits - */ -size_t get_tb_hits(const vector& searchThreads); - -size_t get_avg_depth(const vector& searchThreads); -size_t get_max_depth(const vector& searchThreads); - -#endif // LOGGERTHREAD_H