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

enter image description here

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.

  • 1
    $\begingroup$ If you consider LaTeX to be a "similar high level programming language", you might find the answers to this question on TeX.SE (and other related questions there) useful. $\endgroup$ – Ilmari Karonen Feb 6 '17 at 18:26

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

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.


LaTeX with forest

The forest 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):

decision tree
[N,plain content
  [I;{p_1=0.5},plain content,elo={yshift=4pt}
    [II;b,plain content
  [II;{p_2=0.5},plain content,elo={yshift=4pt}
  ]{\draw[dashed](!1.anchor)--(!2.anchor) node[pos=0.5,above]{I};}

enter image description here

Game Theory Explorer

The game theory explorer 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

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.