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

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

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

DrawTree serves as a bridge between game theory file formats and high-quality visualizations. The diagram below illustrates how data flows from various sources through DrawTree 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 DrawTree 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: DrawTree can natively ingest either EF or EFG files to generate output.

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

    • Generation functions in core.py then process the EF data to produce multiple formats including TikZ, TeX, SVG, PNG, and PDF.

Normal Form Games (NFG)

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

For NFG inputs, generate_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).