BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
ben_bot::search::Context Struct Referencefinal

#include <libbenbot/search/Context.hpp>

Public Member Functions

 Context ()=default
 Context (Callbacks &&callbacksToUse)
 Context (const Context &)=delete
 Context (Context &&)=delete
 ~Context ()=default
void abort () noexcept
void clear_transposition_table ()
auto get_position () const noexcept -> const Position &
auto in_progress () const noexcept -> bool
Contextoperator= (const Context &)=delete
Contextoperator= (Context &&)=delete
void ponder_hit () noexcept
auto probe_transposition_table (const Position &pos) const -> std::optional< TTData >
void resize_transposition_table (size_t sizeMB)
void search ()
void set_callbacks (Callbacks &&callbacksToUse)
void set_options (const chess::uci::GoCommandOptions &opts)
void set_options (const Options &opts)
void set_pondering (const bool isPonderMode) noexcept
void set_position (const Position &pos)
void wait () const

Detailed Description

This struct encapsulates everything needed to perform a search. You can keep one of these alive between searches by simply updating the options and then calling search() again.

Definition at line 41 of file Context.hpp.

Constructor & Destructor Documentation

◆ Context() [1/4]

ben_bot::search::Context::Context ( )
default

Creates a search context with empty callbacks.

◆ Context() [2/4]

ben_bot::search::Context::Context ( Callbacks && callbacksToUse)
inlineexplicit

Creates a search context with a specified set of result callbacks.

Definition at line 46 of file Context.hpp.

◆ Context() [3/4]

ben_bot::search::Context::Context ( const Context & )
delete

◆ Context() [4/4]

ben_bot::search::Context::Context ( Context && )
delete

◆ ~Context()

ben_bot::search::Context::~Context ( )
default

Member Function Documentation

◆ abort()

void ben_bot::search::Context::abort ( )
inlinenoexcept

This function may be called while search() is executing to interrupt the search. If a search is in progress, calling this method will cause the search routine to return at the next available point. This method returns immediately; to wait for the search to complete, call wait() after calling this method.

Definition at line 75 of file Context.hpp.

◆ clear_transposition_table()

void ben_bot::search::Context::clear_transposition_table ( )
inline

Clears the transposition table. If a search is in progress, this method blocks until it returns.

Definition at line 80 of file Context.hpp.

◆ get_position()

auto ben_bot::search::Context::get_position ( ) const -> const Position &
inlinenodiscardnoexcept

Returns the current position.

Definition at line 161 of file Context.hpp.

◆ in_progress()

auto ben_bot::search::Context::in_progress ( ) const -> bool
inlinenodiscardnoexcept

Returns true if a search is currently in progress.

Definition at line 103 of file Context.hpp.

◆ operator=() [1/2]

Context & ben_bot::search::Context::operator= ( const Context & )
delete

◆ operator=() [2/2]

Context & ben_bot::search::Context::operator= ( Context && )
delete

◆ ponder_hit()

void ben_bot::search::Context::ponder_hit ( )
inlinenoexcept

When in a ponder mode search, this exits the search. A ponder mode search will not exit until this method or abort() are called.

Definition at line 119 of file Context.hpp.

◆ probe_transposition_table()

auto ben_bot::search::Context::probe_transposition_table ( const Position & pos) const -> std::optional< TTData >
inlinenodiscard

Probes the transposition table for the given position.

Definition at line 96 of file Context.hpp.

◆ resize_transposition_table()

void ben_bot::search::Context::resize_transposition_table ( size_t sizeMB)
inline

Resizes the transposition table. If a search is in progress, this method blocks until it returns.

Definition at line 89 of file Context.hpp.

◆ search()

void ben_bot::search::Context::search ( )

Performs a search. Results will be propagated via the callbacks that have been assigned.

The search may execute for a potentially unbounded amount of time. The search can be interrupted by calling the abort() method while search() is executing.

◆ set_callbacks()

void ben_bot::search::Context::set_callbacks ( Callbacks && callbacksToUse)
inline

Sets the result callbacks that will be used for the next search. If a search is in progress, this function blocks until it completes.

Definition at line 154 of file Context.hpp.

◆ set_options() [1/2]

void ben_bot::search::Context::set_options ( const chess::uci::GoCommandOptions & opts)
inline

Sets the options to be used by the next search. If a search is in progress, this function blocks until it completes.

Definition at line 145 of file Context.hpp.

◆ set_options() [2/2]

void ben_bot::search::Context::set_options ( const Options & opts)
inline

Sets the options to be used by the next search. If a search is in progress, this function blocks until it completes.

Definition at line 136 of file Context.hpp.

◆ set_pondering()

void ben_bot::search::Context::set_pondering ( const bool isPonderMode)
inlinenoexcept

Sets whether the next search will be in ponder mode. When in ponder mode, the search will not exit until abort() or ponder_hit() are called.

Definition at line 114 of file Context.hpp.

◆ set_position()

void ben_bot::search::Context::set_position ( const Position & pos)
inline

Sets the position to be searched by the next search. If a search is in progress, this function blocks until it completes.

Definition at line 124 of file Context.hpp.

◆ wait()

void ben_bot::search::Context::wait ( ) const

Blocks the calling thread until the search in progress is complete. Returns immediately if no search was in progress when this function was called.


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