57class [[nodiscard]]
Engine :
public uci::EngineBase {
88 return searcher.context.get_options();
97 return moveFormat.get_enum_value();
102 Move move,
const Position& position)
const -> std::string;
113 [[nodiscard]]
auto get_name() const -> std::
string override;
114 [[nodiscard]] auto
get_author() const -> string_view
override {
return "Ben Vining"; }
120 void go(
const uci::GoCommandOptions& opts)
override;
126 void ponder_hit()
override { searcher.context.ponder_hit(); }
128 void wait()
override { searcher.context.wait(); }
130 auto is_searching() const noexcept ->
bool override {
return searcher.context.in_progress(); }
139 return customCommands;
142 void run_perft(string_view arguments)
const;
144 void run_bench(string_view arguments)
const;
146 void make_null_move();
149 void print_logo_and_version()
const;
150 void print_help(string_view args)
const;
151 void print_options();
152 void print_current_position(string_view arguments)
const;
154 void init_search_callbacks();
156 static void print_compiler_info();
158 static void start_file_logger(string_view arg);
160 void write_config_file(string_view arg)
const;
161 void read_config_file(string_view arg);
165 searcher.context.resize_transposition_table(sizeMB);
172 if (not shouldPonder)
173 searcher.context.set_pondering(
false);
180 uci::Action clearTT {
183 "Press to clear the transposition table."
186 uci::IntOption threads {
188 "Number of searcher threads (currently a dummy)."
191 uci::IntOption moveOverhead {
192 "Move Overhead", 0, 5000, 10,
193 "Extra overhead time subtracted from search time (in ms). Increase this if engine loses on time."
196 uci::IntOption multiPV {
198 "Number of best lines to search for and report."
201 uci::StringOption logFile {
202 "Debug Log File",
"<empty>",
203 "If not empty, engine I/O will be mirrored to this file.",
207 uci::BoolOption prettyPrintMode {
210 "When on, search output is pretty-printed instead of printed in UCI format.",
211 [
this]([[maybe_unused]]
const bool usePretty) { init_search_callbacks(); }
214 uci::EnumOption<MoveFormat> moveFormat {
216 MoveFormat::Algebraic,
217 "Notation format used to display moves in pretty printing mode."
220 uci::BoolOption algFormatUTF8PieceType {
221 "Algebraic Format UTF8",
223 "When on and printing algebraic move format, uses UTF8 glyphs for piece types."
226 uci::BoolOption sanitizePositions {
227 "Sanitize Positions",
229 "When on, the engine checks if the position is legal before setting it.",
230 [
this](
const bool sanitize) { set_sanitize_positions(sanitize); }
233 std::array<uci::Option*, 9uz> options {
234 &clearTT, &threads, &moveOverhead, &multiPV, &logFile, &prettyPrintMode, &moveFormat, &algFormatUTF8PieceType, &sanitizePositions
237 std::array<EngineCommand, 10uz> customCommands {
240 .action = [
this](
const string_view args) { print_current_position(args); },
241 .description =
"Prints the current position",
242 .argsHelp =
"[utf8]" },
245 .action = EngineCommand::void_cb([
this] { make_null_move(); }),
246 .description =
"Play a null move on the internal board",
250 .action = EngineCommand::void_cb([
this] { color_flip(); }),
251 .description =
"Color-flip the current position",
255 .action = EngineCommand::void_cb([
this] { print_options(); }),
256 .description =
"Dump current UCI option values",
260 .action = [
this](
const string_view args) { run_perft(args); },
261 .description =
"Computes perft of the current position to the given depth",
262 .argsHelp =
"<N> [json]" },
265 .action = [
this](
const string_view args) { run_bench(args); },
266 .description =
"Runs a search and reports total nodes and NPS",
267 .argsHelp =
"[<depth>] [<epdPath>]" },
270 .action = EngineCommand::void_cb([] { print_compiler_info(); }),
271 .description =
"Print compiler info",
274 .name =
"writeconfig",
275 .action = [
this](
const string_view args) { write_config_file(args); },
276 .description =
"Writes the engine's current state to a configuration file at the given path",
277 .argsHelp =
"<path>" },
279 .name =
"readconfig",
280 .action = [
this](
const string_view args) { read_config_file(args); },
281 .description =
"Loads engine state from a configuration file at the given path",
282 .argsHelp =
"<path>" },
285 .action = [
this](
const string_view args) { print_help(args); },
286 .description =
"Display this text",
287 .argsHelp =
"[--no-logo]" }
void clear_transposition_table()