Enum GameTree

Source
pub enum GameTree<S, M, U, O, const P: usize> {
    Turn {
        state: S,
        to_move: Vec<PlayerIndex<P>>,
        next: Arc<dyn NextGameTree<Vec<M>, S, M, U, O, P>>,
    },
    Chance {
        state: S,
        distribution: Distribution<M>,
        next: Arc<dyn NextGameTree<M, S, M, U, O, P>>,
    },
    End {
        state: S,
        outcome: O,
        utility_type: PhantomData<U>,
    },
}
Expand description

A node in a game tree.

Variants§

§

Turn

One or more players play a move simultaneously.

Fields

§state: S

The game state at this node.

§to_move: Vec<PlayerIndex<P>>

The players to move simultaneously.

§next: Arc<dyn NextGameTree<Vec<M>, S, M, U, O, P>>

Compute the next node in the tree from the moves played by the players.

§

Chance

Make a move of chance according to the given distribution.

Fields

§state: S

The game state at this node.

§distribution: Distribution<M>

The distribution to draw a move from.

§next: Arc<dyn NextGameTree<M, S, M, U, O, P>>

Compute the next node in the tree from the move drawn from the distribution.

§

End

End a game and return the outcome, which includes the game’s payoff.

Fields

§state: S

The final game state.

§outcome: O

The final outcome of the game.

§utility_type: PhantomData<U>

Phantom data to specify the utility value type.

Implementations§

Source§

impl<S: State, M: Move, U: Utility, O: Outcome<M, U, P>, const P: usize> GameTree<S, M, U, O, P>

Source

pub fn player( state: S, to_move: PlayerIndex<P>, next: impl NextGameTree<M, S, M, U, O, P>, ) -> Self

Construct a game node where a single player must make a move and the next node is computed from the move they choose.

Source

pub fn players( state: S, to_move: Vec<PlayerIndex<P>>, next: impl NextGameTree<Vec<M>, S, M, U, O, P>, ) -> Self

Construct a game node where several players must make a move simultaneously and the next node is computed from the moves they choose.

Source

pub fn all_players( state: S, next: impl NextGameTree<Profile<M, P>, S, M, U, O, P>, ) -> Self

Construct a game node where all players must make a move simultaneously and the next node is computed from the moves they choose.

Source

pub fn chance( state: S, distribution: Distribution<M>, next: impl NextGameTree<M, S, M, U, O, P>, ) -> Self

Construct a game node where a move is selected from a distribution and the next node is computed from the selected move.

Source

pub fn end(state: S, outcome: O) -> Self

Construct a game node ending the game with the given outcome.

Source

pub fn state(&self) -> &S

Get the game state at this node.

Source

pub fn sequentialize(self, prioritize: Option<PlayerIndex<P>>) -> Self

Transform the game tree such that each GameTree::Turn node contains exactly one player. Each turn node where several players move simultaneously will be expanded into a sequence of single-player turn nodes.

A particular player may be prioritized in the transformation. The prioritized player will move first among all players in a simultaneous turn. This is useful, e.g. for focusing on the current player when traversing a game tree within a strategy.

Non-prioritized players will be ordered arbitrarily in the transformed tree.

Trait Implementations§

Source§

impl<S: Clone, M: Clone, U: Clone, O: Clone, const P: usize> Clone for GameTree<S, M, U, O, P>

Source§

fn clone(&self) -> GameTree<S, M, U, O, P>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: State, M: Move, U: Utility, O: Outcome<M, U, P>, const P: usize> Game<P> for GameTree<S, M, U, O, P>

Source§

type Move = M

The type of moves played by players in this game.
Source§

type Utility = U

The type of utility values awarded to each player at the end of the game.
Source§

type State = S

The type of intermediate game state used during the execution of the game.
Source§

type View = S

The type of the view of the intermediate game state presented to players. Read more
Source§

fn state_view(&self, state: &Self::State, _player: PlayerIndex<P>) -> Self::View

Produce a view of the game state for the given player. Read more
Source§

fn num_players(&self) -> usize

The number of players this game is for.
Source§

impl<S: State, M: Move, U: Utility, O: Outcome<M, U, P>, const P: usize> Playable<P> for GameTree<S, M, U, O, P>

Source§

type Outcome = O

The type of value produced by playing the game. Read more
Source§

fn into_game_tree(self) -> GameTree<S, M, U, O, P>

Convert this game into the corresponding game tree. Read more
Source§

fn game_tree( &self, ) -> GameTree<Self::State, Self::Move, Self::Utility, Self::Outcome, P>

Get the corresponding game tree for this game. Read more
Source§

fn play( &self, matchup: &Matchup<Self, P>, ) -> PlayResult<Self::Outcome, Self::State, Self::Move, P>

Play this game with the given players by executing the game tree. Read more

Auto Trait Implementations§

§

impl<S, M, U, O, const P: usize> Freeze for GameTree<S, M, U, O, P>
where S: Freeze, O: Freeze,

§

impl<S, M, U, O, const P: usize> !RefUnwindSafe for GameTree<S, M, U, O, P>

§

impl<S, M, U, O, const P: usize> Send for GameTree<S, M, U, O, P>
where S: Send, O: Send, U: Send, M: Send,

§

impl<S, M, U, O, const P: usize> Sync for GameTree<S, M, U, O, P>
where S: Sync, O: Sync, U: Sync, M: Sync,

§

impl<S, M, U, O, const P: usize> Unpin for GameTree<S, M, U, O, P>
where S: Unpin, O: Unpin, U: Unpin, M: Unpin,

§

impl<S, M, U, O, const P: usize> !UnwindSafe for GameTree<S, M, U, O, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V