pub trait Combinatorial<const P: usize>: Game<P> {
// Required methods
fn initial_state(&self) -> Self::State;
fn whose_turn(&self, state: &Self::State) -> PlayerIndex<P>;
fn next_state(
&self,
state: Self::State,
the_move: Self::Move,
) -> PlayResult<Self::State, Self::State, Self::Move, P>;
fn payoff(&self, state: &Self::State) -> Option<Payoff<Self::Utility, P>>;
// Provided method
fn is_game_end(&self, state: &Self::State) -> bool { ... }
}
Expand description
A trait for defining combinatorial games.
A combinatorial game is a perfect-information game where players interact by sequentially making moves to modify a shared state.
To define a combinatorial game, you should implement the Game
trait and this trait. The
Playable
trait is implemented generically for all instances of this trait.
Required Methods§
Sourcefn initial_state(&self) -> Self::State
fn initial_state(&self) -> Self::State
The initial state of the game.
Sourcefn whose_turn(&self, state: &Self::State) -> PlayerIndex<P>
fn whose_turn(&self, state: &Self::State) -> PlayerIndex<P>
Given the state of the game, whose turn is it?
Sourcefn next_state(
&self,
state: Self::State,
the_move: Self::Move,
) -> PlayResult<Self::State, Self::State, Self::Move, P>
fn next_state( &self, state: Self::State, the_move: Self::Move, ) -> PlayResult<Self::State, Self::State, Self::Move, P>
Given the current state and the current player’s move, produce the next state.
Provided Methods§
Sourcefn is_game_end(&self, state: &Self::State) -> bool
fn is_game_end(&self, state: &Self::State) -> bool
Is this game over? Returns true
when the payoff
method returns Some
,
false
otherwise.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.