Trait minimax::interface::Game[][src]

pub trait Game: Sized {
    type S;
    type M: Move<G = Self>;
    fn generate_moves(_: &Self::S, _: &mut [Option<Self::M>]) -> usize;
fn get_winner(_: &Self::S) -> Option<Winner>; }

Defines the rules for a two-player, perfect-knowledge game.

A game ties together types for the state and moves, generates the possible moves from a particular state, and determines whether a state is terminal.

Associated Types

type S[src]

The type of the game state.

type M: Move<G = Self>[src]

The type of game moves.

Loading content...

Required methods

fn generate_moves(_: &Self::S, _: &mut [Option<Self::M>]) -> usize[src]

Generate moves at the given state. After finishing, the next entry in the slice should be set to None to indicate the end. Returns the number of moves generated.

Currently, there's a deficiency that all strategies assume that at most 200 moves may be generated for any position, which allows the underlying memory for the slice to be a stack-allocated array. Once stable, this trait will be extended with an associated constant to specify the maximum number of moves.

fn get_winner(_: &Self::S) -> Option<Winner>[src]

Returns Some(PlayerJustMoved) or Some(PlayerToMove) if there's a winner, Some(Draw) if the state is terminal without a winner, and None if the state is non-terminal.

Loading content...

Implementors

Loading content...