Generating games for the catalog#
Alongside the curated catalog of games (built and hosted separately; see the catalog’s developer guide for how to contribute new games), pygambit can generate games on the fly from two external sources: the OpenSpiel library and the GAMUT suite.
Loading OpenSpiel games
Games from the OpenSpiel library
can be generated using pygambit.catalog.generate_openspiel():
pygambit.catalog.generate_openspiel("matrix_rps")
pygambit.catalog.generate_openspiel("tiny_hanabi")
pygambit.catalog.generate_openspiel("blotto", params={"players": 2, "coins": 3, "fields": 2})
The params argument is forwarded directly to pyspiel.load_game; see the
OpenSpiel game list for
available parameters per game.
This requires open_spiel to be installed (pip install open_spiel;
not available on Windows). The game is exported to EFG or NFG format on the fly
and loaded into Gambit. Not all OpenSpiel games can be exported; a
ValueError is raised for games that are incompatible with either format.
See the OpenSpiel interoperability tutorial for worked examples.
Generating GAMUT games
Games from the GAMUT generator suite can be created
using pygambit.catalog.generate_gamut():
pygambit.catalog.generate_gamut("RandomGame", params={"players": 2, "actions": 3}, gamut_jar="/path/to/gamut.jar")
pygambit.catalog.generate_gamut("CovariantGame", params={"players": 2, "actions": [3, 3]}, gamut_jar="/path/to/gamut.jar")
pygambit.catalog.generate_gamut(
"RandomGame",
params={"players": 3, "actions": 4, "normalize": True, "min_payoff": 0, "max_payoff": 100},
gamut_jar="/path/to/gamut.jar",
)
The params argument maps directly to GAMUT command-line flags. Boolean flags such as
-normalize and -int_payoffs are passed as True; list values for -actions
expand to space-separated tokens. See the
GAMUT documentation for the full list
of game classes and parameters.
GAMUT requires Java (install from java.com) and
gamut.jar to be installed. Provide the path to gamut.jar via the gamut_jar
argument or the GAMUT_JAR environment variable. Download GAMUT from
http://gamut.stanford.edu/.
All 35 GAMUT game classes
| Class | Description | Players | |
|---|---|---|---|
| 0 | ArmsRace | Arms race with cost and demand functions chose... | n |
| 1 | BattleOfTheSexes | Coordination game where players prefer to meet... | 2 |
| 2 | BertrandOligopoly | Bertrand oligopoly with arbitrary cost and dem... | n |
| 3 | BidirectionalLEG | Bidirectional local-effect game on a specified... | n |
| 4 | Chicken | Classic 2x2 Chicken game. | 2 |
| 5 | CollaborationGame | Game where all players choosing the same actio... | n |
| 6 | CongestionGame | Congestion game where payoffs depend on how ma... | n |
| 7 | CoordinationGame | Pure coordination game rewarding matching acti... | n |
| 8 | CournotDuopoly | Cournot duopoly with arbitrary cost and invers... | 2 |
| 9 | CovariantGame | Game with payoffs whose cross-player correlati... | n |
| 10 | DispersionGame | Game where dispersed action choices are rewarded. | n |
| 11 | GrabTheDollar | Simultaneous competition to claim a prize first. | 2 |
| 12 | GreedyGame | Players each choose a subset from a set; payof... | 2 |
| 13 | GuessThirdsAve | Players guess a number trying to reach 2/3 of ... | n |
| 14 | HawkAndDove | Classic 2x2 Hawk and Dove game. | 2 |
| 15 | LocationGame | Hotelling-style two-player location game on a ... | 2 |
| 16 | MajorityVoting | Majority voting game with arbitrary candidate ... | n |
| 17 | MatchingPennies | Classic 2x2 Matching Pennies game. | 2 |
| 18 | MinimumEffortGame | Payoffs depend on the minimum effort exerted a... | n |
| 19 | NPlayerChicken | N-player Chicken game with cooperation costs a... | n |
| 20 | NPlayerPrisonersDilemma | N-player Prisoner's Dilemma with parameterised... | n |
| 21 | PolymatrixGame | Polymatrix game formed by two-player edge game... | n |
| 22 | PrisonersDilemma | Classic 2x2 Prisoner's Dilemma. | 2 |
| 23 | RandomCompoundGame | Compound game whose payoffs are sums of random... | n |
| 24 | RandomGame | Game with payoffs drawn uniformly at random. | n |
| 25 | RandomGraphicalGame | Random graphical game on a specified graph. | n |
| 26 | RandomLEG | Random local-effect game on a specified graph. | n |
| 27 | RandomZeroSum | Two-player zero-sum game with random payoffs. | 2 |
| 28 | RockPaperScissors | Classic Rock, Paper, Scissors game. | 2 |
| 29 | ShapleyGame | Shapley's original game; no stable equilibrium... | 2 |
| 30 | SimpleInspectionGame | Inspection game where players choose from diff... | 2 |
| 31 | TravelersDilemma | Players claim a value; the lowest claim wins a... | n |
| 32 | TwoByTwoGame | 2x2 game of a specified type per Rapoport's cl... | 2 |
| 33 | UniformLEG | Local-effect game where all edges share the sa... | n |
| 34 | WarOfAttrition | Players choose concession times; payoffs depen... | 2 |
See the GAMUT interoperability tutorial for worked examples.
