API documentation#
Representation of games#
A game, the fundamental unit of analysis in game theory. |
|
|
An immutable sequence of `HistoryTransition`s identifying a node (or an information set/event, via its canonical member) by the path of actions taken to reach it from the root. |
|
The layout of a game's tree, computed for graphical display. |
|
The layout coordinates of a single node in a game tree, computed for graphical display. |
Creating, reading, and writing games#
|
Construct a game from its serialised representation in a GBT file. |
|
Construct a game from its serialised representation in an EFG file. |
|
Construct a game from its serialised representation in a NFG file. |
|
Construct a game from its serialised representation in an AGG file. |
|
Construct a game from its serialised representation in a BAGG file. |
|
Create a new |
|
Create a new |
|
Create a new |
|
Generate the payoff tables for players represented as numpy arrays. |
|
Create a new |
|
Save the game to an .efg file or return its serialized representation |
|
Save the game to a .nfg file or return its serialized representation |
|
Export the game to HTML format. |
|
Export the game to LaTeX format. |
Computing a tree layout for graphical display#
|
Computes the layout of game's tree for graphical display. |
Transforming game trees#
|
Add a move for player at terminal nodes. |
|
Add a move at terminal nodes, joining the information set that the node identified by infoset belongs to. |
|
Add a chance move at terminal nodes, with actions and their probabilities given by actions. |
|
Insert a move for player prior to the node identified by node, with actions labeled according to actions. |
|
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 a chance move prior to the node identified by node, with actions and their probabilities given by actions. |
|
Copy the subtree rooted at the node identified by src to the node identified by dest. |
|
Move the subtree rooted at the node identified by src to the node identified by dest. |
|
Delete the parent of the node identified by node. |
|
Truncate the game tree at the node identified by node, deleting the subtree beneath it. |
Transforming game information structure#
|
Form nodes into a single information set belonging to player. |
|
Form nodes into a single event with distribution probs. |
|
Simultaneously reassign the labels of actions at the information set or event that the node identified by infoset belongs to. |
|
Set the actions at the move that the node identified by infoset belongs to, to be actions, matching by label. |
|
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. |
Transforming game components#
|
Simultaneously reassign the labels of the game's players. |
|
Set the players of the game to be players, matching by label. |
|
Simultaneously reassign the labels of player's strategies. |
|
Set the strategies of player to be strategies, matching by label. |
|
Create an outcome with payoffs and label and attach it at location. |
|
Reset the outcome at location to the null outcome. |
|
Simultaneously reassign the labels of the game's outcomes. |
|
Sets the payoff to each player at the outcome labeled label. |
Information about the game#
Get or set the title of the game. |
|
Get or set the description of the game. |
|
Whether the game is constant sum. |
|
Return whether a game has a tree-based representation. |
|
Whether the game is perfect recall. |
|
|
Returns whether player has perfect recall. |
The set of players in the game. |
|
The minimum payoff to any player in any play of the game. |
|
The maximum payoff to any player in any play of the game. |
|
|
Returns the smallest payoff for player in any play of the game. |
|
Returns the largest payoff for player in any play of the game. |
|
Returns a snapshot of the information sets belonging to the personal player player: the decisions at which that player chooses an action. |
Returns a snapshot of the chance player's events: the points of exogenous randomness, each with a probability distribution over its actions. |
|
|
Returns a snapshot of the labels of the strategies belonging to player. |
An iterator over the contingencies in the game. |
|
|
Returns the label of the outcome attached at location. |
Returns the labels of the outcomes in the game. |
|
|
Returns the payoff to each player at the outcome labeled label. |
|
Returns the payoff to each player at a pure-strategy contingency. |
Returns the Histories of the roots of the subgames of the game, in postorder (children before parents). |
|
|
Returns the History of the root of the smallest subgame containing the information set or event that the node identified by history belongs to. |
Returns the Histories of the nodes that are not reachable by any pure strategy profile. |
Player behavior#
|
Create a mixed strategy profile over the game. |
|
Create a MixedStrategy on the game, with probabilities drawn from the uniform distribution over the set of mixed strategy profiles. |
|
Create a mixed behavior profile over the game. |
|
Create a MixedBehaviorProfile on the game, with probabilities drawn from the uniform distribution over the set of mixed behavior profiles. |
|
Create a new StrategySupportProfile on the game. |
|
Create a new BehaviorSupportProfile on the game. |
Representation of strategic behavior#
Computed quantities#
A read-only mapping from player label to a computed value, one entry per player in a game. |
|
Implement iter(self). |
|
|
Return self[key]. |
A read-only mapping from strategy label to a computed value, one entry per strategy belonging to a single player. |
|
Implement iter(self). |
|
Return self[key]. |
|
A read-only mapping from a node's History to a computed value, one entry per node. |
|
Implement iter(self). |
|
|
Return self[key]. |
A read-only mapping from an information set or event to a computed value, one entry per information set or event. |
|
Implement iter(self). |
|
|
Return self[key]. |
Probability distributions over strategies#
Represents a mixed strategy profile over the strategies in a |
|
The game on which this mixed strategy profile is defined. |
|
Iterate over the mixed strategies in the profile, one per player. |
|
Returns a snapshot of the mixed strategy for the player with label player, as of now; it will not reflect any later changes to this profile. |
|
Sets the mixed strategy for the player with label player. |
|
Sets the mixed strategy for the player with label player. |
|
Returns the expected payoff to each player, if all players play according to the profile. |
|
Returns the expected payoff of playing each strategy, conditional on reaching it, if all other players play according to the profile, grouped by player. |
|
Returns the regret to playing each strategy, if all other players play according to the profile, grouped by player. |
|
Returns the regret of each player for playing their mixed strategy, if all other players play according to the profile. |
|
Returns the maximum regret of any player. |
|
Returns the Lyapunov value (see [McK91]) of the strategy profile. |
|
Creates a mixed behavior profile which is equivalent to this mixed strategy profile. |
|
Creates a floating-point copy of this mixed strategy profile. |
|
Create a profile with the same strategy proportions as this one, but normalised so probabilities for each player sum to one. |
|
Creates a copy of the mixed strategy profile. |
|
A probability distribution over a player's strategies. |
|
Iterate over the probabilities assigned to strategies by the mixed strategy. |
|
Returns the probability that the strategy with label strategy is played. |
|
The expected payoff to each player, one entry per player in a game. |
|
The regret of each player for playing their mixed strategy, one entry per player. |
|
The expected payoff of playing each strategy, conditional on reaching it, for one player's strategies. |
|
The regret of playing each strategy, for one player's strategies. |
|
The expected payoff of playing each strategy, conditional on reaching it, grouped by player; each value is a StrategyValueVector for that player's strategies. |
|
The regret of playing each strategy, grouped by player; each value is a StrategyRegretVector for that player's strategies. |
Probability distributions over behavior#
Represents a mixed behavior profile over the actions in a |
|
The game on which this mixed behavior profile is defined. |
|
Iterate over the mixed behaviors in the profile, one per player. |
|
Access a component of the mixed behavior profile specified by index. |
|
Sets the mixed action at the information set containing index. |
|
|
Sets the mixed action at the information set containing index. |
Returns the expected payoff to each player, if all players play according to the profile. |
|
Returns the expected payoff to the player of playing each action, conditional on reaching its information set, if all players play according to the profile, grouped by information set. |
|
Returns the regret to playing each action, if all other players play according to the profile, grouped by information set. |
|
Returns the expected payoff to the player conditional on reaching each information set, if all players play according to the profile. |
|
Returns the regret to the player for playing their mixed action at each information set, if all other players play according to the profile. |
|
Returns the expected payoff to each player conditional on play reaching each node, if all players play according to the profile, grouped by player. |
|
Returns the probability with which each node is reached, if all players play according to the profile. |
|
Returns the probability with which each information set is reached, if all players play according to the profile. |
|
Returns the probability with which each chance event is reached, if all players play according to the profile. |
|
Returns, for each node, the conditional probability that the node is reached, given that its information set (or, at a chance node, its event) is reached, if all players play according to the profile. |
|
Returns the maximum regret at any information set. |
|
Returns the Lyapunov value (see [McK91]) of the strategy profile. |
|
Returns the maximum regret at any information set. |
|
Returns the Lyapunov value (see [McK91]) of the strategy profile. |
|
Returns a MixedStrategyProfile which is equivalent to the profile. |
|
Creates a floating-point copy of this mixed behavior profile. |
|
Create a profile with the same action proportions as this one, but normalised so probabilities for each infoset sum to one. |
|
Creates a copy of the behavior strategy profile. |
|
A set of probability distributions describing a player's behavior. |
|
Iterate over the mixed actions specified by the mixed behavior. |
|
Returns the mixed action at the information set selector resolves to. |
|
A probability distribution over a player's actions at an information set. |
|
Iterate over the probabilities assigned to actions by the mixed action. |
|
Returns the probability that the action with label action is played. |
|
The expected payoff to the player conditional on reaching each information set, one entry per information set. |
|
The regret of playing the mixed action at each information set, one entry per information set. |
|
The probability with which each information set is reached, one entry per information set. |
|
The probability with which each chance event is reached, one entry per event. |
|
The expected payoff of playing each action, conditional on reaching it, for one information set's actions. |
|
The regret of playing each action, for one information set's actions. |
|
The expected payoff of playing each action, conditional on reaching it, grouped by information set; each value is an ActionValueVector for that information set's actions. |
|
The regret of playing each action, grouped by information set; each value is an ActionValueVector for that information set's actions. |
|
The probability with which each node is reached, one entry per node. |
|
The conditional probability that each node is reached, given that its information set is reached, one entry per node. |
|
The expected payoff to one player conditional on reaching each node, one entry per node. |
|
The expected payoff to each personal player conditional on reaching each node, grouped by player; each value is a HistoryValueVector for that player. |
Representation of supports#
Subsets of strategies#
A set-like object representing a subset of the strategies in game. |
|
The Game on which the support profile is defined. |
|
Iterate over the strategy supports in the profile, one per player. |
|
Return a StrategySupport representing the labels of the strategies in the support belonging to the player with label player, as of now; it will not reflect any later changes to this profile. |
|
Sets the support for the player with label player to exactly the given strategies. |
|
Creates a copy of the support profile. |
|
Creates a deep copy of the support profile's game, including only the strategies in the support. |
|
|
Returns whether the strategy with label strategy, belonging to the player with label player, is dominated. |
The labels of the strategies for a specified player in a StrategySupportProfile. |
|
Implement iter(self). |
|
|
Return bool(key in self). |
Subsets of actions#
A set-like object representing a subset of the actions in an extensive game. |
|
The Game on which the support profile is defined. |
|
Iterate over the behavior supports in the profile, one per player. |
|
Access a component of the support profile specified by index. |
|
Sets the support at infoset to exactly the given actions. |
|
Creates a copy of the support profile. |
|
Returns whether infoset can be reached under this support, i.e. whether there is some path of play consistent with the support that reaches it. |
|
The action supports at the information sets belonging to a specified player in a BehaviorSupportProfile. |
|
The label of the player for whom this behavior support is defined. |
|
Iterate over the action supports specified by the behavior support, one per information set belonging to the player. |
|
Returns the action support at the information set selector resolves to. |
|
A set of actions at a specified information set in a BehaviorSupportProfile. |
|
The History of the node that was resolved to identify this information set. |
|
Implement iter(self). |
|
|
Return bool(key in self). |
Computation on supports#
|
Return a support profile including only the strategies in profile which are not dominated by another pure strategy. |
Computation of Nash equilibria#
|
Compute all pure-strategy Nash equilibria of game. |
|
Compute all pure-strategy agent Nash equilibria of game. |
|
Compute all mixed-strategy Nash equilibria of a two-player game using the strategic representation. |
|
:ref:`Compute Nash equilibria by enumerating all support profiles of strategies or actions, and for each support finding all totally-mixed equilibria of the game over that support. |
|
Compute Nash equilibria of a two-player constant-sum game using linear programming. |
|
Compute Nash equilibria of a two-player game using linear complementarity programming. |
|
Compute an approximate Nash equilibrium of a game using Lyapunov function minimization. |
|
Compute an approximate agent Nash equilibrium of a game using Lyapunov function minimization. |
|
Compute a Nash equilibrium of a game using the logit quantal response equilibrium correspondence. |
|
Compute a Nash equilibrium of a game using simplicial subdivision. |
|
Compute a Nash equilibrium of a game using iterated polymatrix approximation. |
|
Compute Nash equilibria of a game using a global Newton method. |
|
Compute a Nash equilibrium of a game using [HerPee01] |
Each of these returns its own result type, documented below:
|
Common attributes shared by every result of a method which computes Nash equilibria in a game. |
|
The result of enumerating pure-strategy Nash equilibria (enumpure_solve) or pure-strategy agent Nash equilibria (enumpure_agent_solve). |
|
The result of enummixed_solve. |
|
The result of enumpoly_solve. |
|
The result of lp_solve. |
|
The result of lcp_solve when solving on the strategic representation. |
|
The result of lcp_solve when solving on the extensive representation. |
|
The result of liap_solve or liap_agent_solve. |
|
The result of logit_solve. |
|
The result of simpdiv_solve. |
|
The result of ipa_solve. |
|
The result of gnm_solve. |
|
The result of hp_solve. |
Computation of quantal response equilibria#
|
|
|
Compute the QRE(s) at the specified value(s) of lam along the principal branch. |
|
Use maximum likelihood estimation to find the logit quantal response equilibrium which best fits empirical frequencies of play. |
|
The result of fitting a QRE to a given probability distribution over strategies. |
|
The result of fitting a QRE to a given probability distribution over actions. |
Catalog of games#
|
Load a game from the package catalog. |
|
Generate a game using the OpenSpiel library. |
|
Generate a game using the GAMUT game generator. |
Return a DataFrame listing all 35 GAMUT game classes. |
|
|
List games available in the package catalog. |
