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. A game is drawn from a text source: a drawing in GTDraw’s .ef format, which includes layout formatting, or the LaTeX body of a strategic game (an sgame table) as a .tex file. A source is a path or a file-like object; in Python, the kind of a path is its extension (.ef or .tex) or the format="ef" / format="sgame" argument, and a text buffer is a drawing unless format says otherwise. .ef files can be created via Game Theory Explorer, or by hand.

GTDraw does not read Gambit’s game files (.efg, .nfg) and does not depend on pygambit. To draw a Gambit game, convert it to a drawing with pygambit first, then draw the file; see the Gambit documentation, Tutorial 4) Creating publication-ready game images.

GTDraw serves as a bridge between text descriptions of games 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), written by hand, or converted from a Gambit game with pygambit.

  2. Formats:

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

    • sgame: The LaTeX body of a strategic game table, as a .tex file.

  3. Generation: All drawing functions live in core.py. tikz() is the foundation: it produces raw TikZ code from the EF data (for an sgame body it returns the body unchanged). draw(), tex(), and pdf() each call tikz() internally; png() and svg() compile with pdflatex as pdf() does and convert the PDF with pdftocairo.

Strategic Games

GTDraw renders strategic (normal) form games from the LaTeX body of an sgame table, given as a .tex file (or a buffer with format="sgame"): the \begin{game}...\end{game} environment, with its payoffs.

For such a source, tikz() returns the body unchanged. Rendering to PDF, PNG, or SVG wraps it in a document and compiles it with pdflatex, and requires the sgame package (provided by texlive-games on Ubuntu, or included in full TeX Live / MiKTeX distributions).