Struct uci::Engine

source ·
pub struct Engine { /* private fields */ }

Implementations§

source§

impl Engine

source

pub fn new(path: &str) -> Result<Engine>

Create a new Engine instance.

§Arguments
  • path - The path to the engine executable.
§Panics
  • Panics if the engine couldn’t be spawned (path is invalid, execution permission denied, etc.)
§Errors

Returns an EngineError if there’s an errors while communicating with the engine.

source

pub fn movetime(self, new_movetime: u32) -> Engine

Changes the amount of time the engine spends looking for a move

§Arguments
  • new_movetime - New timelimit in milliseconds
source

pub fn make_moves(&self, moves: &[String]) -> Result<()>

Asks the engine to play the given moves from the initial position on it’s internal board.

§Arguments
  • moves - A list of moves for the engine to play. Uses Coordinate notation
§Errors

Returns EngineError if there’s an error while communicating with the engine.

§Examples
let engine = uci::Engine::new("stockfish").unwrap();
let moves = vec!["e2e4".to_string(), "e7e5".to_string()];
engine.make_moves(&moves).unwrap();
source

pub fn set_position(&self, fen: &str) -> Result<()>

Asks the engine to use the position represented by the given FEN string

§Errors
§Examples
let engine = uci::Engine::new("stockfish").unwrap();
engine.set_position("2k4R/8/3K4/8/8/8/8/8 b - - 0 1").unwrap();
assert_eq!(engine.bestmove().unwrap(), "c8b7");
source

pub fn make_moves_from_position( &self, fen: &str, moves: &[String] ) -> Result<()>

Asks the engine to use the position represented by the given FEN string and then play the given moves from that position

§Errors

Returns an EngineError if there’s an error while communicating with the engine.

source

pub fn bestmove(&self) -> Result<String>

Returns the best move in the current position according to the engine

§Errors

Returns an error if the engine is not ready to return a move

source

pub fn set_option(&self, name: &str, value: &str) -> Result<()>

Sets an engine specific option to the given value

§Arguments
  • name - Name of the option
  • value - New value for the option
§Errors

Returns an EngineError if the engine doesn’t support the option

§Examples
let engine = uci::Engine::new("stockfish").unwrap();
engine.set_option("Skill Level", "5").unwrap();
source

pub fn command(&self, cmd: &str) -> Result<String>

Sends a command to the engine and returns the output

§Errors

Returns an EngineError if there was an error while sending the command to the engine

§Examples
let engine = uci::Engine::new("stockfish").unwrap();
let analysis = engine.command("go depth 10").unwrap();
println!("{}", analysis);

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>,

§

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>,

§

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.