Game Generators

Exported

GameTheory.covariance_gameMethod
covariance_game([rng=GLOBAL_RNG], nums_actions, rho)

Return a random N-player NormalFormGame instance with N>=2 where the payoff profiles are drawn independently from the standard multi-normal with the covariance of any pair of payoffs equal to rho, as studied in Rinott and Scarsini (2000).

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • nums_actions::NTuple{N,Int}: Tuple of the numbers of actions, one for each player.
  • rho::Real: Covariance of a pair of payoff values. Must be in [-1/(N-1), 1], where N is the number of players.

Returns

  • ::NormalFormGame: The generated random N-player NormalFormGame.

Examples

julia> using GameTheory, Random

julia> rng = MersenneTwister(12345);

julia> g = covariance_game(rng, (4, 3), -0.7);

julia> println(g)
4×3 NormalFormGame{2, Float64}:
 [1.17236, -0.211696]   [1.46647, -1.13947]    [0.378353, 0.603951]
 [0.415565, 0.0779055]  [0.606808, 1.00812]    [1.12871, -1.03399]
 [0.685759, -0.278449]  [-0.588508, 0.464548]  [-0.970332, -0.0319236]
 [-1.47708, 1.12447]    [1.92585, -2.27959]    [-2.1476, 1.53569]

References

  • Y. Rinott and M. Scarsini, "On the Number of Pure Strategy Nash Equilibria in Random Games," Games and Economic Behavior (2000), 274-293.
source
GameTheory.random_gameMethod
random_game([rng=GLOBAL_RNG], [S=Float64], nums_actions)

Return a random N-player NormalFormGame instance where the payoffs are drawn independently from the uniform distribution on the set as determined by S. S is a range (such as 0:9) or a subtype of Integer or AbstractFloat; in the latter case, the set is [0, 1) for floats and typemin(S):typemax(S) for integers.

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • S::Union{Type,AbstractRange}: Set of values from which payoffs are drawn.
  • nums_actions::NTuple{N,Int}: Tuple of the numbers of actions, one for each player.

Returns

  • ::NormalFormGame: The generated random N-player NormalFormGame.

Examples

julia> using GameTheory, Random

julia> rng = MersenneTwister(12345);

julia> g = random_game(rng, (4, 3));

julia> println(g)
4×3 NormalFormGame{2, Float64}:
 [0.562714, 0.586598]  [0.381128, 0.0501668]  [0.922317, 0.61179]
 [0.849939, 0.620099]  [0.365801, 0.215712]   [0.0404417, 0.569955]
 [0.371605, 0.965631]  [0.835014, 0.364706]   [0.573382, 0.923602]
 [0.283365, 0.754047]  [0.260024, 0.696476]   [0.981364, 0.0311643]

julia> g = random_game(rng, 0:9, (4, 3));

julia> println(g)
4×3 NormalFormGame{2, Int64}:
 [1, 5]  [1, 2]  [6, 2]
 [2, 5]  [0, 2]  [1, 0]
 [0, 5]  [3, 9]  [1, 1]
 [9, 5]  [2, 9]  [0, 6]
source
GameTheory.random_mixed_actionsMethod
random_mixed_actions([rng=GLOBAL_RNG], nums_actions)

Return a tuple of random mixed actions (vectors of floats).

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • nums_actions::NTuple{N,Int}: N-tuple of the numbers of actions, one for each player.

Returns

  • ::NTuple{N,Vector{Float64}}: N-tuple of random mixed actions.
source
GameTheory.random_pure_actionsMethod
random_pure_actions([rng=GLOBAL_RNG], nums_actions)

Return a tuple of random pure actions (integers).

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • nums_actions::NTuple{N,Int}: N-tuple of the numbers of actions, one for each player.

Returns

  • ::NTuple{N,Int}: N-tuple of random pure actions.
source
GameTheory.Generators.blotto_gameFunction
blotto_game([rng=GLOBAL_RNG], h, t, rho[, mu=0])

Return a NormalFormGame instance of a 2-player non-zero sum Colonel Blotto game (Hortala-Vallve and Llorente-Saguer, 2012), where the players have an equal number t of troops to assign to h hills (so that the number of actions for each player is equal to (t+h-1) choose (h-1) = (T+h-1)!/(T!*(h-1)!)). Each player has a value for each hill that he receives if he assigns strictly more troops to the hill than his opponent (ties are broken uniformly at random), where the values are drawn from a multivariate normal distribution with covariance rho. Each player’s payoff is the sum of the values of the hills won by that player.

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • h::Integer : Number of hills.
  • t::Integer : Number of troops.
  • rho::Real : Covariance of the players' values of each hill. Must be in [-1, 1].
  • mu::Real=0 : Mean of the players' values of each hill.

Returns

  • g::NormalFormGame

Examples

julia> using GameTheory.Generators, Random

julia> rng = MersenneTwister(1234);

julia> g = blotto_game(rng, 2, 3, 0.5)
4×4 NormalFormGame{2, Float64}

julia> g.players[1]
4×4 Player{2, Float64}:
 0.186434  -0.494479  -0.494479  -0.494479
 0.867347   0.186434  -0.494479  -0.494479
 0.867347   0.867347   0.186434  -0.494479
 0.867347   0.867347   0.867347   0.186434

julia> g.players[2]
4×4 Player{2, Float64}:
 -0.688223  -1.02919   -1.02919   -1.02919
 -0.347259  -0.688223  -1.02919   -1.02919
 -0.347259  -0.347259  -0.688223  -1.02919
 -0.347259  -0.347259  -0.347259  -0.688223
source
GameTheory.Generators.ranking_gameFunction
ranking_game([rng=GLOBAL_RNG], n[, steps=10])

Return a NormalFormGame instance of (the 2-player version of) the "ranking game" studied by Goldberg et al. (2013), where each player chooses an effort level associated with a score and a cost which are both increasing functions with randomly generated step sizes. The player with the higher score wins the first prize, whose value is 1, and the other player obtains the "second prize" of value 0; in the case of a tie, the first prize is split and each player receives a value of 0.5. The payoff of a player is given by the value of the prize minus the cost of the effort.

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • n::Integer : Number of actions, i.e, number of possible effort levels.
  • steps::Integer=10 : Parameter determining the upper bound for the size of the random steps for the scores and costs for each player: The step sizes for the scores are drawn from 1, ..., steps, while those for the costs are multiples of 1/(n*steps), where the cost of effort level 1 is 0, and the maximum possible cost of effort level n is less than or equal to 1.

Returns

  • g::NormalFormGame

Examples

julia> using GameTheory.Generators, Random

julia> rng = MersenneTwister(1234);

julia> g = ranking_game(rng, 5)
5×5 NormalFormGame{2, Float64}

julia> g.players[1]
5×5 Player{2, Float64}:
 0.5    0.0    0.0    0.0    0.0
 0.92  -0.08  -0.08  -0.08  -0.08
 0.88   0.88   0.88   0.88  -0.12
 0.74   0.74   0.74   0.74   0.74
 0.58   0.58   0.58   0.58   0.58

julia> g.players[2]
5×5 Player{2, Float64}:
 0.5   0.0    0.0    0.0    0.0
 0.92  0.92  -0.08  -0.08  -0.08
 0.76  0.76  -0.24  -0.24  -0.24
 0.56  0.56  -0.44  -0.44  -0.44
 0.44  0.44   0.44  -0.56  -0.56
source
GameTheory.Generators.sgc_gameMethod
sgc_game(k)

Return a NormalFormGame instance of the 2-player game introduced by Sandholm, Gilpin, and Conitzer (2005), which has a unique Nash equilibrium, where each player plays half of the actions with positive probabilities. Payoffs are normalized so that the minimum and the maximum payoffs are 0 and 1, respectively.

Arguments

  • k::Integer : Positive integer determining the number of actions. The returned game will have 4*k-1 actions for each player.

Returns

  • g::NormalFormGame

Examples

julia> using GameTheory.Generators

julia> g = sgc_game(2)
7×7 NormalFormGame{2, Float64}

julia> g.players[1]
7×7 Player{2, Float64}:
 0.75  0.5   1.0   0.5   0.5   0.5   0.5
 1.0   0.75  0.5   0.5   0.5   0.5   0.5
 0.5   1.0   0.75  0.5   0.5   0.5   0.5
 0.0   0.0   0.0   0.75  0.0   0.0   0.0
 0.0   0.0   0.0   0.0   0.75  0.0   0.0
 0.0   0.0   0.0   0.0   0.0   0.75  0.0
 0.0   0.0   0.0   0.0   0.0   0.0   0.75

julia> g.players[2]
7×7 Player{2, Float64}:
 0.75  0.5   1.0   0.5   0.5   0.5   0.5
 1.0   0.75  0.5   0.5   0.5   0.5   0.5
 0.5   1.0   0.75  0.5   0.5   0.5   0.5
 0.0   0.0   0.0   0.0   0.75  0.0   0.0
 0.0   0.0   0.0   0.75  0.0   0.0   0.0
 0.0   0.0   0.0   0.0   0.0   0.0   0.75
 0.0   0.0   0.0   0.0   0.0   0.75  0.0
source
GameTheory.Generators.tournament_gameMethod
tournament_game([rng=GLOBAL_RNG], n, k)

Return a NormalFormGame instance of the 2-player win-lose game, whose payoffs are either 0 or 1, introduced by Anbalagan et al. (2013). Player 1 has n actions, which constitute the set of nodes {1, ..., n}, while player 2 has n choose k actions, each corresponding to a subset of k elements of the set of n nodes. Given a randomly generated tournament graph on the n nodes, the payoff for player 1 is 1 if, in the tournament, the node chosen by player 1 dominates all the nodes in the k-subset chosen by player 2. The payoff for player 2 is 1 if player 2's k-subset contains player 1's chosen node.

Notes

The actions of player 2 are ordered according to the combinatorial number system, which is different from the order used in the original library in C.

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • n::Integer : Number of nodes in the tournament graph.
  • k::Integer : Size of subsets of nodes in the tournament graph.

Returns

  • g::NormalFormGame

Examples

julia> using GameTheory.Generators, Random

julia> rng = MersenneTwister(1234);

julia> g = tournament_game(rng, 5, 2)
5×10 NormalFormGame{2, Float64}

julia> g.players[1]
5×10 Player{2, Float64}:
 0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  1.0  1.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0
 0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0

julia> g.players[2]
10×5 Player{2, Float64}:
 1.0  1.0  0.0  0.0  0.0
 1.0  0.0  1.0  0.0  0.0
 0.0  1.0  1.0  0.0  0.0
 1.0  0.0  0.0  1.0  0.0
 0.0  1.0  0.0  1.0  0.0
 0.0  0.0  1.0  1.0  0.0
 1.0  0.0  0.0  0.0  1.0
 0.0  1.0  0.0  0.0  1.0
 0.0  0.0  1.0  0.0  1.0
 0.0  0.0  0.0  1.0  1.0
source
GameTheory.Generators.unit_vector_gameMethod
unit_vector_game([rng=GLOBAL_RNG], n; avoid_pure_nash=false)

Return a NormalFormGame instance of the 2-player game "unit vector game" (Savani and von Stengel, 2016). Payoffs for player 2 are chosen randomly from the [0, 1) range. For player 1, each column contains exactly one 1 payoff and the rest is

Arguments

  • rng::AbstractRNG=GLOBAL_RNG: Random number generator used.
  • n::Integer : Number of actions.
  • avoid_pure_nash::Bool=false : If true, player 1's payoffs will be placed in order to avoid pure Nash equilibria. (If necessary, the payoffs for player 2 are redrawn so as not to have a dominant action.)

Returns

  • g::NormalFormGame

Examples

julia> using GameTheory.Generators, Random

julia> rng = MersenneTwister(123456);

julia> g = unit_vector_game(rng, 5)
5×5 NormalFormGame{2, Float64}

julia> g.players[1]
5×5 Player{2, Float64}:
 0.0  0.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0  1.0
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  1.0  0.0  0.0
 0.0  1.0  0.0  1.0  0.0

julia> g.players[2]
5×5 Player{2, Float64}:
 0.51521   0.574332    0.391494   0.316183  0.913325
 0.74129   0.47338     0.0110828  0.986807  0.302641
 0.582142  0.635053    0.7289     0.324831  0.240347
 0.209969  0.00394602  0.588569   0.627509  0.692993
 0.180649  0.998717    0.0955464  0.974204  0.994846

julia> pure_nash(g)
1-element Vector{Tuple{Int64, Int64}}:
 (2, 5)

With avoid_pure_nash=true:

julia> rng = MersenneTwister(123456);

julia> g = unit_vector_game(rng, 5; avoid_pure_nash=true)
5×5 NormalFormGame{2, Float64}

julia> g.players[1]
5×5 Player{2, Float64}:
 0.0  0.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0
 0.0  0.0  1.0  0.0  0.0
 0.0  1.0  0.0  1.0  0.0

julia> g.players[2]
5×5 Player{2, Float64}:
 0.51521   0.574332    0.391494   0.316183  0.913325
 0.74129   0.47338     0.0110828  0.986807  0.302641
 0.582142  0.635053    0.7289     0.324831  0.240347
 0.209969  0.00394602  0.588569   0.627509  0.692993
 0.180649  0.998717    0.0955464  0.974204  0.994846

julia> pure_nash(g)
Tuple{Int64, Int64}[]
source

Internal