BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
ben_bot::Engine Class Referencefinalabstract

#include <libbenbot/engine/Engine.hpp>

Inheritance diagram for ben_bot::Engine:
Collaboration diagram for ben_bot::Engine:

Public Member Functions

 Engine ()=default
 Engine (const Engine &)=delete
 Engine (Engine &&)=delete
 ~Engine () override=default
virtual void go (const GoCommandOptions &opts)=0
void handle_command (string_view command)
virtual void handle_registration (const RegisterOptions &opts)
void loop ()
Engineoperator= (const Engine &)=delete
Engineoperator= (Engine &&)=delete
void read_config_file (const std::filesystem::path &file)

Private Member Functions

void abort_search () override
auto get_author () const -> string_view override
auto get_name () const -> std::string override
auto get_options () -> std::span< uci::Option * > override
void go (const uci::GoCommandOptions &opts) override
void handle_custom_command (string_view command, string_view opts) override
auto is_searching () const noexcept -> bool override
void new_game (bool firstCall) override
void ponder_hit () override
void set_debug (const bool shouldDebug) override
void set_position (const Position &pos) override
void wait () override

Detailed Description

The ben-bot UCI engine class.

Definition at line 50 of file Engine.hpp.

Constructor & Destructor Documentation

◆ Engine() [1/3]

ben_bot::Engine::Engine ( )
default

◆ ~Engine()

ben_bot::Engine::~Engine ( )
overridedefault

◆ Engine() [2/3]

ben_bot::Engine::Engine ( const Engine & )
delete

◆ Engine() [3/3]

ben_bot::Engine::Engine ( Engine && )
delete

Member Function Documentation

◆ abort_search()

void ben_bot::Engine::abort_search ( )
inlineoverrideprivatevirtual

This function is called when the search should be exited.

Reimplemented from chess::uci::EngineBase.

Definition at line 75 of file Engine.hpp.

◆ get_author()

auto ben_bot::Engine::get_author ( ) const -> string_view
inlinenodiscardoverrideprivatevirtual

This must return the name of the engine's author.

Implements chess::uci::EngineBase.

Definition at line 67 of file Engine.hpp.

◆ get_name()

auto ben_bot::Engine::get_name ( ) const -> std::string
nodiscardoverrideprivatevirtual

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.

Implements chess::uci::EngineBase.

◆ get_options()

auto ben_bot::Engine::get_options ( ) -> std::span< uci::Option * >
inlinenodiscardoverrideprivatevirtual

This must return the list of all options the engine supports.

Reimplemented from chess::uci::EngineBase.

Definition at line 88 of file Engine.hpp.

◆ go() [1/2]

void ben_bot::Engine::go ( const uci::GoCommandOptions & opts)
overrideprivate

◆ go() [2/2]

virtual void chess::uci::EngineBase::go ( const GoCommandOptions & opts)
pure virtualinherited

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>".

◆ handle_command()

void chess::uci::EngineBase::handle_command ( string_view command)
inherited

Handles a UCI command. Typically you will not call this directly, you'll just invoke loop(), but this method can be used to manually invoke UCI commands if needed.

See also
loop()

◆ handle_custom_command()

void ben_bot::Engine::handle_custom_command ( string_view command,
string_view options )
overrideprivatevirtual

Any command input string not recognized as a standard UCI command will invoke this function. Engines can implement custom commands by overriding this function. The "command" argument will be the first word of the input command line.

Reimplemented from chess::uci::EngineBase.

◆ handle_registration()

virtual void chess::uci::EngineBase::handle_registration ( const RegisterOptions & opts)
inlinevirtualinherited

Called when the user send a "register" command. The engine may simply do nothing if it does not require registration.

Definition at line 142 of file EngineBase.hpp.

◆ is_searching()

auto ben_bot::Engine::is_searching ( ) const -> bool
inlineoverrideprivatevirtualnoexcept

This function must return true if a search is currently in progress. This function should be thread-safe.

Implements chess::uci::EngineBase.

Definition at line 81 of file Engine.hpp.

◆ loop()

void chess::uci::EngineBase::loop ( )
inherited

Runs the engine's event loop. This function blocks while reading from stdin. The calling thread becomes the engine's "main thread".

See also
handle_command()

◆ new_game()

void ben_bot::Engine::new_game ( bool firstCall)
overrideprivatevirtual

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.

Parameters
firstCallTrue if this is the first time new_game() has been called.

Reimplemented from chess::uci::EngineBase.

◆ operator=() [1/2]

Engine & ben_bot::Engine::operator= ( const Engine & )
delete

◆ operator=() [2/2]

Engine & ben_bot::Engine::operator= ( Engine && )
delete

◆ ponder_hit()

void ben_bot::Engine::ponder_hit ( )
inlineoverrideprivatevirtual

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 from chess::uci::EngineBase.

Definition at line 77 of file Engine.hpp.

◆ read_config_file()

void ben_bot::Engine::read_config_file ( const std::filesystem::path & file)

Loads the engine's state from a configuration file at the given path.

◆ set_debug()

void ben_bot::Engine::set_debug ( const bool shouldDebug)
inlineoverrideprivatevirtual

Called when the "debug" command is received.

Reimplemented from chess::uci::EngineBase.

Definition at line 83 of file Engine.hpp.

◆ set_position()

void ben_bot::Engine::set_position ( const Position & pos)
inlineoverrideprivatevirtual

Called when a new position is received from the GUI.

Reimplemented from chess::uci::EngineBase.

Definition at line 71 of file Engine.hpp.

◆ wait()

void ben_bot::Engine::wait ( )
inlineoverrideprivatevirtual

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 from chess::uci::EngineBase.

Definition at line 79 of file Engine.hpp.


The documentation for this class was generated from the following file: