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>
impl<S: State, M: Move, U: Utility, O: Outcome<M, U, P>, const P: usize> GameTree<S, M, U, O, P>
Sourcepub fn player(
state: S,
to_move: PlayerIndex<P>,
next: impl NextGameTree<M, S, M, U, O, P>,
) -> Self
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.
Sourcepub fn players(
state: S,
to_move: Vec<PlayerIndex<P>>,
next: impl NextGameTree<Vec<M>, S, M, U, O, P>,
) -> Self
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.
Sourcepub fn all_players(
state: S,
next: impl NextGameTree<Profile<M, P>, S, M, U, O, P>,
) -> Self
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.
Sourcepub fn chance(
state: S,
distribution: Distribution<M>,
next: impl NextGameTree<M, S, M, U, O, P>,
) -> Self
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.
Sourcepub fn end(state: S, outcome: O) -> Self
pub fn end(state: S, outcome: O) -> Self
Construct a game node ending the game with the given outcome.
Sourcepub fn sequentialize(self, prioritize: Option<PlayerIndex<P>>) -> Self
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>
impl<S: Clone, M: Clone, U: Clone, O: Clone, const P: usize> Clone for GameTree<S, M, U, O, P>
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>
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 View = S
type View = S
Source§fn state_view(&self, state: &Self::State, _player: PlayerIndex<P>) -> Self::View
fn state_view(&self, state: &Self::State, _player: PlayerIndex<P>) -> Self::View
Source§fn num_players(&self) -> usize
fn num_players(&self) -> usize
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>
impl<S: State, M: Move, U: Utility, O: Outcome<M, U, P>, const P: usize> Playable<P> for GameTree<S, M, U, O, P>
Auto Trait Implementations§
impl<S, M, U, O, const P: usize> Freeze for GameTree<S, M, U, O, P>
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>
impl<S, M, U, O, const P: usize> Sync for GameTree<S, M, U, O, P>
impl<S, M, U, O, const P: usize> Unpin for GameTree<S, M, U, O, P>
impl<S, M, U, O, const P: usize> !UnwindSafe for GameTree<S, M, U, O, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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