<p>Mathematica has a graph building and drawing capability.</p>

<p>So, if you built the graph in Mathematica, then you could plot it using settings of your choosing.</p>

<p>In Mathematica, you might use the TreeGraph as way to build the graph, and <a href="http://reference.wolfram.com/language/ref/TreePlot.html">TreePlot</a> as a way to plot it. For example, the following code generates a tree with the nodes labeled by coordinate and has a similar format to what you want:</p>

<pre><code>TreePlot[{1 -&gt; 4, 1 -&gt; 1, 1 -&gt; 5, 2 -&gt; 4, 3 -&gt; 6, 3 -&gt; 9, 4 -&gt; 8, 
  4 -&gt; 10, 6 -&gt; 7, 8 -&gt; 9}, 
 EdgeRenderingFunction -&gt; ({If[First[#2] === Last[#2], Red, Black], 
     Arrow[#1, .1], 
     Text[#2, LineScaledCoordinate[#1, .5], Background -&gt; White]} &amp;), 
 VertexLabeling -&gt; True]
</code></pre>

<p><a href="https://i.sstatic.net/39tLom.png"><img src="https://i.sstatic.net/39tLom.png" alt="enter image description here"></a></p>

<p>Also, note that there are graphical packages like TikZ in Tex which have very powerful graph drawing capability. TikZ is mostly used in unix environments, though, and will not store data structures or do calculations like Mathematica. It is purely a graphical drawing capability.</p>

<p>The graph you have used as an illustration has the font typically used in TeX, so it was probably produced with TikZ or another TeX package. If you want a Mathematica equation to look like that you can use the TraditionalForm function, or explicitly specify the Computer Modern font.</p>

CC BY-SA 3.0
2017-02-06T12:17:06.067Z
2017-02-06T12:34:04.373Z
2017-02-06T12:34:04.373Z
Lassie Fair
<p>If you use LaTeX, you can also draw game trees with the <a href="https://ctan.org/pkg/istgame" rel="nofollow noreferrer"><code>istgame</code></a> package, which is based on TikZ.</p>

<p>The manual contains lots of examples with full codes including:</p>

<ul>
<li>game trees in any direction: downwards, upwards, eastwards, -45 degree, etc.</li>
<li>labelling players, action labels, and payoffs</li>
<li>decision nodes, chance nodes, terminal nodes</li>
<li>various information sets</li>
<li>various arrows on branches (backward induction)</li>
<li>various continua of actions</li>
<li>subgames</li>
<li>signaling games</li>
</ul>

<p>With the <code>istgame</code> package, you can draw game trees like you draw them by hand.</p>

<p><a href="https://i.sstatic.net/HtSGK.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HtSGK.jpg" alt="enter image description here"></a></p>

<pre><code>\documentclass{standalone}

\usepackage{istgame}

\begin{document}

<span class="math-container">\begin{istgame}
\xtdistance{15mm}{40mm}
\istroot(0){1}
  \istb{a_1}[al]
  \istb{a_2}[ar]
  \endist
\xtdistance{15mm}{20mm}
\istroot(1)(0-1){2}
  \istb{b_1}[al]{5,5}
  \istb{b_2}[ar]{1,5}
  \endist
\istroot(1)(0-2){2}
  \istb{b_3}[al]{3,6}
  \istb{b_4}[ar]{2,2}
  \endist
\end{istgame}</span>

\end{document}
</code></pre>

CC BY-SA 4.0
2019-11-29T07:59:33.587Z
2019-11-29T08:24:38.050Z
2019-11-29T08:24:38.050Z
InSung Cho
<h2>Just for your convenience</h2>

<p>If you are interested in the <code>istgame</code> package, you can do like this (to draw Amit's examples):</p>

<p>For the centipede game:</p>

<p><a href="https://i.sstatic.net/hBuI3.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hBuI3.jpg" alt="enter image description here"></a></p>

<pre><code>\documentclass{standalone}

\usepackage{istgame}

\begin{document}

<span class="math-container">\begin{istgame}
%% for arrows (optional)
\xtShowArrows
\xtShowEndPoints[ellipse node]
\xtHideTerminalNodes
%% some more optional settings
\setistEllipseNodeStyle{15pt}[blue!20] % node style
\setistmathTF*001&lt;textbf&gt;{textsc}      % input mode changer
\setistgrowdirection{-45}              % direction
%% tree
\xtdistance{10mm}{20mm}
\istrooto(1){1}
  \istbt{Out}[l]{(1,0)}[b] \istb{In}[a]            \endist
\istrooto(2)(1-2){2}
  \istbt{Out}[l]{(0,2)}[b] \istb{In}[a]            \endist
\istrooto(3)(2-2){1}
  \istbt{Out}[l]{(3,1)}[b] \istb{In}[a]            \endist
\istrooto(4)(3-2){2}
  \istbt{Out}[l]{(2,4)}[b] \istb{In}[a]            \endist
\istrooto(5)(4-2){1}
  \istbt{Out}[l]{(5,3)}[b] \istb{In}[a]            \endist
\istrooto(6)(5-2){2}
  \istbt{Out}[l]{(4,6)}[b] \istbt{In}[a]{(7,5)}[r] \endist
\end{istgame}</span>

\end{document}
</code></pre>

<p>The tree structure itself is simple to draw.</p>

<p><a href="https://i.sstatic.net/dhJAd.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dhJAd.jpg" alt="enter image description here"></a></p>

<pre><code>\documentclass{standalone}

\usepackage{istgame}

\begin{document}

<span class="math-container">\begin{istgame}[font=\scriptsize]
\setistmathTF*001{textsc}  % input mode changer
\setistgrowdirection{-45}  % direction
%% tree
\xtdistance{10mm}{20mm}
\istroot(1){1}
  \istb{Out}[l]{(1,0)}[b] \istb{In}[a]           \endist
\istroot(2)(1-2){2}
  \istb{Out}[l]{(0,2)}[b] \istb{In}[a]           \endist
\istroot(3)(2-2){1}
  \istb{Out}[l]{(3,1)}[b] \istb{In}[a]           \endist
\istroot(4)(3-2){2}
  \istb{Out}[l]{(2,4)}[b] \istb{In}[a]           \endist
\istroot(5)(4-2){1}
  \istb{Out}[l]{(5,3)}[b] \istb{In}[a]           \endist
\istroot(6)(5-2){2}
  \istb{Out}[l]{(4,6)}[b] \istb{In}[a]{(7,5)}[r] \endist
\end{istgame}</span>

\end{document}
</code></pre>

<hr>

<hr>

<p>For the another example:</p>

<p><a href="https://i.sstatic.net/7N3dS.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7N3dS.jpg" alt="enter image description here"></a></p>

<pre><code>\documentclass{standalone}

\usepackage{istgame}

\begin{document}

<span class="math-container">\begin{istgame}[font=\scriptsize]
%% for arrows (optional)
\xtShowArrows
\xtShowEndPoints[ellipse node]
\xtHideTerminalNodes
%% some more optional settings
\setistEllipseNodeStyle{15pt}[blue!20] % node style
\setistmathTF*001&lt;textbf&gt;{textsc} % input mode changer
%% tree
\xtdistance{15mm}{30mm}
\istrooto(1){1}
  \istbt{Not Play}[al]{(1,1)}
  \istb{Play}[ar]
  \endist
\istrooto(2)(1-2){2}
  \istb{Trust}[al]
  \istbt{Distrust}[ar]{(0,2)}
  \endist
\istrooto(3)(2-1){1}
  \istbt{Steal}[al]{(10,10)}
  \istbt{Share}[ar]{(5,5)}
  \endist
\end{istgame}</span>

\end{document}
</code></pre>

<p>Again, the tree structure is simple to draw.</p>

<p><a href="https://i.sstatic.net/Mc7mu.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Mc7mu.jpg" alt="enter image description here"></a></p>

<pre><code>\documentclass{standalone}

\usepackage{istgame}

\begin{document}

<span class="math-container">\begin{istgame}[font=\scriptsize]
\setistmathTF*001{textsc}        % input mode changer
%% tree
\xtdistance{15mm}{30mm}
\istroot(1){1}
  \istb{Not Play}[al]{(1,1)}
  \istb{Play}[ar]
  \endist
\istroot(2)(1-2){2}
  \istb{Trust}[al]
  \istb{Distrust}[ar]{(0,2)}
  \endist
\istroot(3)(2-1){1}
  \istb{Steal}[al]{(10,10)}
  \istb{Share}[ar]{(5,5)}
  \endist
\end{istgame}</span>

\end{document}
</code></pre>

<p>(ADDED) If you want the tree to be <strong>eastward</strong>:</p>

<p><a href="https://i.sstatic.net/WLw3B.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WLw3B.jpg" alt="enter image description here"></a></p>

<pre><code>\documentclass{standalone}

\usepackage{istgame}

\begin{document}

<span class="math-container">\begin{istgame}[font=\scriptsize]
\setistmathTF*001{textsc}        % input mode changer
\setistgrowdirection'{east}      % direction
%% tree
\xtdistance{15mm}{30mm}
\istroot(1)&lt;180&gt;{1}
  \istb{Not Play}[al]{(1,1)}
  \istb{Play}[bl]
  \endist
\istroot(2)(1-2)&lt;180&gt;{2}
  \istb{Trust}[al]
  \istb{Distrust}[bl]{(0,2)}
  \endist
\istroot(3)(2-1)&lt;180&gt;{1}
  \istb{Steal}[al]{(10,10)}
  \istb{Share}[bl]{(5,5)}
  \endist
\end{istgame}</span>

\end{document}
</code></pre>

CC BY-SA 4.0
2019-11-30T14:00:33.963Z
2019-12-01T04:07:44.217Z
2019-12-01T04:07:44.217Z
InSung Cho
<p><a href="https://i.sstatic.net/JdIjp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JdIjp.png" alt="enter image description here"></a></p>

<p>I have used LaTeX with tikz package. The following code is used to generate this Centepede Game :</p>

<pre><code>\documentclass{article}

\usepackage{tikz}
\usepackage{bodegraph}
\usepackage[printwatermark]{xwatermark}


\begin{document}


\begin{tikzpicture}[-&gt;,&gt;=stealth',shorten &gt;=1pt,auto,node distance=1.3cm,
  thick,main node/.style={circle,fill=blue!20,draw,font=\sffamily\normalsize\bfseries}]

  \node[main node] (1) {1};
  \node[main node] (2) [right of=1] {2};
  \node[main node] (3) [right of=2] {1};
  \node[main node] (4) [right of=3] {2};
  \node[main node] (5) [right of=4] {1};
  \node[main node] (6) [right of=5] {2};
    \node (7) [below of=1] {<span class="math-container">$(1,0)$</span>};
       \node (8) [below of=2] {(0,2)};
    \node (9) [below of=3] {<span class="math-container">$(3,1)$</span>};
    \node (10) [below of=4] {<span class="math-container">$(2,4)$</span>};
  \node (11) [below of=5] {<span class="math-container">$(5,3)$</span>};
    \node (12) [below of=6] {<span class="math-container">$(4,6)$</span>};
      \node (13) [right of=6] {<span class="math-container">$(7,5)$</span>};
       \path[every node/.style={font=\sffamily\small\scshape}]
   (1) edge node [above] {In} (2)
   edge node [left] {Out} (7)
        (2) edge node [above] {In} (3)
   edge node [left] {Out} (8)
      (3) edge node [above] {In} (4)
   edge node [left] {Out} (9)
      (4) edge node [above] {In} (5)
   edge node [left] {Out} (10)
      (5) edge node [above] {In} (6)
   edge node [left] {Out} (11)
      (6) edge node [above] {In} (13)
   edge node [left] {Out} (12);
\end{tikzpicture} 
\end{document}
</code></pre>

<p>Here is another example:</p>

<p><a href="https://i.sstatic.net/dLx95.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dLx95.png" alt="enter image description here"></a></p>

<p>Code for the above game is :</p>

<pre><code>\documentclass{article}

\usepackage{tikz}
\usepackage{bodegraph}
\usepackage[printwatermark]{xwatermark}


\begin{document}
\begin{tikzpicture}[-&gt;,&gt;=stealth',shorten &gt;=1pt,auto,node distance=3cm,
  thick,main node/.style={circle,fill=blue!20,draw,font=\sffamily\Large\bfseries}]

  \node[main node] (1) {1};
  \node[main node] (2) [below right of=1] {2};
  \node[main node] (3) [below left of=2] {1};
  \node (4) [below left of=1] {<span class="math-container">$(1,1)$</span>};
   \node (5) [below right of=2] {(0,2)};
    \node (6) [below left of=3] {<span class="math-container">$(10,0)$</span>};
    \node (7) [below right of=3] {<span class="math-container">$(5,5)$</span>};

 \path[every node/.style={font=\sffamily\small\scshape}]
   (1) edge node [right] {Play} (2)
   edge node [left] {Not Play} (4)
      (2) edge node [right] {Distrust} (5)
   edge node [left] {Trust} (3)
      (3) edge node [left] {Steal} (6)
   edge node [right] {Share} (7);
\end{tikzpicture}
\end{document}
</code></pre>

CC BY-SA 4.0
2019-11-30T07:41:50.343Z
2019-11-30T07:52:58.490Z
2019-11-30T07:52:58.490Z
Amit
<h1>LaTeX with <code>forest</code></h1>

<p>The <a href="http://muug.ca/mirror/ctan/graphics/pgf/contrib/forest/forest-doc.pdf" rel="noreferrer"><code>forest</code></a> package of LaTeX allows you to draw game trees with pretty simple syntax. After copying a pre-set template into the LaTeX preamble, one can build up the game tree using a nested <code>[]</code> syntax, then the program takes care of node placement/spacing/etc. </p>

<ul>
<li>pros: customizability (you can annotate the game tree in any way you want) and font/style consistency </li>
<li>cons: inputting the game tree elements (player/action names, payoffs, info sets) is still somewhat manual, especially if the tree is large; and a somewhat steep learning curve if you're not already familiar with the TikZ package </li>
</ul>

<p>Here's an example from the <code>forest</code> manual ("Decision tree" in Section 5.1): </p>

<pre><code>\begin{forest} 
decision tree
[N,plain content
  [I;{p_1=0.5},plain content,elo={yshift=4pt}
    [{5,1};a]
    [II;b,plain content
      [{1,2};m]
      [{2,3};n]
    ]
  ]
  [II;{p_2=0.5},plain content,elo={yshift=4pt}
    [;c
      [{1,0};z]
      [{2,2};t]
    ]
    [;d
      [{3,1};z]
      [{0,0};t]
    ]
  ]{\draw[dashed](!1.anchor)--(!2.anchor) node[pos=0.5,above]{I};}
]
\end{forest}
</code></pre>

<p><a href="https://i.sstatic.net/IDozq.png" rel="noreferrer"><img src="https://i.sstatic.net/IDozq.png" alt="enter image description here"></a></p>

<h1>Game Theory Explorer</h1>

<p>The <a href="http://gte.csc.liv.ac.uk/index/" rel="noreferrer">game theory explorer</a> is developed by a few people at LSE. It allows users to input matrix-form games or build extensive form games through a GUI. It also seems capable of converting between normal and extensive form games. Additionally, the software comes with a solver that looks for Nash equilibria of the inputted game. </p>

<ul>
<li>pros: GUI; solver; no need for local installation; (limited) customizability</li>
<li>cons: no support for annotation; font/style inconsistency with rest of document</li>
</ul>

<p>Screenshots: 
<a href="https://i.sstatic.net/odWI7.png" rel="noreferrer"><img src="https://i.sstatic.net/odWI7.png" alt="enter image description here"></a></p>

<p><a href="https://i.sstatic.net/x3yRV.png" rel="noreferrer"><img src="https://i.sstatic.net/x3yRV.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2021-04-23T03:30:26.300Z
Thank you very much for the loaded response! Just tried the game theory explorer. They migrated to: http://www.gametheoryexplorer.org/ with wonderful and brief tutorials on youtube. Amazing!
Leshui
CC BY-SA 3.0
2017-02-06T19:57:45.677Z
2017-02-06T19:57:45.677Z
Herr K.
<p>There are many ways to draw a sequential game 'by hand'. By drawing the game I mean this:</p>

<p><a href="https://i.sstatic.net/Tuwxk.png" rel="noreferrer"><img src="https://i.sstatic.net/Tuwxk.png" alt="enter image description here"></a></p>

<p>Displaying players' decision points, available actions and payoffs.</p>

<p>Is there any way I can do this in R or a similar high level programming language? To be precise: I do not want to plot geometric equations, I want to define a structure (players, points, connections, payoffs) and have the program plot it.</p>

<p>I am currently browsing the 'igraph' package but I am having some difficulty labeling so I am wondering if there is a better way.</p>

CC BY-SA 3.0
2017-02-06T18:26:05.830Z
If you consider LaTeX to be a "similar high level programming language", you might find the answers to [this question on TeX.SE](http://tex.stackexchange.com/questions/113315/what-is-a-more-efficient-way-to-draw-this-tree) (and other related questions there) useful.
Ilmari Karonen
<game-theory><software>
Visualization tools for game theory: Decision trees
Giskard
# Visualization tools for game theory: Decision trees

(Asked by: username_0 on 2017-02-06)

There are many ways to draw a sequential game 'by hand'. By drawing the game I mean this:

[![enter image description here](https://i.sstatic.net/Tuwxk.png)](https://i.sstatic.net/Tuwxk.png)

Displaying players' decision points, available actions and payoffs.

Is there any way I can do this in R or a similar high level programming language? To be precise: I do not want to plot geometric equations, I want to define a structure (players, points, connections, payoffs) and have the program plot it.

I am currently browsing the 'igraph' package but I am having some difficulty labeling so I am wondering if there is a better way.

**Tags:** game-theory, software

> **Comments:**
> **username_1**: If you consider LaTeX to be a "similar high level programming language", you might find the answers to [this question on TeX.SE](http://tex.stackexchange.com/questions/113315/what-is-a-more-efficient-way-to-draw-this-tree) (and other related questions there) useful.  

---

## 5 answers

### Answer by username_5 on 2017-02-06. Score: 12 | Accepted answer

# LaTeX with `forest`

The [`forest`](http://muug.ca/mirror/ctan/graphics/pgf/contrib/forest/forest-doc.pdf) package of LaTeX allows you to draw game trees with pretty simple syntax. After copying a pre-set template into the LaTeX preamble, one can build up the game tree using a nested `[]` syntax, then the program takes care of node placement/spacing/etc.

* pros: customizability (you can annotate the game tree in any way you want) and font/style consistency
* cons: inputting the game tree elements (player/action names, payoffs, info sets) is still somewhat manual, especially if the tree is large; and a somewhat steep learning curve if you're not already familiar with the TikZ package

Here's an example from the `forest` manual ("Decision tree" in Section 5.1):

```
\begin{forest} 
decision tree
[N,plain content
  [I;{p_1=0.5},plain content,elo={yshift=4pt}
    [{5,1};a]
    [II;b,plain content
      [{1,2};m]
      [{2,3};n]
    ]
  ]
  [II;{p_2=0.5},plain content,elo={yshift=4pt}
    [;c
      [{1,0};z]
      [{2,2};t]
    ]
    [;d
      [{3,1};z]
      [{0,0};t]
    ]
  ]{\draw[dashed](!1.anchor)--(!2.anchor) node[pos=0.5,above]{I};}
]
\end{forest}

```

[![enter image description here](https://i.sstatic.net/IDozq.png)](https://i.sstatic.net/IDozq.png)

# Game Theory Explorer

The [game theory explorer](http://gte.csc.liv.ac.uk/index/) is developed by a few people at LSE. It allows users to input matrix-form games or build extensive form games through a GUI. It also seems capable of converting between normal and extensive form games. Additionally, the software comes with a solver that looks for Nash equilibria of the inputted game.

* pros: GUI; solver; no need for local installation; (limited) customizability
* cons: no support for annotation; font/style inconsistency with rest of document

Screenshots:
[![enter image description here](https://i.sstatic.net/odWI7.png)](https://i.sstatic.net/odWI7.png)

[![enter image description here](https://i.sstatic.net/x3yRV.png)](https://i.sstatic.net/x3yRV.png)

> **Comments:**
> **username_6**: Thank you very much for the loaded response! Just tried the game theory explorer. They migrated to: http://www.gametheoryexplorer.org/ with wonderful and brief tutorials on youtube. Amazing!  

---

### Answer by username_2 on 2017-02-06. Score: 7

Mathematica has a graph building and drawing capability.

So, if you built the graph in Mathematica, then you could plot it using settings of your choosing.

In Mathematica, you might use the TreeGraph as way to build the graph, and [TreePlot](http://reference.wolfram.com/language/ref/TreePlot.html) as a way to plot it. For example, the following code generates a tree with the nodes labeled by coordinate and has a similar format to what you want:

```
TreePlot[{1 -> 4, 1 -> 1, 1 -> 5, 2 -> 4, 3 -> 6, 3 -> 9, 4 -> 8, 
  4 -> 10, 6 -> 7, 8 -> 9}, 
 EdgeRenderingFunction -> ({If[First[#2] === Last[#2], Red, Black], 
     Arrow[#1, .1], 
     Text[#2, LineScaledCoordinate[#1, .5], Background -> White]} &), 
 VertexLabeling -> True]

```

[![enter image description here](https://i.sstatic.net/39tLom.png)](https://i.sstatic.net/39tLom.png)

Also, note that there are graphical packages like TikZ in Tex which have very powerful graph drawing capability. TikZ is mostly used in unix environments, though, and will not store data structures or do calculations like Mathematica. It is purely a graphical drawing capability.

The graph you have used as an illustration has the font typically used in TeX, so it was probably produced with TikZ or another TeX package. If you want a Mathematica equation to look like that you can use the TraditionalForm function, or explicitly specify the Computer Modern font.


---

### Answer by username_3 on 2019-11-29. Score: 4

If you use LaTeX, you can also draw game trees with the [`istgame`](https://ctan.org/pkg/istgame) package, which is based on TikZ.

The manual contains lots of examples with full codes including:

* game trees in any direction: downwards, upwards, eastwards, -45 degree, etc.
* labelling players, action labels, and payoffs
* decision nodes, chance nodes, terminal nodes
* various information sets
* various arrows on branches (backward induction)
* various continua of actions
* subgames
* signaling games

With the `istgame` package, you can draw game trees like you draw them by hand.

[![enter image description here](https://i.sstatic.net/HtSGK.jpg)](https://i.sstatic.net/HtSGK.jpg)

```
\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}
\xtdistance{15mm}{40mm}
\istroot(0){1}
  \istb{a_1}[al]
  \istb{a_2}[ar]
  \endist
\xtdistance{15mm}{20mm}
\istroot(1)(0-1){2}
  \istb{b_1}[al]{5,5}
  \istb{b_2}[ar]{1,5}
  \endist
\istroot(1)(0-2){2}
  \istb{b_3}[al]{3,6}
  \istb{b_4}[ar]{2,2}
  \endist
\end{istgame}

\end{document}

```


---

### Answer by username_3 on 2019-11-30. Score: 2

## Just for your convenience

If you are interested in the `istgame` package, you can do like this (to draw username_4's examples):

For the centipede game:

[![enter image description here](https://i.sstatic.net/hBuI3.jpg)](https://i.sstatic.net/hBuI3.jpg)

```
\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}
%% for arrows (optional)
\xtShowArrows
\xtShowEndPoints[ellipse node]
\xtHideTerminalNodes
%% some more optional settings
\setistEllipseNodeStyle{15pt}[blue!20] % node style
\setistmathTF*001<textbf>{textsc}      % input mode changer
\setistgrowdirection{-45}              % direction
%% tree
\xtdistance{10mm}{20mm}
\istrooto(1){1}
  \istbt{Out}[l]{(1,0)}[b] \istb{In}[a]            \endist
\istrooto(2)(1-2){2}
  \istbt{Out}[l]{(0,2)}[b] \istb{In}[a]            \endist
\istrooto(3)(2-2){1}
  \istbt{Out}[l]{(3,1)}[b] \istb{In}[a]            \endist
\istrooto(4)(3-2){2}
  \istbt{Out}[l]{(2,4)}[b] \istb{In}[a]            \endist
\istrooto(5)(4-2){1}
  \istbt{Out}[l]{(5,3)}[b] \istb{In}[a]            \endist
\istrooto(6)(5-2){2}
  \istbt{Out}[l]{(4,6)}[b] \istbt{In}[a]{(7,5)}[r] \endist
\end{istgame}

\end{document}

```

The tree structure itself is simple to draw.

[![enter image description here](https://i.sstatic.net/dhJAd.jpg)](https://i.sstatic.net/dhJAd.jpg)

```
\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}[font=\scriptsize]
\setistmathTF*001{textsc}  % input mode changer
\setistgrowdirection{-45}  % direction
%% tree
\xtdistance{10mm}{20mm}
\istroot(1){1}
  \istb{Out}[l]{(1,0)}[b] \istb{In}[a]           \endist
\istroot(2)(1-2){2}
  \istb{Out}[l]{(0,2)}[b] \istb{In}[a]           \endist
\istroot(3)(2-2){1}
  \istb{Out}[l]{(3,1)}[b] \istb{In}[a]           \endist
\istroot(4)(3-2){2}
  \istb{Out}[l]{(2,4)}[b] \istb{In}[a]           \endist
\istroot(5)(4-2){1}
  \istb{Out}[l]{(5,3)}[b] \istb{In}[a]           \endist
\istroot(6)(5-2){2}
  \istb{Out}[l]{(4,6)}[b] \istb{In}[a]{(7,5)}[r] \endist
\end{istgame}

\end{document}

```

---

---

For the another example:

[![enter image description here](https://i.sstatic.net/7N3dS.jpg)](https://i.sstatic.net/7N3dS.jpg)

```
\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}[font=\scriptsize]
%% for arrows (optional)
\xtShowArrows
\xtShowEndPoints[ellipse node]
\xtHideTerminalNodes
%% some more optional settings
\setistEllipseNodeStyle{15pt}[blue!20] % node style
\setistmathTF*001<textbf>{textsc} % input mode changer
%% tree
\xtdistance{15mm}{30mm}
\istrooto(1){1}
  \istbt{Not Play}[al]{(1,1)}
  \istb{Play}[ar]
  \endist
\istrooto(2)(1-2){2}
  \istb{Trust}[al]
  \istbt{Distrust}[ar]{(0,2)}
  \endist
\istrooto(3)(2-1){1}
  \istbt{Steal}[al]{(10,10)}
  \istbt{Share}[ar]{(5,5)}
  \endist
\end{istgame}

\end{document}

```

Again, the tree structure is simple to draw.

[![enter image description here](https://i.sstatic.net/Mc7mu.jpg)](https://i.sstatic.net/Mc7mu.jpg)

```
\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}[font=\scriptsize]
\setistmathTF*001{textsc}        % input mode changer
%% tree
\xtdistance{15mm}{30mm}
\istroot(1){1}
  \istb{Not Play}[al]{(1,1)}
  \istb{Play}[ar]
  \endist
\istroot(2)(1-2){2}
  \istb{Trust}[al]
  \istb{Distrust}[ar]{(0,2)}
  \endist
\istroot(3)(2-1){1}
  \istb{Steal}[al]{(10,10)}
  \istb{Share}[ar]{(5,5)}
  \endist
\end{istgame}

\end{document}

```

(ADDED) If you want the tree to be **eastward**:

[![enter image description here](https://i.sstatic.net/WLw3B.jpg)](https://i.sstatic.net/WLw3B.jpg)

```
\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}[font=\scriptsize]
\setistmathTF*001{textsc}        % input mode changer
\setistgrowdirection'{east}      % direction
%% tree
\xtdistance{15mm}{30mm}
\istroot(1)<180>{1}
  \istb{Not Play}[al]{(1,1)}
  \istb{Play}[bl]
  \endist
\istroot(2)(1-2)<180>{2}
  \istb{Trust}[al]
  \istb{Distrust}[bl]{(0,2)}
  \endist
\istroot(3)(2-1)<180>{1}
  \istb{Steal}[al]{(10,10)}
  \istb{Share}[bl]{(5,5)}
  \endist
\end{istgame}

\end{document}

```


---

### Answer by username_4 on 2019-11-30. Score: 2

[![enter image description here](https://i.sstatic.net/JdIjp.png)](https://i.sstatic.net/JdIjp.png)

I have used LaTeX with tikz package. The following code is used to generate this Centepede Game :

```
\documentclass{article}

\usepackage{tikz}
\usepackage{bodegraph}
\usepackage[printwatermark]{xwatermark}

\begin{document}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.3cm,
  thick,main node/.style={circle,fill=blue!20,draw,font=\sffamily\normalsize\bfseries}]

  \node[main node] (1) {1};
  \node[main node] (2) [right of=1] {2};
  \node[main node] (3) [right of=2] {1};
  \node[main node] (4) [right of=3] {2};
  \node[main node] (5) [right of=4] {1};
  \node[main node] (6) [right of=5] {2};
    \node (7) [below of=1] {$(1,0)$};
       \node (8) [below of=2] {(0,2)};
    \node (9) [below of=3] {$(3,1)$};
    \node (10) [below of=4] {$(2,4)$};
  \node (11) [below of=5] {$(5,3)$};
    \node (12) [below of=6] {$(4,6)$};
      \node (13) [right of=6] {$(7,5)$};
       \path[every node/.style={font=\sffamily\small\scshape}]
   (1) edge node [above] {In} (2)
   edge node [left] {Out} (7)
        (2) edge node [above] {In} (3)
   edge node [left] {Out} (8)
      (3) edge node [above] {In} (4)
   edge node [left] {Out} (9)
      (4) edge node [above] {In} (5)
   edge node [left] {Out} (10)
      (5) edge node [above] {In} (6)
   edge node [left] {Out} (11)
      (6) edge node [above] {In} (13)
   edge node [left] {Out} (12);
\end{tikzpicture} 
\end{document}

```

Here is another example:

[![enter image description here](https://i.sstatic.net/dLx95.png)](https://i.sstatic.net/dLx95.png)

Code for the above game is :

```
\documentclass{article}

\usepackage{tikz}
\usepackage{bodegraph}
\usepackage[printwatermark]{xwatermark}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
  thick,main node/.style={circle,fill=blue!20,draw,font=\sffamily\Large\bfseries}]

  \node[main node] (1) {1};
  \node[main node] (2) [below right of=1] {2};
  \node[main node] (3) [below left of=2] {1};
  \node (4) [below left of=1] {$(1,1)$};
   \node (5) [below right of=2] {(0,2)};
    \node (6) [below left of=3] {$(10,0)$};
    \node (7) [below right of=3] {$(5,5)$};

 \path[every node/.style={font=\sffamily\small\scshape}]
   (1) edge node [right] {Play} (2)
   edge node [left] {Not Play} (4)
      (2) edge node [right] {Distrust} (5)
   edge node [left] {Trust} (3)
      (3) edge node [left] {Steal} (6)
   edge node [right] {Share} (7);
\end{tikzpicture}
\end{document}

```


---

