50class [[nodiscard]]
Engine final :
public uci::EngineBase {
66 [[nodiscard]]
auto get_name() const -> std::
string override;
67 [[nodiscard]] auto
get_author() const -> string_view
override {
return "Ben Vining"; }
73 void go(
const uci::GoCommandOptions& opts)
override;
77 void ponder_hit()
override { searcher.context.ponder_hit(); }
79 void wait()
override { searcher.context.wait(); }
81 auto is_searching() const noexcept ->
bool override {
return searcher.context.in_progress(); }
85 debugMode.store(shouldDebug, std::memory_order::relaxed);
88 [[nodiscard]]
auto get_options() -> std::span<uci::Option*>
override {
return options; }
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()
const;
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;
115 [[nodiscard]]
static auto create_move_format_option() -> uci::ComboOption;
117 std::atomic_bool debugMode {
false };
123 uci::IntOption ttSize {
126 "Sets the maximum transposition table size (in MB).",
127 [
this](
const int sizeMB) {
132 uci::Action clearTT {
135 "Press to clear the transposition table."
142 uci::BoolOption ponder {
145 "Controls whether pondering is allowed.",
146 [
this](
const bool shouldPonder) {
149 if (not shouldPonder)
154 uci::IntOption threads {
156 "Number of searcher threads (currently a dummy)."
159 uci::IntOption moveOverhead {
160 "Move Overhead", 0, 5000, 10,
161 "Extra overhead time subtracted from search time (in ms). Increase this if engine loses on time."
164 uci::StringOption logFile {
165 "Debug Log File",
"<empty>",
166 "If not empty, engine I/O will be mirrored to this file.",
170 uci::BoolOption prettyPrintMode {
173 "When on, search output is pretty-printed instead of printed in UCI format.",
174 [
this](
const bool usePretty) { set_pretty_printing(usePretty); }
177 uci::ComboOption moveFormat { create_move_format_option() };
179 std::array<uci::Option*, 8uz> options {
180 &ttSize, &clearTT, &ponder, &threads, &moveOverhead, &logFile, &prettyPrintMode, &moveFormat
186 std::array<CustomCommand, 10uz> customCommands {
189 .action = [
this](
const string_view args){ print_current_position(args); },
190 .description =
"Prints the current position",
195 .action = CustomCommand::void_cb([
this]{ make_null_move(); }),
196 .description =
"Play a null move on the internal board",
201 .action = CustomCommand::void_cb([
this]{ color_flip(); }),
202 .description =
"Color-flip the current position",
207 .action = CustomCommand::void_cb([
this]{ print_options(); }),
208 .description =
"Dump current UCI option values",
213 .action = [
this](
const string_view args) { run_perft(args); },
214 .description =
"Computes perft of the current position to the given depth",
215 .argsHelp =
"<N> [json]"
219 .action = [
this](
const string_view args){ run_bench(args); },
220 .description =
"Runs a search and reports total nodes and NPS",
221 .argsHelp =
"[<depth>] [<epdPath>]"
225 .action = CustomCommand::void_cb([]{ print_compiler_info(); }),
226 .description =
"Print compiler info",
230 .name =
"writeconfig",
231 .action = [
this](
const string_view args) { write_config_file(args); },
232 .description =
"Writes the engine's current state to a configuration file at the given path",
236 .name =
"readconfig",
237 .action = [
this](
const string_view args) { read_config_file(args); },
238 .description =
"Loads engine state from a configuration file at the given path",
243 .action = [
this] (
const string_view args){ print_help(args); },
244 .description =
"Display this text",
245 .argsHelp =
"[--no-logo]"
void clear_transposition_table()
void resize_transposition_table(size_t sizeMB)
void set_pondering(const bool isPonderMode) noexcept