API documentation#

Representation of games#

Game

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

Player

A player in a Game.

Outcome

An outcome in a Game.

Node

A node in a Game.

Infoset

An information set in a Game.

Action

A choice available at an Infoset in a Game.

Strategy

A plan of action for a Player in a Game.

Creating, reading, and writing games#

read_gbt(filepath_or_buffer[, normalize_labels])

Construct a game from its serialised representation in a GBT file.

read_efg(filepath_or_buffer[, normalize_labels])

Construct a game from its serialised representation in an EFG file.

read_nfg(filepath_or_buffer[, normalize_labels])

Construct a game from its serialised representation in a NFG file.

read_agg(filepath_or_buffer[, normalize_labels])

Construct a game from its serialised representation in an AGG file.

Game.new_tree([players, title])

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

Game.new_table(dim[, title])

Create a new Game with a strategic representation.

Game.from_arrays(*arrays[, title])

Create a new Game with a strategic representation.

Game.to_arrays(dtype)

Generate the payoff tables for players represented as numpy arrays.

Game.from_dict(payoffs[, title])

Create a new Game with a strategic representation.

Game.to_efg([filepath_or_buffer])

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

Game.to_nfg([filepath_or_buffer])

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

Game.to_html([filepath_or_buffer])

Export the game to HTML format.

Game.to_latex([filepath_or_buffer])

Export the game to LaTeX format.

Transforming game trees#

Game.append_move(nodes, player, actions)

Add a move for player at terminal nodes.

Game.append_infoset(nodes, infoset)

Add a move in information set infoset at terminal nodes.

Game.insert_move(node, player, actions)

Insert a move for player prior to the node node, with actions actions.

Game.insert_infoset(node, infoset)

Insert a move in information set infoset prior to the node node.

Game.copy_tree(src, dest)

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

Game.move_tree(src, dest)

Move the subtree rooted at 'src' to 'dest'.

Game.delete_parent(node)

Delete the parent node of node.

Game.delete_tree(node)

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

Transforming game information structure#

Game.set_player(infoset, player)

Set the player at an information set.

Game.set_infoset(node, infoset)

Place node in the information set infoset.

Game.leave_infoset(node)

Remove this node from its information set.

Game.set_chance_probs(infoset, probs)

Set the action probabilities at chance information set infoset.

Game.reveal(infoset, player)

Reveals the move made at infoset to player.

Game.sort_infosets()

Sort information sets into a standard order.

Transforming game components#

Game.add_player([label])

Add a new player to the game.

Game.add_outcome([payoffs, label])

Add a new outcome to the game.

Game.delete_outcome(outcome)

Delete an outcome from the game.

Game.set_outcome(node, outcome)

Set outcome to be the outcome at node.

Game.add_strategy(player[, label])

Add a new strategy to the set of strategies for player.

Game.delete_strategy(strategy)

Delete strategy from the game.

Information about the game#

Game.title

Get or set the title of the game.

Game.description

Get or set the description of the game.

Game.is_const_sum

Whether the game is constant sum.

Game.is_tree

Return whether a game has a tree-based representation.

Game.is_perfect_recall

Whether the game is perfect recall.

Game.players

The set of players in the game.

Game.outcomes

The set of outcomes in the game.

Game.min_payoff

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

Game.max_payoff

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

Game.strategies

The set of strategies in the game.

Game.root

The root node of the game.

Game.actions

The set of actions available in the game.

Game.infosets

The set of information sets in the game.

Game.nodes

The set of nodes in the game.

Game.contingencies

An iterator over the contingencies in the game.

Player.label

Gets or sets the text label of the player.

Player.number

Returns the number of the player in its game.

Player.game

Gets the Game to which the player belongs.

Player.strategies

Returns the set of strategies belonging to the player.

Player.infosets

Returns the set of information sets at which the player has the decision.

Player.actions

Returns the set of actions available to the player at some information set.

Player.is_chance

Returns whether the player is the chance player.

Player.min_payoff

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

Player.max_payoff

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

Player.strategies

Returns the set of strategies belonging to the player.

Outcome.label

The text label associated with this outcome.

Outcome.number

Returns the number of the outcome in the game.

Outcome.game

Returns the game with which this outcome is associated.

Node.label

The text label associated with the node.

Node.game

Gets the Game to which the node belongs.

Node.outcome

Returns the outcome attached to the node.

Node.children

The set of children of this node.

Node.parent

The parent of this node.

Node.is_subgame_root

Returns whether the node is the root of a proper subgame.

Node.is_terminal

Returns whether this is a terminal node of the game.

Node.is_strategy_reachable

Returns whether this node is reachable by any pure strategy profile.

Node.prior_action

The action which leads to this node.

Node.prior_sibling

The node which is immediately before this one in its parent's children.

Node.next_sibling

The node which is immediately after this one in its parent's children.

Node.infoset

The information set to which this node belongs.

Node.player

The player who makes the decision at this node.

Node.is_successor_of(node)

Returns whether this node is a successor of node.

Node.plays

Returns a list of all terminal Node objects consistent with it.

Node.own_prior_action

The last action taken by the node's owner before reaching this node.

Infoset.label

Get or set the text label of the information set.

Infoset.game

The Game to which the information set belongs.

Infoset.is_chance

Whether the information set belongs to the chance player.

Infoset.is_absent_minded

Whether the information set is absent-minded.

Infoset.player

The player who has the move at this information set.

Infoset.actions

The set of actions at the information set.

Infoset.members

The set of nodes which are members of the information set.

Infoset.precedes(node)

Return whether this information set precedes node in the game tree.

Infoset.plays

Returns a list of all terminal Node objects consistent with it.

Infoset.own_prior_actions

The set of actions taken by the player immediately preceding the member nodes in the information set.

Action.label

Get or set the text label of the action.

Action.infoset

Get the information set to which the action belongs.

Action.precedes(node)

Returns whether node precedes this action in the extensive game.

Action.prob

Get the probability a chance action is played.

Action.plays

Returns a list of all terminal Node objects consistent with it.

Strategy.label

Get or set the text label associated with the strategy.

Strategy.game

The game to which the strategy belongs.

Strategy.player

The player to which the strategy belongs.

Strategy.number

The number of the strategy.

Strategy.action(infoset)

Get the action prescribed by a strategy for a given information set.

Player behavior#

Game.mixed_strategy_profile([data, rational])

Create a mixed strategy profile over the game.

Game.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.

Game.mixed_behavior_profile([data, rational])

Create a mixed behavior profile over the game.

Game.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.

Game.strategy_support_profile([strategies])

Create a new StrategySupportProfile on the game.

Representation of strategic behavior#

Probability distributions over strategies#

MixedStrategyProfile

Represents a mixed strategy profile over the strategies in a Game.

MixedStrategyProfile.game

The game on which this mixed strategy profile is defined.

MixedStrategyProfile.mixed_strategies()

Iterate over the mixed strategies in the profile.

MixedStrategyProfile.__iter__

Iterate over the probabilities assigned to strategies by the profile.

MixedStrategyProfile.__getitem__

Access a component of the mixed strategy profile specified by index.

MixedStrategyProfile.__setitem__

Sets a probability or a mixed strategy to value.

MixedStrategyProfile.payoff(player)

Returns the expected payoff to a player if all players play according to the profile.

MixedStrategyProfile.strategy_value(strategy)

Returns the expected payoff to playing the strategy, if all other players play according to the profile.

MixedStrategyProfile.strategy_regret(strategy)

Returns the regret to playing strategy, if all other players play according to the profile.

MixedStrategyProfile.player_regret(player)

Returns the regret of player for playing their mixed strategy, if all other players play according to the profile.

MixedStrategyProfile.strategy_value_deriv(...)

Returns the derivative of the payoff to playing strategy, with respect to the probability that other is played.

MixedStrategyProfile.max_regret()

Returns the maximum regret of any player.

MixedStrategyProfile.liap_value()

Returns the Lyapunov value (see [McK91]) of the strategy profile.

MixedStrategyProfile.as_behavior()

Creates a mixed behavior profile which is equivalent to this mixed strategy profile.

MixedStrategyProfile.normalize()

Create a profile with the same strategy proportions as this one, but normalised so probabilities for each player sum to one.

MixedStrategyProfile.copy()

Creates a copy of the mixed strategy profile.

MixedStrategy

A probability distribution over a player's strategies.

MixedStrategy.__iter__

Iterate over the probabilities assigned to strategies by the mixed strategy.

MixedStrategy.__getitem__

Returns the probability that the strategy referred to by index is played.

MixedStrategy.__setitem__

Sets the probability a strategy is played.

Probability distributions over behavior#

MixedBehaviorProfile

Represents a mixed behavior profile over the actions in a Game.

MixedBehaviorProfile.game

The game on which this mixed behavior profile is defined.

MixedBehaviorProfile.mixed_behaviors()

Iterate over the mixed behaviors in the profile.

MixedBehaviorProfile.mixed_actions()

Iterate over the mixed actions specified by the profile.

MixedBehaviorProfile.__iter__

Iterate over the probabilities assigned to actions by the profile.

MixedBehaviorProfile.__getitem__

Access a component of the mixed behavior specified by index.

MixedBehaviorProfile.__setitem__

Sets a probability, mixed agent strategy, or mixed behavior strategy to value.

MixedBehaviorProfile.payoff(player)

Returns the expected payoff to a player if all players play according to the profile.

MixedBehaviorProfile.action_value(action)

Returns the expected payoff to the player of playing an action conditional on reaching its information set, if all players play according to the profile.

MixedBehaviorProfile.action_regret(action)

Returns the regret to playing action, if all other players play according to the profile.

MixedBehaviorProfile.infoset_value(infoset)

Returns the expected payoff to the player conditional on reaching an information set, if all players play according to the profile.

MixedBehaviorProfile.infoset_regret(infoset)

Returns the regret to the player for playing their mixed action at infoset, if all other players play according to the profile.

MixedBehaviorProfile.node_value(player, node)

Returns the expected payoff to player conditional on play reaching node, if all players play according to the profile.

MixedBehaviorProfile.realiz_prob(node)

Returns the probability with which a node is reached.

MixedBehaviorProfile.infoset_prob(infoset)

Returns the probability with which an information set is reached.

MixedBehaviorProfile.belief(node)

Returns the conditional probability that a node is reached, given that its information set is reached.

MixedBehaviorProfile.is_defined_at(infoset)

Returns whether the profile has probabilities defined at the information set.

MixedBehaviorProfile.agent_max_regret()

Returns the maximum regret at any information set.

MixedBehaviorProfile.agent_liap_value()

Returns the Lyapunov value (see [McK91]) of the strategy profile.

MixedBehaviorProfile.max_regret()

Returns the maximum regret at any information set.

MixedBehaviorProfile.liap_value()

Returns the Lyapunov value (see [McK91]) of the strategy profile.

MixedBehaviorProfile.as_strategy()

Returns a MixedStrategyProfile which is equivalent to the profile.

MixedBehaviorProfile.normalize()

Create a profile with the same action proportions as this one, but normalised so probabilities for each infoset sum to one.

MixedBehaviorProfile.copy()

Creates a copy of the behavior strategy profile.

MixedBehavior

A set of probability distributions describing a player's behavior.

MixedBehavior.mixed_actions()

Iterate over the mixed actions specified by the mixed behavior.

MixedBehavior.__iter__

Iterate over the probabilities assigned to actions by the mixed behavior.

MixedBehavior.__getitem__

Access a component of the mixed behavior specified by index.

MixedBehavior.__setitem__

Sets a component of the mixed behavior to value.

MixedAction

A probability distribution over a player's actions at an information set.

MixedAction.__iter__

Iterate over the probabilities assigned to actions by the mixed action.

MixedAction.__getitem__

Returns the probability that the action referred to by index is played.

MixedAction.__setitem__

Sets the probability an action is played.

Computation on supports#

undominated_strategies_solve(profile[, ...])

Return a support profile including only the strategies in profile which are not dominated by another pure strategy.

Computation of Nash equilibria#

NashComputationResult(game, method, ...)

Represents the result of a method which computes Nash equilibria in a game.

enumpure_solve(game)

Compute all pure-strategy Nash equilibria of game.

enumpure_agent_solve(game)

Compute all pure-strategy agent Nash equilibria of game.

enummixed_solve(game[, rational, lrsnash_path])

Compute all mixed-strategy Nash equilibria of a two-player game using the strategic representation.

enumpoly_solve(game[, use_strategic, ...])

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.

lp_solve(game[, rational, use_strategic])

Compute Nash equilibria of a two-player constant-sum game using linear programming.

lcp_solve(game[, rational, use_strategic, ...])

Compute Nash equilibria of a two-player game using linear complementarity programming.

liap_solve(start[, maxregret, maxiter])

Compute approximate Nash equilibria of a game using Lyapunov function minimization.

liap_agent_solve(start[, maxregret, maxiter])

Compute approximate agent Nash equilibria of a game using Lyapunov function minimization.

logit_solve(game[, use_strategic, ...])

Compute Nash equilibria of a game using the logit quantal response equilibrium correspondence.

simpdiv_solve(start[, maxregret, refine, leash])

Compute Nash equilibria of a game using simplicial subdivision.

ipa_solve(perturbation)

Compute Nash equilibria of a game using iterated polymatrix approximation.

gnm_solve(perturbation[, end_lambda, steps, ...])

Compute Nash equilibria of a game using a global Newton method.

Computation of quantal response equilibria#

logit_solve_branch(game[, use_strategic, ...])

logit_solve_lambda(game, lam[, ...])

logit_estimate(data[, use_empirical, ...])

Use maximum likelihood estimation to find the logit quantal response equilibrium which best fits empirical frequencies of play.

LogitQREMixedStrategyFitResult(data, method, ...)

The result of fitting a QRE to a given probability distribution over strategies.

LogitQREMixedBehaviorFitResult(data, method, ...)

The result of fitting a QRE to a given probability distribution over actions.

Catalog of games#

games([num_actions, num_contingencies, ...])

Return a list of catalog game class names.

Artist1()

Artist problem, one stage.

Artist2()

Artist problem, two stages.

Badgame1()

Agent Nash not Player Nash.

Badgame2()

Agent SPE not Player SPE.

Bagwell()

Bagwell Commitment and Unobservability Example.

Bayes1a()

General Bayes game, one stage.

Bayes2a()

General Bayesian game, two stages.

Bcp2()

Banks-Camerer-Porter (GEB 94), Game 2.

Bcp3()

Banks-Camerer-Porter (GEB 94), Game 3.

Bcp4()

Banks-Camerer-Porter (GEB 94), Game 4.

Bhg1()

Brandts-Holt, IJGT 93, Game 1.

Bhg2()

Brandts-Holt, IJGT 93, Game 2.

Bhg3()

Brandts-Holt, IJGT 93, Game 3.

Bhg4()

Brandts-Holt, IJGT 93, Game 4.

Bhg5()

Brandts-Holt, IJGT 93, Game 5.

Caro2()

Caro2.

Cent2()

Centipede game.

Cent2NFG()

Centipede game.

Cent3()

Centipede game.

Cent4()

Centipede game, 4 move.

Cent6()

Centipede game, 6 move.

Centcs10()

Centipede game, 10 move constant sum.

Centcs6()

Centipede game, 6 move constant sum.

Condjury()

Feddersen-Pesendorfer, three person Condorcet jury game.

Coord2()

Two person 2x2 game coordination game.

Coord2NFG()

Two person 2x2 coordination game with 3 Nash equilibria.

Coord2ts()

Two stage 2x2 game -- 3 Nash equilibria in stage game.

Coord3()

Two person 3 x 3 coordination problem with 7 Nash equilibria.

Coord333()

Three player 3x3x3 coordination game.

Coord3NFG()

3x3 coordination game with 7 Nash equilibria.

Coord4()

Two person 4 x 4 coordination problem with 15 Nash equilibria.

Coord4NFG()

4x4 coordination game with 15 Nash equilibria.

Cross()

Criss-crossing infosets.

Cs()

Chain store paradox, with three entrants.

Csg1()

2x2 constant sum game with a continuum of equilibria.

Csg2()

Two person 4x4 constant sum game with a continuum of equilibria.

Csg3()

Two person constant sum game with a continuum of equilibria.

Csg4()

Two person 4x4 constant sum game with a continuum of equilibria.

Deg1()

Degenerate 3x3 game 1.

Deg2()

Degenerate 3x3 game 2.

E01()

Selten (IJGT, 75), Figure 1.

E01NFG()

Selten (IJGT, 75), Figure 1, normal form.

E02()

Selten (IJGT, 75), Figure 2.

E02NFG()

Selten (IJGT, 75), Figure 2, normal form.

E03()

Selten (IJGT, 75), Figure 3.

E04()

Kreps-Wilson (Econometrica, 85), Figures 1,4,9, and 14.

E04NFG()

Kreps-Wilson (Econometrica, 85), Figures 1,4,9,14, normal form.

E05()

Kreps, Wilson (Econometrica, 85), Figure 8.

E06()

Kreps Wilson (Econometrica, 85), Figure 11.

E07()

Harsanyi (Managment Sci, 68), Table 1.

E07NFG()

Harsanyi (Managment Sci, 68), Table 1.

E08()

Plurality Voting, Three alternatives, simultaneous vote.

E09()

Binary voting, Successive procedure, no recall.

E10()

Nim with 5 stones.

E10a()

Nim with 5 stones.

E13()

Two Stage Prisoners' Dilemma.

E16()

Peter's Game.

E17()

Cho-Kreps (QJE 87) Fig 1, Beer-Quiche Game.

E18()

Banks-Sobel, Example 1.

G1()

van der Laan et al. Three person, 2 x 2 x 2 example with no pure Nash .

G1NFG()

van der Laan et al. Three person, 2x2x2 example with no pure, 1 totally mixed equilibria.

G2()

van der Laan et al. Three person 3 x 3 x 3 example with no pure Nash.

G2NFG()

van der Laan et al. Three person 3x3x3 example with no pure, and one mixed equilibrium.

G3()

van der Laan et al. Four person, 2 x 2 x 2 x 2 example with no Pure Nash.

G3NFG()

van der Laan et al. Four person, 2x2x2x2 example with no pure, and five mixed equilibria.

Game2s2x2x2()

Two stage McKelvey McLennan game with 9 equilibria each stage.

Game2smp()

Two-stage matching pennies game.

Game2x2()

Two person 2 x 2 game with unique mixed equilibrium.

Game2x2a()

Two person 2 x 2 game with unique mixed equilibrium.

Game2x2const()

2 x 2 constant sum game with unique mixed equilibrium.

Game2x2x2()

McKelvey McLennan game with 9 equilibria, 2 totally mixed.

Game2x2x2NFG()

2x2x2 Example from McKelvey-McLennan, with 9 Nash equilibria, 2 totally mixed.

Game2x2x2_nau()

2x2x2 example with 3 pure, 2 incompletely mixed, and a continuum of completely mixed NE.

Game2x2x2x2()

Four person, 2x2x2x2 game with 3 Nash equilibria.

Game2x2x2x2x2()

Five person 2x2x2x2x2 game with five equilibria.

Game3x3x3()

Three person 3x3x3 game with five equilibria (two pure).

Game4cards()

4 Card poker, from Alix Martin.

Game5x4x3()

Three person random 5x4x3 game.

Game8x2x2()

Three person random 8x2x2 game.

Game8x8()

Random 8x8 game with 5 equilibria (3 pure).

Holdout()

McKelvey-Palfrey (JET 77), 7 stage version of holdout game.

Hs1()

Harsanyi, Selten (1988): example reanalyzed by Dickhaut Kaplan .

Jury_mr()

Jury game, majority rule.

Jury_un()

Jury game, unanimous vote required.

Km1()

Kohlberg Mertens, Example 1.

Km2()

Kohlberg, Mertens, Example 2.

Km3()

Kohlberg, Mertens, Example 3.

Km6()

Kohlberg, Mertens, Example 6.

Loopback()

Backward-bending principal logit branch.

Mixdom()

Two person 4x4 game needing mixed domination.

Mixdom2()

Two person 4x4 game needing mixed domination.

Montyhal()

The Monty Hall 'Lets make a deal' problem.

My_2_1()

Myerson (Game Theory), Exercise 2.1.

My_2_4()

Myerson (Game Theory), Exercise 2.4.

My_2_8()

Myerson (Game Theory), Exercise 2.8.

My_3_3a()

Myerson (Game Theory), Exercise 3.3a.

My_3_3b()

Myerson (Game Theory), Exercise 3.3b.

My_3_3c()

Myerson (Game Theory), Exercise 3.3c.

My_3_3d()

Myerson (Game Theory), Exercise 3.3d.

My_3_3e()

Myerson (Game Theory), Exercise 3.3e.

My_3_4()

Myerson (Game Theory), Exercise 3.4.

Myerson()

Myerson - Game with no solution in behavioral strategies.

Myerson_fig_4_2()

Myerson (1991) Fig 4.2.

Nim()

Nim-like game.

Nim7()

Nim-like game.

OneShotTrust(*args, **kwargs)

One-shot trust game.

Oneill()

Oneill's (1987 Proc NAS) game.

Palf()

McKelvey-Palfrey: one stage mixed strategy learning game.

Palf2()

McKelvey-Palfrey: two stage mixed strategy learning game.

Palf3()

Palfrey one sided incomplete info game with both types mixing.

Pbride()

Princess Bride signaling game (from Watson).

Perfect1()

Game with no dominated strategies, and dominated equilibrium.

Perfect2()

Game with no dominated pure strategies but with dominated Nash equilibria.

Perfect3()

Three person version of perfect2.

Poker()

A simple Poker game.

Poker2()

A Simple Poker Game with an initial ante.

PokerNFG()

A simple two person poker game in normal form.

PrisonersDilemma()

Two person Prisoner's Dilemma game.

Pvw()

Game from van Winden.

Pvw2()

Game 2 from van Winden.

Sh3()

Wilson's example of inaccessible equilibria (Shapley, 1974, Math Prog Stud).

Sh3NFG()

Wilson's example of inaccessible equilibria (Shapley, 1974, Math Prog Stud).

Spence()

Job-market signaling game (version from Watson).

Stengel()

von Stengel's two person 6 x 6 game with 75 equilibria.

Sww1()

Schotter-Weigelt-Wilson (GEB 94), Fig 1.

Sww1NFG()

Schotter-Weigelt-Wilson Fig 1 game in normal form.

Sww2()

Schotter-Weigelt-Wilson (GEB 94), Fig 2.

Sww3()

Schotter-Weigelt-Wilson (GEB 94), Fig 3.

Tim()

Game from Tim Feddersen.

Todd1()

Todd's (incorrect) example of incaccessible equilibria.

Todd2()

Todd's (corrected) example of incaccessible equilibria.

Todd3()

Todd's second example of incaccessible equilibria.

Ttt()

Tic Tac Toe (Not finished yet).

Vd()

Van Damme's Game.

VdNFG()

Van Damme's burning a dollar Game.

W_ex1()

Wilson's ex1.

W_ex2()

Wilson's ex2: Two stage battle of the sexes.

Wilson1()

Wilson (1991): a game with two weakly stable sets.

Wink3()

Simple example where CBFS != AllNash.

Winkels()

Winkels, 1979 degenerate game with 12 extreme equilibria.

Work1()

Employer - Employee problem, one stage.

Work2()

Employer - Employee problem, two stages.

Work3()

Employer - Employee problem, three stages.

Yamamoto()

Example game from Yamamoto (IJGT, 1993).

Zero()

Two person 2 x 2 game with all zero payoffs.