Trait zero_sum::analysis::Evaluation [] [src]

pub trait Evaluation: Sized + Clone + Copy + Display + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Neg<Output = Self> + Div<Output = Self> + PartialEq + PartialOrd {
    fn null() -> Self;
    fn shift(self, steps: i32) -> Self;
    fn win() -> Self;
    fn max() -> Self;
    fn is_win(&self) -> bool;

    fn lose() -> Self { ... }
    fn min() -> Self { ... }
    fn is_lose(&self) -> bool { ... }
    fn is_end(&self) -> bool { ... }
}

An evaluation type.

This is usually a tuple around a signed numeric type.

Example

There is a helper macro to facilitate the implementation of tuple structs:

#[macro_use]
extern crate zero_sum;
use std::i32;
use std::ops::{Add, Div, Mul, Neg, Sub};

#[derive(Clone, Copy, PartialEq, PartialOrd)]
struct Eval(i32);

prepare_evaluation_tuple!(Eval); // impl Add, Div, Mul, Neg, Sub, and Display

impl Evaluation for Eval {
    fn null() -> Eval { Eval(0) }
    fn shift(self, steps: i32) -> Eval { Eval(self.0 + steps) }
    fn win() -> Eval { Eval(100000) }
    fn max() -> Eval { Eval(i32::MAX) }
    fn is_win(&self) -> bool { self.0 > 99000 }
}

Required Methods

An empty, or zero evaluation.

Shift the evaluation by the smallest representable amount steps times in the positive or negative direction.

The base value of a win. The evaluator may add or subtract to it in in order to promote it or discourage it in favor of others in the search.

The maximum value representable. This must be safely negatable.

Returns true if this evaluation contains a win. This is usually a check to see if the value is above a certain threshold.

Provided Methods

The base value of a loss. The evaluator may add or subtract to it in in order to promote it or discourage it in favor of others in the search.

The minimum value representable.

Returns true if this evaluation contains a loss.

Returns true if this evaluation is either a win or a loss.

Implementors