pub trait Game {
type Move: Copy;
type Iter: Iterator<Item = Self::Move>;
// Required methods
fn player(&self) -> Player;
fn score(&self) -> u32;
fn max_score(&self) -> u32;
fn min_score(&self) -> i32;
fn make_move(&mut self, m: Self::Move) -> bool;
fn possible_moves(&self) -> Self::Iter;
fn is_winning_move(&self, m: Self::Move) -> bool;
}Expand description
Represents a combinatorial game.
Required Associated Types§
Required Methods§
Sourcefn score(&self) -> u32
fn score(&self) -> u32
Scores a position. The default implementation uses the size minus the number of moves (for finite games)
Sourcefn make_move(&mut self, m: Self::Move) -> bool
fn make_move(&mut self, m: Self::Move) -> bool
Returns true if the move was valid, and makes the move if it was.
Sourcefn possible_moves(&self) -> Self::Iter
fn possible_moves(&self) -> Self::Iter
Returns a vector of all possible moves.
If possible, this function should “guess” what the best moves are first. For example, if this is for tic tac toe, it should give the middle move first. This allows alpha-beta pruning to move faster.
Sourcefn is_winning_move(&self, m: Self::Move) -> bool
fn is_winning_move(&self, m: Self::Move) -> bool
Returns true if the move is a winning move.