Typesetting extensive form games in LaTeX

Apr. 15, 2014

For my game theory course I needed to typeset extensive-form games in LaTeX documents. One way of doing this to use the egameps package written by Martin Osborne. Osborne is the author of two excellent game theory texts, and he has shown the same care in this package which has a very pleasing syntax and produces quite nice output. This package is based on the pstricks package which means that it will not work with pdfTeX. You need to compile to DVI, then to Postscript and then to PDF which is cumbersome, though some LaTeX environment do provide a shortcut for this pipeline.

A newer way of producing drawings in LaTeX is the PGF/TikZ packages which support pdfTeX. TikZ also has lot of built in support for drawing trees which means that unlike egameps one does not have to calculate coordinates for the nodes manually. To typeset a game tree we use node to define the game nodes, child to describe their hierarchical relationship and edge from parent to style and label the edges. The details are in Chapters 1–3 and 16 of the PGF/TikZ manual.

A Minimal Example

Suppose you want to typeset this tree

Example

The LaTeX code would be

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
 \begin{figure}
 	\begin{center}
    \small
    \begin{tikzpicture}[thin,
      level 1/.style={sibling distance=40mm},
      level 2/.style={sibling distance=25mm},
      level 3/.style={sibling distance=15mm},
      every circle node/.style={minimum size=1.5mm,inner sep=0mm}]
      
      \node[circle,draw,label=above:$1$] (root) {}
        child { node [circle,fill,label=above:$2$] {}
          child { 
            node {$3,2$}
            edge from parent
              node[left] {$D$}}
          child { 
            node {$6,4$}
            edge from parent
              node[right] {$C$}}
          edge from parent
            node[left] {$Z$}}
        child { node [circle,fill,label=above:$2$] {}
          child { 
            node[circle,fill] (node-A) {}
              child {
                node {$3,0$}
                edge from parent
                  node[left] {$X$}}
              child {
                 node {$8,5$}
                 edge from parent
                   node[right] {$Y$}}
              edge from parent
                node[left] {$A$}}
          child { 
            node[circle,fill] (node-B) {}
              child {
                node {$4,6$}
                edge from parent
                  node[left] {$X$}}
              child {
                 node {$2,1$}
                 edge from parent
                   node[right] {$Y$}}
              edge from parent
                node[right] {$B$}}
           edge from parent
             node[right] {$W$}};
      \draw [dashed] (node-A) -- (node-B) 
         node[midway,above] {$1$};
    \end{tikzpicture}
    \end{center}
    \caption{Example: Extensive-form games in TikZ}
  \end{figure}
\end{document}