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_history ()
void clear_transposition_table ()
auto get_continuation_history () const noexcept -> const ContinuationHistory &
auto get_history_table () const noexcept -> const HistoryTable &
auto get_options () const noexcept -> const Options &
auto get_position () const noexcept -> const Position &
auto in_progress () const noexcept -> bool
Context & operator= (const Context &)=delete
Context & operator= (Context &&)=delete
void ponder_hit () noexcept
auto probe_transposition_table (const Position &pos) const -> std::optional< TTData >
void reset_abort () noexcept
void resize_transposition_table (const 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 47 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 52 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 81 of file Context.hpp.

◆ clear_history()

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

Clears the killer moves & the history heuristic tables. This should be called at the start of each new game, along with clear_transposition_table(), so that what was learnt in one game doesn't affect the next one. If a search is in progress, this method aborts it and blocks until it returns.

Definition at line 107 of file Context.hpp.

◆ clear_transposition_table()

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

Clears the transposition table & the pawn hash table. If a search is in progress, this method aborts it and blocks until it returns.

Definition at line 93 of file Context.hpp.

◆ get_continuation_history()

auto ben_bot::search::Context::get_continuation_history ( ) const -> const ContinuationHistory &
inlinenodiscardnoexcept

Returns the continuation history table.

Definition at line 120 of file Context.hpp.

◆ get_history_table()

auto ben_bot::search::Context::get_history_table ( ) const -> const HistoryTable &
inlinenodiscardnoexcept

Returns the history heuristic table.

Definition at line 117 of file Context.hpp.

◆ get_options()

auto ben_bot::search::Context::get_options ( ) const -> const Options &
inlinenodiscardnoexcept

Returns the current search parameters.

Definition at line 205 of file Context.hpp.

◆ get_position()

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

Returns the current position.

Definition at line 202 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 140 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 156 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 133 of file Context.hpp.

◆ reset_abort()

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

Clears any previous abort() request, so that the next call to search() will run. This must be called before starting each search; search() itself doesn't reset the flag, so that an abort() call made after a search has been requested but before it has actually begun still takes effect.

Definition at line 88 of file Context.hpp.

◆ resize_transposition_table()

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

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

Definition at line 125 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 aborts it and blocks until it completes.

Definition at line 194 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 aborts it and blocks until it completes.

Definition at line 184 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 aborts it and blocks until it completes.

Definition at line 174 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 151 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 aborts it and blocks until it completes.

Definition at line 161 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: