🤝 Public Goods Game & Cooperation

N players each decide how much to contribute to a public good. Multiplier r distributes total back equally. Nash equilibrium: contribute 0. With punishment, cooperation emerges.

Game MathInteractive
Purple = contributions per round · Green line = avg payoff · Dashed = Nash payoff

How it Works

In the public goods game, each of N players receives an endowment E and privately chooses contribution c_i ∈ [0, E]. Total contributions are multiplied by r and divided equally: each player receives r·ΣC/N regardless of own contribution.

The payoff for player i is: π_i = (E − c_i) + r·ΣC/N. The dominant strategy is c_i = 0 (free-ride), yielding Nash equilibrium payoff = E. But if all cooperate fully (c = E), each gets r·E — which exceeds E when r > 1. The social optimum requires r > 1 but individual rationality pulls toward 0.

Payoff: π_i = (E − c_i) + r · Σ_j c_j / N Nash equilibrium: c_i* = 0 for all i (when r < N) Nash payoff: π_NE = E Social optimum: c_i = E, π_SO = r·E Price of anarchy: r·E / E = r With punishment (cost γ to reduce free-rider by δ): Punisher payoff: π_i − γ Free-rider payoff: π_j − δ·(# punishers) Cooperation is stable when δ/γ > (N-1)

In the evolutionary mode, strategies update each round: players with above-average payoff are imitated. With punishment, cooperators can sustain cooperation indefinitely by deterring free-riders.

Frequently Asked Questions

What is the public goods game?

The public goods game involves N players who each receive an endowment and privately decide how much to contribute to a common pool. Total contributions are multiplied by r and divided equally. When 1 < r < N, the Nash equilibrium is to contribute nothing (free-ride), yet full cooperation maximizes total welfare.

What is a free rider?

A free rider contributes nothing to the public good but receives an equal share of the multiplied pool. Since individual benefit from contributing is r/N, when r < N contributing is individually irrational. Free-riding is the dominant strategy in the standard public goods game.

Why does cooperation emerge with punishment?

Costly punishment allows cooperators to penalize free-riders, making defection unprofitable. Even though punishment is costly for the punisher, it sustains cooperation in iterated games. This mechanism explains real-world institutions and social norms that enforce contribution.

What is the Nash equilibrium of the public goods game?

When the multiplier r < N, the unique Nash equilibrium is for every player to contribute zero. Each player's dominant strategy is to free-ride, regardless of what others do.

What happens when the multiplier r exceeds the number of players?

When r > N, contributing the full endowment becomes the dominant strategy. This is no longer a social dilemma — cooperation is individually rational because every unit contributed returns more than one unit to the contributor.

How does evolutionary game theory explain cooperation?

In evolutionary models, strategies replicate proportional to their fitness (payoff). Cooperators thrive when clustered, when reputation effects matter, or when punishment mechanisms co-evolve. These dynamics can sustain cooperation despite free-rider temptation.

What is the social optimum in the public goods game?

The social optimum is for all players to contribute their full endowment when r > 1. Total welfare equals N × endowment × r. The gap between Nash equilibrium and social optimum payoffs measures the cost of the free-rider problem.

What real examples follow public goods logic?

Climate change (countries reducing emissions), tax compliance, open-source software, fisheries (limiting catch), vaccination, and neighborhood cleanliness all share public goods structure: individual cost, collective benefit, temptation to free-ride.

What is altruistic punishment?

Altruistic punishment is paying a personal cost to punish free-riders even in one-shot anonymous interactions. Experiments show humans punish defectors at personal cost, sustaining cooperation — behavior hard to explain by pure self-interest models.

How does group size affect cooperation?

Larger groups make monitoring harder and reduce individual impact. With N players, contributing gives r/N per unit. As N grows this falls further below 1, strengthening the free-rider incentive. Smaller groups generally sustain higher cooperation.

About this simulation

This simulation runs N players through repeated rounds of the classic public goods game: each contributes some of their endowment E to a shared pot, the total is multiplied by r and split equally regardless of who paid in, and you can switch between all-rational free-riding, mixed cooperation, full cooperation, costly punishment, and evolutionary imitation to see which strategy modes actually sustain contributions over time.

🔬 What it shows

Purple bars tracking average contribution per round, a green line for average payoff, a dashed cooperator-percentage line, plus red and purple reference lines marking the Nash-equilibrium payoff (E) and the social-optimum payoff (r·E).

🎮 How to use

Set player count N, multiplier r, endowment E, and number of rounds with the sliders, choose a strategy mode from the dropdown, then click Run Simulation to animate round-by-round play, or Reset to reinitialise the population.

💡 Did you know?

In "Punishment Enabled" mode, punishers deliberately take a personal cost (−0.3 payoff) just to inflict a larger cost (−1.0) on free-riders — this exact asymmetry is what experimental economists call altruistic punishment, and it is one of the few mechanisms that reliably drags real human groups away from the Nash equilibrium of contributing nothing.

Frequently asked questions

Why does the average contribution bar sink toward zero in "All Rational" mode?

With the default multiplier r below the player count N, each unit contributed only returns r/N to the contributor — less than the unit they gave up — so the payoff-maximising choice for every rational player is to contribute nothing, and the simulation's Nash equilibrium reference line at E confirms that this free-riding outcome is exactly what standard theory predicts.

Why does raising the multiplier r change so much?

r directly scales how much the shared pot pays back per unit contributed; once r exceeds N, contributing your whole endowment starts paying back more than you put in individually, flipping the dominant strategy from free-riding to full cooperation, which you can watch the social-optimum reference line (r·E) climb to confirm.

How does the Punishment mode actually raise contributions over rounds?

Each round, self-identified punishers dock payoff from every non-cooperator they see; once a free-rider's payoff falls far enough below the endowment, the simulation flips them into a cooperator for the next round — a simple mechanical stand-in for how real costly-punishment experiments push initially selfish groups toward sustained cooperation.

What does the Evolutionary mode simulate that the others don't?

Instead of fixed strategies, each player randomly observes another player each round and copies their contribution level if that player earned more — a basic replicator-dynamics rule, so the cooperator percentage line drifts based purely on relative payoffs rather than a scripted behaviour rule.

Why do smaller player counts N tend to sustain higher contributions?

Individual return from contributing scales as r/N, so the same multiplier r gives each contributor a bigger personal payback in a small group than in a large one — this is exactly why the simulation shows cooperation eroding faster as you drag the Players slider higher, matching real-world observations that large anonymous groups free-ride more than small ones.