GameTheory.jl
GameTheory.jl is a Julia package about algorithms and data structures for Game Theory.
Installation
To install the package, enter the Pkg mode by pressing ] and run
add GameTheoryUsage
Once installed, the GameTheory package can be used by typing
using GameTheoryThe Base type Player can be created by passing a payoff matrix:
player1 = Player([3 1; 0 2])2×2 Player{2, Int64}:
3 1
0 2A 2-player NormalFormGame can be created either by passing Player instances,
player2 = Player([2 0; 1 3])
g = NormalFormGame((player1, player2))
print(g)2×2 NormalFormGame{2, Int64}:
[3, 2] [1, 1]
[0, 0] [2, 3]or by passing a payoff matrix directly:
payoff_bimatrix = Array{Int}(undef, 2, 2, 2)
payoff_bimatrix[1, 1, :] = [3, 2]
payoff_bimatrix[1, 2, :] = [1, 1]
payoff_bimatrix[2, 1, :] = [0, 0]
payoff_bimatrix[2, 2, :] = [2, 3]
g = NormalFormGame(payoff_bimatrix)
print(g)2×2 NormalFormGame{2, Int64}:
[3, 2] [1, 1]
[0, 0] [2, 3]After constructing a NormalFormGame, we can find its Nash Equilibria by using methods of GameTheory. For example, pure_nash finds all pure action Nash Equilibria by enumeration:
pure_nash(g)2-element Vector{Tuple{Int64, Int64}}:
(1, 1)
(2, 2)Please see the notebooks on QuantEcon for more details.
Notebooks
Some notebooks for demonstration are available: