Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Creating Games

GTDraw cannot be used to generate games directly. Games can be specified via .ef format files which include layout formatting, or via Gambit’s .efg format files (requires pygambit). .ef files can be created via Game Theory Explorer, or by hand.

Games can alternatively be specified via pygambit game objects; see the Python API section for details, or read the tutorial in the Gambit documentation: Tutorial 4) Creating publication-ready game images.

GTDraw also supports Normal Form Games (.nfg files) — see the NFG section below.

GTDraw serves as a bridge between game theory file formats and high-quality visualizations. The diagram below illustrates how data flows from various sources through GTDraw to produce publication-ready graphics.

Data Flow

  1. Sources: Games can be designed in GTE (Game Theory Explorer) or managed via the Gambit suite (PyGambit, GUI, or CLI).

  2. Formats:

    • EF: The native GTDraw format, optimized for manual layout and TikZ rendering.

    • EFG: The standard Gambit format.

  3. Conversion: The converter.py module provides robust two-way conversion between EF and EFG formats to ensure compatibility between different tools.

  4. Generation: GTDraw can natively ingest either EF or EFG files to generate output.

    • EFG files are internally converted to an EF representation via gambit_layout.py.

    • All drawing functions live in core.py. tikz() is the foundation — it produces raw TikZ code from the EF data. draw(), tex(), and pdf() each call tikz() internally; png() and svg() build on pdf().

Normal Form Games (NFG)

GTDraw renders normal form (strategic form) games from Gambit’s .nfg file format or from pygambit NFG game objects.

For NFG inputs, tikz() returns the raw \begin{game}...\end{game} LaTeX body produced by pygambit’s game.to_latex(). This uses the sgame LaTeX package to typeset the payoff matrix.

Rendering to PDF, PNG, or SVG compiles this LaTeX body with pdflatex and requires the sgame package (provided by texlive-games on Ubuntu, or included in full TeX Live / MiKTeX distributions).