mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 02:27:00 +08:00
Transform search output to engine callbacks
Part 2 of the Split UCI into UCIEngine and Engine refactor. This creates function callbacks for search to use when an update should occur. The benching in uci.cpp for example does this to extract the total nodes searched. No functional change
This commit is contained in:
26
src/engine.h
26
src/engine.h
@@ -19,7 +19,14 @@
|
||||
#ifndef ENGINE_H_INCLUDED
|
||||
#define ENGINE_H_INCLUDED
|
||||
|
||||
#include "misc.h"
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "nnue/network.h"
|
||||
#include "position.h"
|
||||
#include "search.h"
|
||||
@@ -31,6 +38,10 @@ namespace Stockfish {
|
||||
|
||||
class Engine {
|
||||
public:
|
||||
using InfoShort = Search::InfoShort;
|
||||
using InfoFull = Search::InfoFull;
|
||||
using InfoIter = Search::InfoIteration;
|
||||
|
||||
Engine(std::string path = "");
|
||||
~Engine() { wait_for_search_finished(); }
|
||||
|
||||
@@ -51,9 +62,14 @@ class Engine {
|
||||
void set_ponderhit(bool);
|
||||
void search_clear();
|
||||
|
||||
void set_on_update_no_moves(std::function<void(const InfoShort&)>&&);
|
||||
void set_on_update_full(std::function<void(const InfoFull&)>&&);
|
||||
void set_on_iter(std::function<void(const InfoIter&)>&&);
|
||||
void set_on_bestmove(std::function<void(std::string_view, std::string_view)>&&);
|
||||
|
||||
// network related
|
||||
|
||||
void verify_networks();
|
||||
void verify_networks() const;
|
||||
void load_networks();
|
||||
void load_big_network(const std::string& file);
|
||||
void load_small_network(const std::string& file);
|
||||
@@ -61,9 +77,7 @@ class Engine {
|
||||
|
||||
// utility functions
|
||||
|
||||
void trace_eval();
|
||||
// nodes since last search clear
|
||||
uint64_t nodes_searched() const;
|
||||
void trace_eval() const;
|
||||
OptionsMap& get_options();
|
||||
|
||||
private:
|
||||
@@ -76,6 +90,8 @@ class Engine {
|
||||
ThreadPool threads;
|
||||
TranspositionTable tt;
|
||||
Eval::NNUE::Networks networks;
|
||||
|
||||
Search::SearchManager::UpdateContext updateContext;
|
||||
};
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
Reference in New Issue
Block a user