pub struct GameTree {
pub name: String,
pub nodes: HashMap<NodeId, NodeData>,
pub root: Option<NodeId>,
pub num_players: usize,
/* private fields */
}Expand description
A game tree representing an extensive-form game.
Fields§
§name: StringName of the game.
nodes: HashMap<NodeId, NodeData>All nodes indexed by their ID.
root: Option<NodeId>The root node ID.
num_players: usizeNumber of players.
Implementations§
Source§impl GameTree
impl GameTree
Sourcepub fn with_players(name: &str, num_players: usize) -> Self
pub fn with_players(name: &str, num_players: usize) -> Self
Create a game tree with a specified number of players.
Sourcepub fn add_decision(&mut self, player: PlayerId, label: &str) -> NodeId
pub fn add_decision(&mut self, player: PlayerId, label: &str) -> NodeId
Add a decision node and return its ID.
Sourcepub fn add_terminal(&mut self, payoffs: Vec<Payoff>, label: &str) -> NodeId
pub fn add_terminal(&mut self, payoffs: Vec<Payoff>, label: &str) -> NodeId
Add a terminal node with payoffs.
Sourcepub fn add_chance(&mut self, probabilities: Vec<f64>, label: &str) -> NodeId
pub fn add_chance(&mut self, probabilities: Vec<f64>, label: &str) -> NodeId
Add a chance node.
Sourcepub fn add_action(&mut self, parent: NodeId, action: &str, child: NodeId)
pub fn add_action(&mut self, parent: NodeId, action: &str, child: NodeId)
Add an action from parent to child with a label.
Sourcepub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut NodeData>
pub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut NodeData>
Get a mutable node by ID.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count total nodes.
Sourcepub fn ultimatum_game(total: Payoff) -> Self
pub fn ultimatum_game(total: Payoff) -> Self
Build an Ultimatum game: P1 proposes split, P2 accepts/rejects.
Sourcepub fn centipede_game(n: usize, pot: Payoff, growth: Payoff) -> Self
pub fn centipede_game(n: usize, pot: Payoff, growth: Payoff) -> Self
Build a Centipede game with n rounds.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GameTree
impl RefUnwindSafe for GameTree
impl Send for GameTree
impl Sync for GameTree
impl Unpin for GameTree
impl UnsafeUnpin for GameTree
impl UnwindSafe for GameTree
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
Mutably borrows from an owned value. Read more