Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 37 ยท Repeated and Evolutionary Games

Replicator Dynamics

Simulate how strategy shares in a population change over time with the replicator equation. Python examples: Hawk-Dove convergence, rock-paper-scissors cycles, coordination games.

An ESS tells you which populations resist invasion, but not how a population gets there, or what happens when no ESS exists. Replicator dynamics adds time. Take a large population divided into strategy types. A type that earns more than the average grows its share; a type that earns less shrinks. This one idea, written as a differential equation, links evolution, learning and imitation.

The replicator equation

Let x_i be the share of the population playing strategy i, and let f_i be the expected payoff of a type-i individual against the current population, f_i = (A x)_i for payoff matrix A. The average payoff is f_avg = sum of x_i * f_i. The replicator equation says

dx_i/dt = x_i * (f_i - f_avg)

A strategy grows exactly when it does better than average. Shares always sum to one, and a type with a zero share stays at zero (no spontaneous mutation).

Replicator dynamics

Strategy shares x_i, summing to 1
Compare Own payoff against the average
Grow or shrink Better than average means growth
Rest points Where every used type earns the same

Stable rest points are linked to Nash and ESS.

1 / 2

A simulator

We integrate the equation with a classic fourth-order Runge-Kutta method (RK4), implemented in a few lines with numpy.

Python Integrating the replicator equation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Starting from only 10% Hawks, the population drifts toward 2/3 Hawks and stays there. Starting from 99% Hawks you would converge to the same point from the other side. The mixed ESS is a stable rest point of the dynamics.

Four classic games

The replicator behaves differently for different games:

  • Prisoner's dilemma: Defect takes over, even though cooperation would give a better average payoff.
  • Coordination game: Two stable pure states; the starting point decides which one wins.
  • Hawk-Dove: One stable mixed state.
  • Rock-paper-scissors: No stable point; shares cycle.
Python Comparing outcomes in four games

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

In the coordination game, the payoff-dominant convention A wins only if it starts with a large enough share (here, above one third), a hint of how history can lock in a less efficient convention.

Cycles in rock-paper-scissors

For the standard zero-sum rock-paper-scissors matrix, the equilibrium (1/3, 1/3, 1/3) is not attracting. Trajectories orbit around it. In the zero-sum case, the product x1 * x2 * x3 is constant along a trajectory, so shares neither explode nor settle. The program shows the orbit and checks the conserved product.

Python Orbits in rock-paper-scissors

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The orbit is a closed loop: when Rock is common, Paper grows; once Paper is common, Scissors grows; then Rock returns. Many real cycles resemble this, such as lizards with three throat colors or bacteria with three toxin strategies.

Connections to other solution concepts

  • Every Nash equilibrium is a rest point of the dynamics, but not every rest point is Nash: pure-strategy states in which an absent strategy would do better are also rest points (they are unstable).
  • A stable rest point (in the sense of Lyapunov) is a Nash equilibrium.
  • Every ESS is an asymptotically stable rest point.
  • The converse fails in some games, so stability of dynamics and ESS are close but not identical.

The same equation arises from imitation (each player compares their payoff with a random other and adopts the better strategy with probability proportional to the difference) and from certain reinforcement learning rules, which is why evolutionary models also describe learning in economic settings.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In the replicator equation, when does a strategy's population share grow?

    dx_i/dt = x_i (f_i - f_avg), which is positive exactly when f_i exceeds the average.
  2. 2. What does the replicator dynamics do in the prisoner's dilemma?

    Defectors always earn more than cooperators against any mix, so their share rises to 1.
  3. 3. What happens in rock-paper-scissors under replicator dynamics?

    In the zero-sum case the product of the shares is conserved, giving closed orbits.
  4. 4. In the coordination game with payoffs 2 and 1, which statement is true?

    Both all-A and all-B are stable rest points; the interior mixed point is unstable and separates their basins.

Summary

  • Replicator dynamics: dx_i/dt = x_i (f_i - f_avg). Above-average types grow.
  • ESS are asymptotically stable rest points; stable rest points are Nash equilibria.
  • Prisoner's dilemma leads to defection, coordination games to path-dependent conventions, Hawk-Dove to a mixed state, rock-paper-scissors to cycles.
  • Imitation and learning rules lead to the same equation, linking biology and economics.
  • Numerical integration (RK4) is enough to explore these systems.

Next: Auction Formats