Trait zero_sum::Resolution [] [src]

pub trait Resolution {
    fn get_winner(&self) -> Option<u8>;
    fn is_draw(&self) -> bool;
}

A game's resolution.

This is often an enum that represents each ending a game can have.

Example

For tic-tac-toe, we might have:

enum Mark { X, O }

enum End {
    Win(Mark),
    CatsGame,
}

impl Resolution for End {
    fn get_winner(&self) -> Option<u8> {
        match *self {
            End::Win(Mark::X) => Some(0),
            End::Win(Mark::O) => Some(1),
            _ => None,
        }
    }
    fn is_draw(&self) -> bool { if *self == End::CatsGame { true } else { false } }
}

Required Methods

Returns the index of the winning player if this Resolution represents a win.

Implementors