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
impl Engine
pub fn new() -> Self
Sourcepub fn transposition_table(&self) -> &TranspositionTable
pub fn transposition_table(&self) -> &TranspositionTable
Returns reference to engine’s transposition table.
Sourcepub fn new_game(&mut self) -> Result<()>
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.
Sourcepub fn try_set_transpositions_mb(&mut self, new_mb: usize) -> Result<usize>
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.
Sourcepub fn try_clear_transpositions(&mut self) -> Result<()>
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.
Sourcepub fn search_sync(&mut self, mode: Mode) -> SearchResult
pub fn search_sync(&mut self, mode: Mode) -> SearchResult
Run a blocking search.
Sourcepub fn search<T>(&mut self, mode: Mode, sender: Sender<T>) -> Result<()>
pub fn search<T>(&mut self, mode: Mode, sender: Sender<T>) -> Result<()>
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.