Open-source JavaScript · in memory of William H. Sandholm

Dynamo.js

Diagrams for evolutionary game dynamics

A faithful, zero-dependency port of William Sandholm's Dynamo Mathematica suite — one engine for the replicator, best-response, logit, BNN, Smith, projection and nine other dynamics, drawn on every shape the original covered: the square, the triangle, the tetrahedron, the prism and the cube. Pick a shape, a game and a dynamic, and watch the population flow.

15 dynamics5 geometries seeded & reproduciblerest points + stability SVG exportzero dependencies

Original Dynamo by William H. Sandholm, Emin Dokumacı & Francisco Franchetti, University of Wisconsin–Madison. Sandholm (1970–2020) released it freely; this port continues that spirit.

The explorer

Every game knows its own shape (its strategy and population counts), so choosing a game fixes the geometry. The dynamics, by contrast, are universal — the same vector field runs on every shape.

Controls

sink source saddle centre

The five shapes

Sandholm's notebooks differ only in geometry — the state always lives on a product of simplices fixed by dims. Dynamo.js treats them uniformly.

dims = [2,2]

Square

Two populations, two strategies each — a bimatrix game on the unit square. (2×2)

dims = [3]

Triangle

One population, three strategies, on the 2-simplex. (3S)

dims = [4]

Tetrahedron

One population, four strategies, on the 3-simplex. (4S)

dims = [3,2]

Prism

Two populations: three strategies versus two — a triangular prism. (3×2)

dims = [2,2,2]

Cube

Three populations, two strategies each — trilinear payoffs on the cube. (2×2×2)

The dynamics

Each is transcribed from Sandholm's notebook and cross-checked against Population Games and Evolutionary Dynamics. F̄ is mean payoff, F̂ = F − F̄ the excess payoff.

Replicatorẋⱼ = xⱼ·F̂ⱼStrategies grow in proportion to how far their payoff beats the mean.
Maynard-Smithẋ = (1/F̄)·replicatorReplicator rescaled by mean payoff (needs positive payoffs).
Best responseLogit[.001]Jump toward the current best reply; the sharp limit of logit.
Logit[η]ẋⱼ = softmax(F/η)ⱼ − xⱼPerturbed best response; η is the noise level.
Imitative logit[η]xⱼ·e^{Fⱼ/η}/Σ − xⱼLogit weighted by current shares.
BNN[F̂ⱼ]₊ − xⱼ·Σ[F̂ₖ]₊Brown–von Neumann–Nash excess-payoff dynamic; rests at Nash equilibria.
SmithΣₖ xₖ[Fⱼ−Fₖ]₊ − xⱼΣₖ[Fₖ−Fⱼ]₊Pairwise comparison: switch from worse to better at a rate set by the gap.
Excess payoffσ̃ⱼ − xⱼ·Σσ̃ₖ, σ̃=([F̂]₊)²BNN's form with a squared revision potential.
ProjectionΠ tangent-cone FProject the payoff onto the simplex tangent cone.
Sample BR[k]E[BR(k samples)] − xExact expected best response to a sample of k opponents.
Selection–mutationMᵀ·diag(x)·F − (x·F)xReplicator with a mutation matrix M.