pub struct Tablebase<S: Position + Clone + Syzygy> { /* private fields */ }
Expand description

A collection of tables.

Implementations§

source§

impl<S: Position + Clone + Syzygy> Tablebase<S>

source

pub fn new() -> Tablebase<S>

Create an empty collection of tables.

source

pub fn max_pieces(&self) -> usize

Returns the maximum number of pieces over all added tables.

This number is updated when adding table files and very fast to read.

source

pub fn add_directory<P: AsRef<Path>>(&mut self, path: P) -> Result<usize>

Add all relevant tables from a directory.

Tables are selected by filename, e.g. KQvKP.rtbz. The files are not actually opened. This happens lazily when probing.

Traverses symbolic links.

Note that probing generally requires tables for the specific material composition, as well as material compositions that are transitively reachable by captures and promotions. These are sometimes distributed separately, so make sure to add tables from all relevant directories.

Returns the number of added table files.

§Errors

Returns an error result when:

  • The path does not exist.
  • path is not pointing to a directory.
  • Listing the directory fails (no permission, …).
source

pub fn add_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Add a table file.

The file is not actually opened. This happens lazily when probing.

Traverses symbolic links.

§Errors

Returns an immediate error result when:

  • The filename does not indicate that it is a valid table file (e.g. KQvKP.rtbz).
  • Querying metadata for the path fails (file does not exist, broken symlink, no permission to read metadata, …).
  • path is not pointing to a regular file.
  • The file size indicates that the table file must be corrupted.
source

pub fn probe_wdl_after_zeroing(&self, pos: &S) -> Result<Wdl, SyzygyError>

Probe tables for the Wdl value of a position, assuming pos is reached directly after a capture or pawn move.

§Errors

See SyzygyError for possible error conditions.

source

pub fn probe_wdl(&self, pos: &S) -> Result<AmbiguousWdl, SyzygyError>

Probe tables for the WDL value of a position, considering also the halfmove counter of pos. The result may be ambiguous due to DTZ rounding.

Requires both WDL and DTZ tables.

§Errors

See SyzygyError for possible error conditions.

source

pub fn probe_dtz(&self, pos: &S) -> Result<MaybeRounded<Dtz>, SyzygyError>

Probe tables for the Dtz value of a position.

Requires both WDL and DTZ tables.

§Errors

See SyzygyError for possible error conditions.

source

pub fn best_move( &self, pos: &S ) -> Result<Option<(Move, MaybeRounded<Dtz>)>, SyzygyError>

Get the recommended tablebase move.

Following the tablebase mainline starting from a capture or pawn move guarantees achieving the optimal outcome under the 50-move rule.

Otherwise (i.e. when not immediately following the tablebase mainline after the capture that crosses into tablebase territory), some care needs to be taken due to DTZ rounding.

Requires both WDL and DTZ tables.

§Errors

See SyzygyError for possible error conditions.

Trait Implementations§

source§

impl<S: Debug + Position + Clone + Syzygy> Debug for Tablebase<S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: Position + Clone + Syzygy> Default for Tablebase<S>

source§

fn default() -> Tablebase<S>

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

Auto Trait Implementations§

§

impl<S> Freeze for Tablebase<S>

§

impl<S> RefUnwindSafe for Tablebase<S>

§

impl<S> Send for Tablebase<S>
where S: Send,

§

impl<S> Sync for Tablebase<S>
where S: Sync + Send,

§

impl<S> Unpin for Tablebase<S>
where S: Unpin,

§

impl<S> UnwindSafe for Tablebase<S>
where S: UnwindSafe,

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.