Skip to content

About

Draw extensive-form game trees in the browser

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Game Tree Studio

Draw extensive-form game trees in the browser and export them as images or LaTeX.

Open the editor, nothing to install.

The Game Tree Studio editor with an example game

Game Tree Studio is a single-page editor for the game trees used in game theory: decision nodes, chance moves, information sets, payoffs and continua of actions. It runs entirely in the browser, with no build step, no server and no account. Your games are saved in your browser's local storage.

Features

  • Quick tree building. Double-click a node to add moves, press 1–6 to give it to a player, or N to make it a chance node.
  • Information sets. Shift-click the nodes a player cannot tell apart and press I. They are drawn as a dashed line, a dotted line or an oval, and move labels stay in sync across the set.
  • Chance moves with numeric or symbolic probabilities (1/3, 0.25, \pi, 1-\pi). The editor warns when numeric probabilities don't add up to 1.
  • Payoffs as expressions. s_1-5, -s_1-5 renders as s₁−5, −s₁−5.
  • Continuum of actions. An arc between the extreme choices, one representative move and a range label such as x \in [0, 8].
  • Highlighted moves (thick line with an arrow) to mark a strategy profile or a backward-induction path.
  • Layout control. Top-to-bottom or left-to-right trees, spacing sliders, terminal nodes on one row, drag a node to nudge its subtree, and per-node label positions. Wide payoffs get extra room automatically.
  • Notation options. Payoffs as (3, 1), 3, 1 or stacked; open-circle or square chance nodes; serif or sans-serif text; optional colors by player.
  • Export to PNG (3× resolution), SVG, the clipboard, TikZ, GTDraw .ef files and the editor's own .json format.
  • Undo and redo, copy and paste of subtrees, keyboard navigation, light and dark themes, and a layout that works on phones.

The example game exported as a PNG: Ann moves first, Nature moves after R, and Bob's two nodes after Nature form one information set

Getting started

Open index.html in a recent version of Chrome, Edge, Firefox or Safari. There is nothing to install.

To serve it locally, so it behaves exactly like a hosted copy:

python -m http.server 8000

Then visit http://localhost:8000.

Host it with GitHub Pages

  1. Push this repository to GitHub.
  2. Open Settings › Pages, set Source to Deploy from a branch, and choose main with the / (root) folder.
  3. After a minute the editor is live at https://<your-username>.github.io/<repository-name>/.

Drawing a tree

Action How
Add moves Double-click a node, or select it and press A
Assign a player 1–6, or N for a chance node
Edit a label in place Double-click a move, probability, payoff or player name
Jump to the next label while editing Tab (Shift+Tab goes back)
Edit payoffs of a terminal node Select it and press Enter, then type 3, 5
Select several nodes Shift-click
Join or leave an information set I / U
Highlight the move into a node H
Delete a node and everything after it Delete or Backspace
Copy a subtree, paste it onto a terminal node Ctrl+C, then Ctrl+V
Undo and redo Ctrl+Z, Ctrl+Y
Pan, zoom, fit Drag empty space, Ctrl + scroll, F
Move the selection Arrow keys

A continuum of actions is set per node: select a decision node and tick Draw as a continuum in the side panel.

Math in labels

Move labels, probabilities and payoffs accept a small LaTeX-like markup:

Type Shows
s_1, u_{12} s₁, u₁₂
x^2 x²
\pi, 1-\pi π, 1 − π
\ge, \le, \in ≥, ≤, ∈
\alpha, \theta, \delta α, θ, δ

Minus signs in payoffs and probabilities are typeset as true minus signs. In the TikZ export the same text becomes math mode, and simple fractions such as 1/3 become \tfrac{1}{3}.

Export formats

Format Use it for
PNG Word, Google Docs, slides and course submissions
SVG Vector graphics for the web or for further editing
Copy image Pasting straight into another app
TikZ LaTeX documents. Needs the tikz and amsmath packages. Every element sits at the coordinates shown in the editor.
GTDraw .ef Fine-tuning the typesetting in GTDraw
JSON Saving games as files, sharing them and opening them again (Export › Open game file, or drag the file onto the canvas)

Game file format

A game is a JSON object. See examples/example-game.json.

Field Meaning
players Player names in payoff order, e.g. [{ "name": "Ann" }, { "name": "Bob" }]
chanceName Name shown at chance nodes, e.g. "Nature"
root Id of the root node
nodes Map from node id to node
style Optional display settings (orientation, spacing, notation, font)

Each node has these fields (all optional except parent and children):

Field Meaning
parent, children Tree structure; children is ordered
player 1, 2, … for players, 0 for a chance node, null when unassigned
iset Information set id, shared by all of its nodes
move Label of the move into this node
prob Probability of that move when the parent is a chance node
pay Payoffs at a terminal node, one string per player
hl Highlight the move into this node
cont, range Draw a continuum of moves at this node, with a range label
label Optional node label
dx, dl Manual nudge across the tree (in slots) and extra depth (in levels)
lpos Player name position: auto, left, right, above, below or hide

Project layout

index.html          page markup
assets/app.css      styles; colors are tokens on :root, with dark-mode overrides
assets/app.js       the editor: tree model, layout, rendering, export
assets/favicon.svg  icon
examples/           sample game files
docs/               images used in this README

Storage

Games are kept in localStorage for the address the editor is served from, so a copy on GitHub Pages and a copy opened from disk keep separate libraries. Clearing site data removes them. Use Export › Save game file to keep a copy you can open anywhere.

License

MIT

About

Draw extensive-form game trees in the browser

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages