Split UCI into UCIEngine and Engine

This is another refactor which aims to decouple uci from stockfish. A new engine
class manages all engine related logic and uci is a "small" wrapper around it.

In the future we should also try to remove the need for the Position object in
the uci and replace the options with an actual options struct instead of using a
map. Also convert the std::string's in the Info structs a string_view.

closes #5147

No functional change
This commit is contained in:
Disservin
2024-03-17 12:33:14 +01:00
parent 0716b845fd
commit 299707d2c2
14 changed files with 341 additions and 149 deletions

View File

@@ -22,6 +22,7 @@
#include <iostream>
#include <string>
#include "engine.h"
#include "misc.h"
#include "nnue/network.h"
#include "position.h"
@@ -36,9 +37,9 @@ class Move;
enum Square : int;
using Value = int;
class UCI {
class UCIEngine {
public:
UCI(int argc, char** argv);
UCIEngine(int argc, char** argv);
void loop();
@@ -47,25 +48,17 @@ class UCI {
static std::string square(Square s);
static std::string move(Move m, bool chess960);
static std::string wdl(Value v, const Position& pos);
static Move to_move(const Position& pos, std::string& str);
static Move to_move(const Position& pos, std::string str);
static Search::LimitsType parse_limits(const Position& pos, std::istream& is);
const std::string& working_directory() const { return cli.workingDirectory; }
OptionsMap options;
Eval::NNUE::Networks networks;
private:
TranspositionTable tt;
ThreadPool threads;
CommandLine cli;
Engine engine;
CommandLine cli;
void go(Position& pos, std::istringstream& is, StateListPtr& states);
void bench(Position& pos, std::istream& args, StateListPtr& states);
void position(Position& pos, std::istringstream& is, StateListPtr& states);
void trace_eval(Position& pos);
void search_clear();
void go(Position& pos, std::istringstream& is);
void bench(Position& pos, std::istream& args);
void position(std::istringstream& is);
void setoption(std::istringstream& is);
};