Solver

Struct Solver 

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

Reusing the same solver instead of repeatedly running score in order to calculate similar positions, may have performance benefits, because we can reuse the transposition table.

Implementations§

Source§

impl Solver

Source

pub fn new() -> Solver

Source

pub fn score(&mut self, game: &ConnectFour) -> i8

Calculates the score of a connect four game. The score is set up so always picking the move with the lowest score results in perfect play. Perfect meaning winning as fast as possible, drawing or loosing as late as possible.

A positive score means the player who can put in the next stone can win. Positions which can be won faster are scored higher. The score is 1 if the current player can win with his last stone. Two if he can win with his second to last stone and so on. A score of zero means the game will end in a draw if both players play perfectly. A negative score means the opponent (the player which is not putting in the next stone) is winnig. It is -1 if the opponent is winning with his last stone. -2 if he is winning second to last stone and so on.

Source

pub fn best_moves(&mut self, game: &ConnectFour, best_moves: &mut Vec<Column>)

Fills best_moves with all the legal moves, which have the best strong score.

Trait Implementations§

Source§

impl Default for Solver

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Solver

§

impl RefUnwindSafe for Solver

§

impl Send for Solver

§

impl Sync for Solver

§

impl Unpin for Solver

§

impl UnwindSafe for Solver

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.