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 epsilon() -> Self;
    fn win() -> Self;
    fn max() -> Self;
    fn is_win(&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 epsilon() -> Eval { Eval(1) }
    fn win() -> Eval { Eval(100000) }
    fn max() -> Eval { Eval(i32::MAX) }
    fn is_win(&self) -> bool { self.0.abs() > 99000 }
}

Required Methods

An empty, or zero evaluation.

The smallest step to consider.

The base value of a win. The evaluation system 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 absolute value is above a certain threshold.

Implementors