Struct shakmaty_syzygy::Dtz

source ·
pub struct Dtz(pub i32);
Expand description

DTZ50′′. Based on the distance to zeroing of the half-move clock.

Zeroing the half-move clock while keeping the game theoretical result in hand guarantees making progress, so min-maxing Dtz values guarantees achieving the optimal outcome under the 50-move rule.

DTZWDL
-100 <= n <= -1LossUnconditional loss (assuming the 50-move counter is zero). Zeroing move can be forced in -n plies.
n < -100Blessed lossLoss, but draw under the 50-move rule. A zeroing move can be forced in -n plies or -n - 100 plies (if a later phase is responsible for the blessing).
0Draw
100 < nCursed winWin, but draw under the 50-move rule. A zeroing move can be forced in n or n - 100 plies (if a later phase is responsible for the curse).
1 <= n <= 100WinUnconditional win (assuming the 50-move counter is zero). Zeroing move can be forced in n plies.

Tuple Fields§

§0: i32

Implementations§

source§

impl Dtz

source

pub fn before_zeroing(wdl: Wdl) -> Dtz

Converts wdl to a Dtz, given that the best move is zeroing.

WDLDTZ
Loss-1
Blessed loss-101
Draw0
Cursed win101
Win1
source

pub fn add_plies(self, plies: u32) -> Dtz

Increases the absolute non-zero value by plies.

§Panics

Panics if overflow occurrs.

§Examples
use shakmaty_syzygy::Dtz;

assert_eq!(Dtz(1).add_plies(3), Dtz(4));
assert_eq!(Dtz(0).add_plies(3), Dtz(0));
assert_eq!(Dtz(-1).add_plies(3), Dtz(-4));
source

pub fn add_plies_checked(self, plies: u32) -> Option<Dtz>

Increases the absolute non-zero value by plies, returning None if overflow occurred.

source

pub fn add_plies_saturating(self, plies: u32) -> Dtz

Increases the absolute non-zero value by plies, saturating if overflow occurred.

source

pub fn signum(self) -> i32

Returns a number representing the sign of self.

  • 1 if self > Dtz(0)
  • 0 if self == Dtz(0)
  • -1 if self < Dtz(0)
source

pub fn is_zero(self) -> bool

Returns self == Dtz(0).

source

pub fn is_positive(self) -> bool

Returns self > Dtz(0).

source

pub fn is_negative(self) -> bool

Returns self < Dtz(0).

Trait Implementations§

source§

impl Clone for Dtz

source§

fn clone(&self) -> Dtz

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Dtz

source§

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

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

impl From<Dtz> for i128

source§

fn from(wdl: Dtz) -> i128

Converts to this type from the input type.
source§

impl From<Dtz> for i32

source§

fn from(wdl: Dtz) -> i32

Converts to this type from the input type.
source§

impl From<Dtz> for i64

source§

fn from(wdl: Dtz) -> i64

Converts to this type from the input type.
source§

impl From<i16> for Dtz

source§

fn from(dtz: i16) -> Dtz

Converts to this type from the input type.
source§

impl From<i32> for Dtz

source§

fn from(dtz: i32) -> Dtz

Converts to this type from the input type.
source§

impl From<i8> for Dtz

source§

fn from(dtz: i8) -> Dtz

Converts to this type from the input type.
source§

impl From<u16> for Dtz

source§

fn from(dtz: u16) -> Dtz

Converts to this type from the input type.
source§

impl From<u8> for Dtz

source§

fn from(dtz: u8) -> Dtz

Converts to this type from the input type.
source§

impl Neg for Dtz

§

type Output = Dtz

The resulting type after applying the - operator.
source§

fn neg(self) -> Dtz

Performs the unary - operation. Read more
source§

impl Ord for Dtz

source§

fn cmp(&self, other: &Dtz) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Dtz

source§

fn eq(&self, other: &Dtz) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Dtz

source§

fn partial_cmp(&self, other: &Dtz) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Dtz

source§

impl Eq for Dtz

source§

impl StructuralPartialEq for Dtz

Auto Trait Implementations§

§

impl Freeze for Dtz

§

impl RefUnwindSafe for Dtz

§

impl Send for Dtz

§

impl Sync for Dtz

§

impl Unpin for Dtz

§

impl UnwindSafe for Dtz

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.