49class [[nodiscard]]
Engine final :
public uci::EngineBase {
65 [[nodiscard]]
auto get_name() const -> std::
string override;
66 [[nodiscard]] auto
get_author() const -> string_view
override {
return "Ben Vining"; }
72 void go(
const uci::GoCommandOptions& opts)
override;
76 void ponder_hit()
override { searcher.context.ponder_hit(); }
78 void wait()
override { searcher.context.wait(); }
80 auto is_searching() const noexcept ->
bool override {
return searcher.context.in_progress(); }
89 return customCommands;
92 void run_perft(string_view arguments)
const;
94 void run_bench(string_view arguments)
const;
96 void make_null_move();
99 void print_logo_and_version()
const;
100 void print_help(string_view args)
const;
101 void print_options();
102 void print_current_position(string_view arguments)
const;
104 void set_pretty_printing(
bool shouldPrettyPrint);
106 [[nodiscard]]
auto pretty_print_move(
Move move)
const -> std::string;
108 static void print_compiler_info();
110 static void start_file_logger(string_view arg);
112 void write_config_file(string_view arg)
const;
113 void read_config_file(string_view arg);
115 [[nodiscard]]
static auto create_move_format_option() -> uci::ComboOption;
119 searcher.context.resize_transposition_table(sizeMB);
126 if (not shouldPonder)
127 searcher.context.set_pondering(
false);
134 uci::Action clearTT {
137 "Press to clear the transposition table."
140 uci::IntOption threads {
142 "Number of searcher threads (currently a dummy)."
145 uci::IntOption moveOverhead {
146 "Move Overhead", 0, 5000, 10,
147 "Extra overhead time subtracted from search time (in ms). Increase this if engine loses on time."
150 uci::StringOption logFile {
151 "Debug Log File",
"<empty>",
152 "If not empty, engine I/O will be mirrored to this file.",
156 uci::BoolOption prettyPrintMode {
159 "When on, search output is pretty-printed instead of printed in UCI format.",
160 [
this](
const bool usePretty) { set_pretty_printing(usePretty); }
163 uci::ComboOption moveFormat { create_move_format_option() };
165 uci::BoolOption sanitizePositions {
166 "Sanitize Positions",
168 "When on, the engine checks if the position is legal before setting it.",
169 [
this](
const bool sanitize) { set_sanitize_positions(sanitize); }
172 std::array<uci::Option*, 7uz> options {
173 &clearTT, &threads, &moveOverhead, &logFile, &prettyPrintMode, &moveFormat, &sanitizePositions
176 std::array<EngineCommand, 10uz> customCommands {
179 .action = [
this](
const string_view args) { print_current_position(args); },
180 .description =
"Prints the current position",
181 .argsHelp =
"[utf8]" },
184 .action = EngineCommand::void_cb([
this] { make_null_move(); }),
185 .description =
"Play a null move on the internal board",
189 .action = EngineCommand::void_cb([
this] { color_flip(); }),
190 .description =
"Color-flip the current position",
194 .action = EngineCommand::void_cb([
this] { print_options(); }),
195 .description =
"Dump current UCI option values",
199 .action = [
this](
const string_view args) { run_perft(args); },
200 .description =
"Computes perft of the current position to the given depth",
201 .argsHelp =
"<N> [json]" },
204 .action = [
this](
const string_view args) { run_bench(args); },
205 .description =
"Runs a search and reports total nodes and NPS",
206 .argsHelp =
"[<depth>] [<epdPath>]" },
209 .action = EngineCommand::void_cb([] { print_compiler_info(); }),
210 .description =
"Print compiler info",
213 .name =
"writeconfig",
214 .action = [
this](
const string_view args) { write_config_file(args); },
215 .description =
"Writes the engine's current state to a configuration file at the given path",
216 .argsHelp =
"<path>" },
218 .name =
"readconfig",
219 .action = [
this](
const string_view args) { read_config_file(args); },
220 .description =
"Loads engine state from a configuration file at the given path",
221 .argsHelp =
"<path>" },
224 .action = [
this](
const string_view args) { print_help(args); },
225 .description =
"Display this text",
226 .argsHelp =
"[--no-logo]" }
void clear_transposition_table()