|
BenBot 1.7.5
A chess engine
|
#include <libchess/uci/EngineBase.hpp>
Public Types | |
| using | CommandList = std::span<const EngineCommand> |
| using | OptionList = std::span<Option*> |
Public Member Functions | |
| EngineBase ()=default | |
| EngineBase (const EngineBase &)=delete | |
| EngineBase (EngineBase &&)=delete | |
| virtual | ~EngineBase () |
| virtual void | abort_search () |
| virtual auto | get_author () const -> string_view=0 |
| virtual auto | get_custom_uci_commands () const noexcept -> CommandList |
| virtual auto | get_custom_uci_options () noexcept -> OptionList |
| virtual auto | get_name () const -> std::string=0 |
| auto | get_standard_uci_commands () const noexcept -> CommandList |
| auto | get_standard_uci_options () noexcept -> OptionList |
| virtual void | go (const GoCommandOptions &opts)=0 |
| void | handle_command (string_view command) |
| virtual void | handle_registration (const RegisterOptions &opts) |
| auto | is_debug_mode () const noexcept -> bool |
| virtual auto | is_searching () const noexcept -> bool=0 |
| void | loop () |
| virtual void | new_game (bool firstCall) |
| EngineBase & | operator= (const EngineBase &)=delete |
| EngineBase & | operator= (EngineBase &&)=delete |
| virtual void | ponder_hit () |
| virtual void | resize_transposition_table (const size_t sizeMB) |
| void | set_debug_mode (const bool shouldDebug) noexcept |
| virtual void | set_ponder (const bool shouldPonder) |
| virtual void | set_position (const Position &pos) |
| void | set_sanitize_positions (const bool shouldSanitize) noexcept |
| virtual void | wait () |
Public Attributes | |
| IntOption | opt_Hash |
| BoolOption | opt_Ponder |
A base class for UCI [3] chess engines.
This class provides handling of UCI command parsing, so that the engine implementation can focus purely on implementing evaluation and search. UCI printing is provided by the functions in the uci::printing namespace.
To use this class, implement a derived class, then in your program's main() function, create an instance of your derived engine class and call its loop() method.
Definition at line 91 of file EngineBase.hpp.
| using chess::uci::EngineBase::CommandList = std::span<const EngineCommand> |
Typedef for a view of a list of engine commands.
Definition at line 171 of file EngineBase.hpp.
| using chess::uci::EngineBase::OptionList = std::span<Option*> |
Typedef for a view of a list of engine options.
Definition at line 186 of file EngineBase.hpp.
|
default |
|
virtual |
|
delete |
|
delete |
|
inlinevirtual |
This function is called when the search should be exited.
Reimplemented in ben_bot::Engine.
Definition at line 132 of file EngineBase.hpp.
|
nodiscardpure virtual |
This must return the name of the engine's author.
Implemented in ben_bot::Engine.
|
inlinenodiscardvirtualnoexcept |
Subclasses should overload this to return their custom UCI commands.
Reimplemented in ben_bot::Engine.
Definition at line 180 of file EngineBase.hpp.
|
inlinenodiscardvirtualnoexcept |
Subclasses should overload this to return their custom UCI options.
Reimplemented in ben_bot::Engine.
Definition at line 189 of file EngineBase.hpp.
|
nodiscardpure virtual |
This must return the name of the engine. The returned string may optionally contain the engine's current version, such as BenBot 1.2.0.
Implemented in ben_bot::Engine.
|
inlinenodiscardnoexcept |
Returns the engine's list of supported standard UCI commands.
Definition at line 174 of file EngineBase.hpp.
|
inlinenodiscardnoexcept |
Returns the engine's list of supported standard UCI commands.
Definition at line 195 of file EngineBase.hpp.
|
pure virtual |
Called when the "go" command is received. The engine should begin searching. After this function has been called, the engine should print to stdout a line of the form "bestmove <from><to>".
| void chess::uci::EngineBase::handle_command | ( | string_view | command | ) |
|
inlinevirtual |
Called when the user send a "register" command. The engine may simply do nothing if it does not require registration.
Definition at line 168 of file EngineBase.hpp.
|
inlinenodiscardnoexcept |
Returns true if the engine's debugging mode is active.
Definition at line 201 of file EngineBase.hpp.
|
nodiscardpure virtualnoexcept |
This function must return true if a search is currently in progress. This function should be thread-safe.
Implemented in ben_bot::Engine.
| void chess::uci::EngineBase::loop | ( | ) |
Runs the engine's event loop. This function blocks while reading from stdin. The calling thread becomes the engine's "main thread".
|
inlinevirtual |
This function will be called when the "ucinewgame" command is received. This should flush any game-specific data structures such as hash tables, transposition table, etc. wait() will be called after this, before the next search begins.
| firstCall | True if this is the first time new_game() has been called. |
Reimplemented in ben_bot::Engine.
Definition at line 129 of file EngineBase.hpp.
|
delete |
|
delete |
|
inlinevirtual |
This function is called when the "ponderhit" command is received. This means that the engine was told to ponder on the same move the user has played. The engine should continue searching but switch from pondering to normal search.
Reimplemented in ben_bot::Engine.
Definition at line 138 of file EngineBase.hpp.
|
inlinevirtual |
Subclasses should implement this to resize their transposition table.
Reimplemented in ben_bot::Engine.
Definition at line 225 of file EngineBase.hpp.
|
inlinenoexcept |
Sets the engine's debugging mode.
Definition at line 207 of file EngineBase.hpp.
|
inlinevirtual |
Subclasses can implement this to be informed when the ponder parameter changes.
Reimplemented in ben_bot::Engine.
Definition at line 228 of file EngineBase.hpp.
|
inlinevirtual |
Called when a new position is received from the GUI.
Reimplemented in ben_bot::Engine.
Definition at line 141 of file EngineBase.hpp.
|
inlinenoexcept |
Tells the base class whether to sanitize incoming positions when processing the position command. When sanitizing is on, after evaluating each position command, the engine performs some basic checks to determine if the position is illegal, and if so, prints a diagnostic message and reverts the internal board to the previous position.
Definition at line 219 of file EngineBase.hpp.
|
inlinevirtual |
This function will be called when the "isready" command is received, and may block while waiting for background tasks to complete. This function should be thread-safe.
Reimplemented in ben_bot::Engine.
Definition at line 114 of file EngineBase.hpp.
| IntOption chess::uci::EngineBase::opt_Hash |
Standard UCI option for hash size.
Definition at line 234 of file EngineBase.hpp.
| BoolOption chess::uci::EngineBase::opt_Ponder |
Standard UCI option for pondering. The engine doesn't start pondering on its own without explicitly being told to via another go command; this option is needed to inform the GUI that the engine supports pondering, and also gives the engine the opportunity to adjust its time management algorithm when pondering is enabled.
Definition at line 250 of file EngineBase.hpp.