Struct Engine

Source
pub struct Engine { /* private fields */ }
Expand description

Engine wraps up all parameters required for running any kind of search. It is stateful because to properly evaluate a chess position the history of moves for the current game need to be tracked.

If a new game is going to be started, the engine needs to be told so.

Implementations§

Source§

impl Engine

Source

pub fn new() -> Self

Source

pub fn game(&self) -> &Game

Returns reference to current game of engine.

Source

pub fn debug(&self) -> &bool

Returns reference to current debug flag of engine.

Source

pub fn transposition_table(&self) -> &TranspositionTable

Returns reference to engine’s transposition table.

Source

pub fn set_game<T: Into<Game>>(&mut self, game: T)

Set the game or position for evaluation.

Source

pub fn set_debug(&mut self, new_debug: bool)

Update the engine’s debug parameter.

Source

pub fn new_game(&mut self) -> Result<()>

Informs engine that next search will be from a new game. Returns Ok if engine succeeded in changing state for a new game, Err otherwise.

Source

pub fn try_set_transpositions_mb(&mut self, new_mb: usize) -> Result<usize>

Attempt to set a new size for the transposition table in Megabytes. Table is set only if there is exactly one reference to the table (not used in search). Returns Ok(new capacity) on success or Err if no change was made.

Source

pub fn try_clear_transpositions(&mut self) -> Result<()>

Attempt to clear the transposition table. Table is cleared only if there are no other Arcs to the table. Returns Ok on success or Err if the table was not cleared.

Source

pub fn search_sync(&mut self, mode: Mode) -> SearchResult

Run a blocking search.

Source

pub fn search<T>(&mut self, mode: Mode, sender: Sender<T>) -> Result<()>
where T: From<SearchResult> + Send + 'static,

Run a non-blocking search. The engine only runs one search at a time, so if it is not ready, it fails to begin. If the engine is available for searching, it ensures its stopper is unset.

Source

pub fn ponder(&self)

Source

pub fn stop(&self)

Informs the active search to stop searching as soon as possible.

Source

pub fn unstop(&self)

Resets stopper flag.

Source

pub fn wait(&mut self)

Engine blocks thread until search is completed.

Source

pub fn ready(&self) -> bool

Returns true if the engine is ready to start a search. Only one search may run at a time, so if a search is in progress, engine is not ready.

Source

pub fn shutdown(self)

Consumes and shuts down the Engine. Signals any threads to stop searching and waits for internal resources to close first. The engine will normally close up properly when dropped, however this function provides a way to do it explicitly directly from the API.

Trait Implementations§

Source§

impl Default for Engine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Engine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl !UnwindSafe for Engine

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V