pygambit.gambit.Game#

class pygambit.gambit.Game#

A game, the fundamental unit of analysis in game theory.

Games may be represented in extensive or strategic form.

Methods

append_event(nodes, actions)

Add a chance move at terminal nodes, with actions and their probabilities given by actions.

append_infoset(nodes, infoset)

Add a move at terminal nodes, joining the information set that the node identified by infoset belongs to.

append_move(nodes, player, actions)

Add a move for player at terminal nodes.

behavior_support_profile([actions])

Create a new BehaviorSupportProfile on the game.

copy_tree(src, dest)

Copy the subtree rooted at the node identified by src to the node identified by dest.

delete_parent(node)

Delete the parent of the node identified by node.

delete_tree(node)

Truncate the game tree at the node identified by node, deleting the subtree beneath it.

from_arrays(*arrays[, title])

Create a new Game with a strategic representation.

from_dict(payoffs[, title])

Create a new Game with a strategic representation.

get_action_probs(history)

Returns the probability of each action at the node that history resolves to, keyed by label, if it currently belongs to a chance event.

get_actions(history)

Returns the labels of the actions available at the node that history resolves to, in the order they are defined.

get_behavior(player, strategy)

Return the mapping from information sets to actions prescribed by a strategy.

get_events()

Returns a snapshot of the chance player's events: the points of exogenous randomness, each with a probability distribution over its actions.

get_histories(selector)

Returns the Histories of the nodes that selector resolves to.

get_infosets(player)

Returns a snapshot of the information sets belonging to the personal player player: the decisions at which that player chooses an action.

get_max_payoff(player)

Returns the largest payoff for player in any play of the game.

get_members(history)

Returns the Histories of the nodes which are members of the information set or event that the node identified by history currently belongs to.

get_min_payoff(player)

Returns the smallest payoff for player in any play of the game.

get_minimal_subgame(history)

Returns the History of the root of the smallest subgame containing the information set or event that the node identified by history belongs to.

get_outcome(location)

Returns the label of the outcome attached at location.

get_outcome_payoffs(label)

Returns the payoff to each player at the outcome labeled label.

get_outcomes()

Returns the labels of the outcomes in the game.

get_payoffs(contingency)

Returns the payoff to each player at a pure-strategy contingency.

get_player(history)

Returns the label of the player associated with the node that history resolves to: the one who makes the decision, if this is a personal node, or the chance player, if this is an event.

get_strategies(player)

Returns a snapshot of the labels of the strategies belonging to player.

get_strategy_unreachable()

Returns the Histories of the nodes that are not reachable by any pure strategy profile.

get_subgame_roots()

Returns the Histories of the roots of the subgames of the game, in postorder (children before parents).

has_perfect_recall(player)

Returns whether player has perfect recall.

insert_event(node, actions)

Insert a chance move prior to the node identified by node, with actions and their probabilities given by actions.

insert_infoset(node, infoset)

Insert a move in the information set or event that the node identified by infoset belongs to, prior to the node identified by node.

insert_move(node, player, actions)

Insert a move for player prior to the node identified by node, with actions labeled according to actions.

make_event(nodes, probs[, label])

Form nodes into a single event with distribution probs.

make_infoset(nodes, player[, label])

Form nodes into a single information set belonging to player.

make_outcome(location, payoffs, label)

Create an outcome with payoffs and label and attach it at location.

make_outcome_null(location)

Reset the outcome at location to the null outcome.

mixed_behavior_profile([data, rational])

Create a mixed behavior profile over the game.

mixed_strategy_profile([data, rational])

Create a mixed strategy profile over the game.

move_tree(src, dest)

Move the subtree rooted at the node identified by src to the node identified by dest.

new_table(dim[, title])

Create a new Game with a strategic representation.

new_tree([players, title])

Create a new Game consisting of a trivial game tree, with one node, which is both root and terminal.

random_behavior_profile([denom, gen])

Create a MixedBehaviorProfile on the game, with probabilities drawn from the uniform distribution over the set of mixed behavior profiles.

random_strategy_profile([denom, gen])

Create a MixedStrategy on the game, with probabilities drawn from the uniform distribution over the set of mixed strategy profiles.

relabel_actions(infoset, labels[, strict])

Simultaneously reassign the labels of actions at the information set or event that the node identified by infoset belongs to.

relabel_outcomes(labels[, strict])

Simultaneously reassign the labels of the game's outcomes.

relabel_players(labels[, strict])

Simultaneously reassign the labels of the game's players.

relabel_strategies(player, labels[, strict])

Simultaneously reassign the labels of player's strategies.

set_event_actions(event, probs[, drop, add])

Set the actions at the event that the node identified by event belongs to, to be the keys of probs, in order, with the given probability distribution.

set_move_actions(infoset, actions[, drop, add])

Set the actions at the move that the node identified by infoset belongs to, to be actions, matching by label.

set_outcome_payoffs(label, payoffs)

Sets the payoff to each player at the outcome labeled label.

set_players(players[, drop, add])

Set the players of the game to be players, matching by label.

set_strategies(player, strategies[, drop, add])

Set the strategies of player to be strategies, matching by label.

strategy_support_profile([strategies])

Create a new StrategySupportProfile on the game.

to_arrays(dtype)

Generate the payoff tables for players represented as numpy arrays.

to_efg([filepath_or_buffer])

Save the game to an .efg file or return its serialized representation

to_html([filepath_or_buffer])

Export the game to HTML format.

to_latex([filepath_or_buffer])

Export the game to LaTeX format.

to_nfg([filepath_or_buffer])

Save the game to a .nfg file or return its serialized representation

Attributes

contingencies

An iterator over the contingencies in the game.

description

Get or set the description of the game.

is_const_sum

Whether the game is constant sum.

is_perfect_recall

Whether the game is perfect recall.

is_tree

Return whether a game has a tree-based representation.

max_payoff

The maximum payoff to any player in any play of the game.

min_payoff

The minimum payoff to any player in any play of the game.

players

The set of players in the game.

title

Get or set the title of the game.