Trait igs::game::Game

source ·
pub trait Game {
    type Position;
    type NimberSet: NimberSet;

    // Required methods
    fn moves_count(&self, position: &Self::Position) -> u16;
    fn initial_position(&self) -> Self::Position;

    // Provided methods
    fn try_solve_theoretically(&self, _position: &Self::Position) -> Option<u8> { ... }
    fn theoretical_solutions(&self) -> TheoreticalSolutions<'_, Self> { ... }
    fn is_initial_position_winning(&self) -> Option<bool> { ... }
}
Expand description

All games have to implement this trait, plus either SimpleGame (if game hasn’t decomposable positions) or DecomposableGame (if game has decomposable positions).

Required Associated Types§

source

type Position

In case of simple games, i.e. without decomposable positions: game position. In case of games with decomposable positions: a single component of decomposable position.

source

type NimberSet: NimberSet

Type used to store set of nimbers for this game.

Required Methods§

source

fn moves_count(&self, position: &Self::Position) -> u16

Returns the number of moves available in the position given.

source

fn initial_position(&self) -> Self::Position

Returns the initial game position.

Provided Methods§

source

fn try_solve_theoretically(&self, _position: &Self::Position) -> Option<u8>

Tries to provide theoretical solution for (i.e. the nimber of) the given position. One can use dbs::TheoreticalSolutions provider returned by self.theoretical_solutions() as an const_db of any solver to utilize this method during search.

The default implementation returns None.

source

fn theoretical_solutions(&self) -> TheoreticalSolutions<'_, Self>

Returns nimber provider that delegates get_nimber to self.try_solve_theoretically.

source

fn is_initial_position_winning(&self) -> Option<bool>

Returns the outcome of the initial position if it is known.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Game for igs::games::chomp::Chomp

§

type Position = u64

§

type NimberSet = [u64; 4]

source§

impl Game for igs::games::chomp_skyline::Chomp

§

type Position = u64

§

type NimberSet = [u64; 4]

source§

impl Game for Cram

source§

impl Game for GrundyGame

§

type Position = u16

§

type NimberSet = [u64; 4]