The Prisoner’s Dilemma
Two people who would both be better off trusting each other, each reasoning perfectly about their own interest, and both ending up worse off for it anyway. The same trap explains arms races, price wars, and why ten sensible farmers can ruin one field.
Before you start. Dominant Strategies & Nash Equilibrium showed you how to read a table of outcomes and pick the one move that beats every other move no matter what the other player does. Here is the table where that move sends both players somewhere worse than if neither had bothered - a shape so common it turns up under a dozen different costumes.
1950: two mathematicians pay two colleagues to play a game
At the RAND Corporation, a Cold War think tank in Santa Monica building the mathematics of nuclear strategy, two researchers named Merrill Flood and Melvin Dresher ran a strange experiment in 1950. They sat two RAND colleagues, the economist Armen Alchian and the mathematician John Williams, in a room and had them play the same simple game against each other a hundred times, for real money each round. Each player picked one of two moves without seeing the other’s pick, and a fixed table of payoffs decided what each earned from the pair.
Flood and Dresher had worked out the one move that always paid off best, and expected the two men to grind toward playing it every round. Instead, Alchian and Williams cooperated far more often than the maths said they should. Repeating the game seemed to change the answer - a gap between theory and real people that took decades to explain properly, and gets its own lesson next.
The name came later that year, from a third RAND mathematician who wasn’t one of the two players. Albert Tucker, a Princeton professor spending his summer consulting for RAND, had to explain Flood and Dresher’s game to a room of psychologists at a colloquium at Stanford. He swapped their abstract payoff numbers for prison sentences and gave two fictional suspects a story to be caught in. The story is what stuck, not the numbers - “the prisoner’s dilemma” is still the name today.
Two rooms, no way to talk, and one move that wins anyway
Two people are arrested together and questioned in separate rooms, unable to hear or signal each other. Each has the same two choices: stay silent, or talk and cut a deal for yourself at the other’s expense. Game theorists call the first move cooperating. They call the second defecting.
The deal: talk while your partner stays silent, and you walk free while they take ten years. Both talk, five years each. Both stay silent, and the police can only prove a minor charge - one year each.
Put those numbers in a grid, one row per your move, one column per your partner’s, and each cell holds a payoff for the pair of moves - read it as “your years, their years”:
PARTNER
Silent Confess
Silent (1, 1) (10, 0)
YOU
Confess (0, 10) (5, 5)
Check both branches by hand, the way the last lesson taught you to. If your partner stays silent, you get 1 year for silence or 0 for talking - talking wins. If your partner talks, you get 10 for silence or 5 for talking - talking wins again. Whatever your partner does, talking is the better pick, and by the same reasoning, it’s the better pick for them too. A move that beats every alternative no matter what the other side does is a dominant strategy, and both suspects have the same one.
The seat that’s worse for both of them, and neither can leave
When both players play their dominant strategy, the table settles on one cell that neither can improve by switching alone: (Confess, Confess), five years each. That settled cell is a Nash equilibrium - the idea the last lesson introduced, now with a face on it.
One cell over sits (Silent, Silent): one year each, better for both of them than the equilibrium they land on. Neither can get there alone, though - from (Silent, Silent), either one can cut their own sentence to zero by talking, so silence only holds if you trust the other person not to take that easy win. The equilibrium isn’t the best deal on the table, just the only one that survives once nobody can trust the other side.
The same shape shows up wherever cooperating is best for everyone but defecting is better for each person individually:
- Arms race - both sides disarming is safe and cheap; each fears the other arming first, so both arm and end up no safer.
- Price war - both firms holding their price keeps margins healthy; each undercuts to win customers; both cut and the margin is gone.
- Overfishing - everyone limiting their catch keeps the fishery alive; each boat catches a bit more anyway, since the fish they don’t take, someone else will.
The same trap, stretched to ten farmers on one field
Scale the two suspects up to many players sharing one resource and the trap gets a second name: the tragedy of the commons, after a 1968 paper by the ecologist Garrett Hardin. Picture one shared pasture and several farmers, each free to graze as many cows as they like. Every extra cow thins the grass a little for every cow already there, but the farmer who adds it keeps the whole benefit while the thinner grass is a cost every farmer shares. So one more cow always looks worth it, even once the field is crowded.
Say each cow earns less the more cows share the grass, so the whole field earns most at forty cows. Now give it ten farmers. A farmer adding a cow keeps all of that cow’s milk, but the thinner grass hurts all ten herds, so they feel only a tenth of the harm. Each keeps adding cows while the extra milk beats their tenth of the loss, and that stops paying only near seventy-three cows, almost double forty. At forty cows each nets forty, so the field makes 1,600. At seventy-three each nets about seven, so the village makes about 530, a third of that.
Read the loop below from the top left: the cost of one more cow lands on everyone, the gain lands on one farmer, and the dotted arrow is the only way out.
flowchart LR H[each herder adds a cow] --> G[grass per cow falls] G --> M[milk per cow falls for everyone] M --> R[my own income dips a little] R --> H G --> P[pasture overgrazed, total value collapses] Q[quota, fee or ownership] -. changes the payoff .-> H
The loop only breaks where something changes the payoff at the moment of adding a cow - a quota, a fee, or making one person own the whole field.
What playing it twice - or two hundred times - changes
Everything above assumes the suspects play once and never meet again. Flood and Dresher’s own experiment hints at the loophole: Alchian and Williams played a hundred rounds against the same opponent, and cooperated far more than the one-shot maths predicted. If you might face the same partner again tomorrow, talking today can cost you their trust for every round after. Whether that threat is enough to make silence pay is a question you can actually measure, round by round - which is the second read below, and Repeated Games & Cooperation next.
You now know
- A payoff table lists what each player gets for every combination of moves; reading it means checking your own best reply to each of the other player’s choices.
- A dominant strategy is a move that beats every alternative no matter what the other player does.
- A Nash equilibrium is an outcome neither player can improve by changing only their own move; when both play a dominant strategy, that is where they land.
- A prisoner’s dilemma is a game where each player’s dominant move leaves both worse off than if both had cooperated, and neither can trust the other enough to cooperate.
- The tragedy of the commons is a prisoner’s dilemma with many players sharing one resource: each gains fully from taking more, the cost is split among all, so all take more and the resource is ruined.
- When the same two players repeat a prisoner’s dilemma many times, cooperating can pay, because betraying today costs you the other player’s cooperation in later rounds.
Stop here if you want. What follows is the same trap in numbers: the two-hundred-round tournament that shows exactly when repetition starts to pay, and the pasture arithmetic behind “a third of the value.”
Second read: the trap, measured
The general shape. Any prisoner’s dilemma ranks its outcomes the same way: Temptation (defect on a cooperator) beats Reward (both cooperate) beats Punishment (both defect) beats Sucker (cooperate against a defector). Years are bad, so score each outcome as minus years (fewer years, higher score): T = 0, R = −1, P = −5, S = −10, and 0 > −1 > −5 > −10 holds. A second condition, 2R > T + S, matters once games repeat: it says taking turns exploiting each other is worse than always cooperating. Here 2R = −2 beats T + S = −10 by a wide margin, which is why alternating betrayals never beats mutual cooperation in the tournament below.
The tournament. Take the same shape in points (T = 5, R = 3, P = 1, S = 0) and let four fixed strategies play 200 rounds against every pair, including a copy of themselves: always-defect (defects every round), always-coop (cooperates every round), tit-for-tat (starts by cooperating, then copies the other side’s last move), and grim (cooperates until a single betrayal, then defects forever).
const PAY = { CC: [3, 3], CD: [0, 5], DC: [5, 0], DD: [1, 1] };
const strategies = {
"tit-for-tat": (mine, theirs) => theirs.length ? theirs[theirs.length - 1] : "C",
"always-defect": () => "D",
"grim": (mine, theirs) => theirs.includes("D") ? "D" : "C",
"always-coop": () => "C",
};
function play(a, b, rounds = 200) {
const ha = [], hb = []; let sa = 0, sb = 0;
for (let i = 0; i < rounds; i++) {
const ma = strategies[a](ha, hb), mb = strategies[b](hb, ha);
const [pa, pb] = PAY[ma + mb]; sa += pa; sb += pb; ha.push(ma); hb.push(mb);
}
return [sa, sb];
}
const names = Object.keys(strategies);
const total = Object.fromEntries(names.map(n => [n, 0]));
console.log("pair".padEnd(30), "A".padStart(5), "B".padStart(5));
for (let i = 0; i < names.length; i++) for (let j = i; j < names.length; j++) {
const [sa, sb] = play(names[i], names[j]);
console.log(`${names[i]} vs ${names[j]}`.padEnd(30), String(sa).padStart(5), String(sb).padStart(5));
total[names[i]] += sa; if (i !== j) total[names[j]] += sb; else total[names[i]] += sb;
}
console.log("\ntournament totals (each plays every strategy incl. itself, 200 rounds):");
for (const n of names.sort((a, b) => total[b] - total[a])) console.log(` ${n.padEnd(15)} ${total[n]}`);
console.log("\nshadow of the future: total over N rounds, TFT vs TFT and AllD vs TFT");
for (const N of [1, 2, 3, 5, 10, 200]) {
const [tt] = play("tit-for-tat", "tit-for-tat", N);
const [ad] = play("always-defect", "tit-for-tat", N);
console.log(` N=${String(N).padStart(3)} TFT earns ${String(tt).padStart(3)} AllD earns ${String(ad).padStart(3)} ${ad > tt ? "defect wins" : ad === tt ? "tie" : "cooperate wins"}`);
}
pair A B
tit-for-tat vs tit-for-tat 600 600
tit-for-tat vs always-defect 199 204
tit-for-tat vs grim 600 600
tit-for-tat vs always-coop 600 600
always-defect vs always-defect 200 200
always-defect vs grim 204 199
always-defect vs always-coop 1000 0
grim vs grim 600 600
grim vs always-coop 600 600
always-coop vs always-coop 600 600
tournament totals (each plays every strategy incl. itself, 200 rounds):
tit-for-tat 2599
grim 2599
always-coop 2400
always-defect 1808
shadow of the future: total over N rounds, TFT vs TFT and AllD vs TFT
N= 1 TFT earns 3 AllD earns 5 defect wins
N= 2 TFT earns 6 AllD earns 6 tie
N= 3 TFT earns 9 AllD earns 7 cooperate wins
N= 5 TFT earns 15 AllD earns 9 cooperate wins
N= 10 TFT earns 30 AllD earns 14 cooperate wins
N=200 TFT earns 600 AllD earns 204 cooperate wins
Three rows carry the result. always-defect never loses a match - 204 to 199 against tit-for-tat and grim, 1000 to 0 against always-coop, exactly what the one-shot analysis predicts - and it still finishes last in the tournament, 1808 against tit-for-tat’s 2599. Both are true because a repeated game scores the total across every match: a strategy that wins each match by a little, while dragging it down to (1, 1), earns less than one that ties everyone at (3, 3).
The 204 to 199 breaks down simply: always-defect wins round one 5 to 0, then meets its own move mirrored back for 199 rounds at 1 point each - 5 + 199 = 204 against 0 + 199 = 199. Tit-for-tat pays for one round of trust and never again.
sequenceDiagram participant T as tit-for-tat participant D as always-defect T->>D: round 1, silent (0 points) D->>T: round 1, confess (5 points) Note over T,D: T copies D from now on T->>D: round 2, confess (1 point) D->>T: round 2, confess (1 point) Note over T,D: rounds 3 to 200 identical, 1 point each Note over T,D: final 199 vs 204, one round of gain, 199 rounds of loss
The “shadow of the future” block plays a shorter game each time and asks which does better against tit-for-tat: being tit-for-tat, or being always-defect. Once, defect wins 5 to 3, the one-shot answer. Twice, it’s a tie. From three rounds on, cooperating pulls ahead and never looks back - 600 to 204 by round 200. That crossover is small: cooperation only needs enough future that the one-round temptation (T − R = 2) is smaller than the punishment that follows (R − P = 2 per round).
Grim and tit-for-tat tie throughout because neither opponent ever defects against them twice; they differ only once a mistake enters, where grim never forgives and tit-for-tat forgives after one round. One honest limit: if both players know the game ends at round 200, the last round is a one-shot game and both defect in it, so round 199 has nothing left to protect either, unravelling all the way back to round 1. Real repeated games rarely have a publicly known last round, which is why the escape holds in practice.
The pasture, in numbers. One pasture, n farmers. Every cow earns its owner 100 − C where C is the total cows on the field (more cows, thinner grass, less milk each), minus 20 to keep it - so a farmer with c cows earns c × (80 − C). Maximising that for one farmer, holding everyone else’s cows fixed, settles at c = 80 / (n + 1) each once every farmer does the same. The village as a whole does best maximising the total C × (80 − C), which peaks at C = 40 cows and 1,600 profit regardless of how many farmers split it.
// n herders on one pasture. Each cow earns (100 - C) - 20 where C = total cows.
// Herder i chooses c_i to maximise c_i * (80 - C).
function nash(n) { const c = 80 / (n + 1); const C = n * c; return { each: c, total: C, profitEach: c * (80 - C), profitAll: C * (80 - C) }; }
const opt = { total: 40, profitAll: 40 * (80 - 40) };
console.log("herders cows/each total cows profit/each profit all social optimum total profit");
for (const n of [1, 2, 5, 10, 100]) {
const r = nash(n);
console.log(String(n).padStart(7), r.each.toFixed(1).padStart(10), r.total.toFixed(1).padStart(11), r.profitEach.toFixed(1).padStart(12), r.profitAll.toFixed(0).padStart(11), String(opt.profitAll).padStart(30), `(${opt.total} cows)`);
}
herders cows/each total cows profit/each profit all social optimum total profit
1 40.0 40.0 1600.0 1600 1600 (40 cows)
2 26.7 53.3 711.1 1422 1600 (40 cows)
5 13.3 66.7 177.8 889 1600 (40 cows)
10 7.3 72.7 52.9 529 1600 (40 cows)
100 0.8 79.2 0.6 63 1600 (40 cows)
One owner grazes 40 cows and takes the full 1,600 - with nobody to pass the cost onto, private and village interest are the same thing. Two farmers already overgraze to 53 cows and lose 11% of the total. Ten put 72.7 cows (call it 73) on a field built for 40 and keep a third of what it could have earned. A hundred graze it to 79 cows, almost the point where a cow earns nothing at all, and the village splits 63 - four percent of the possible 1,600. The waste approaches the entire value of the resource as n grows, because each extra farmer sees only their own cow’s share of the thinning grass, never the whole cost of adding it.
It’s a genuine dilemma, not a misjudgement: at ten farmers, one who cuts back alone to their fair share of the optimum (4 cows), while the other nine keep 7.3 each, earns 4 × (80 − 69.5) ≈ 42 - less than the 52.9 they’d earn grazing along. Restraint alone is the sucker’s payoff. Every real fix changes the payoff itself - a quota, a grazing fee, or property rights that make n = 1 - and none of them is “please graze less.”
Related dilemmas worth naming. The commons is over-use of a shared resource. Its mirror image is the free-rider problem: everyone benefits from a shared good - clean air, an open-source library, the person keeping the on-call rota running - but each would rather someone else pay for it, so it stays under-provided. Both are collective-action problems: a group that can’t reach the outcome it would collectively prefer, though nobody in it is being irrational. The same shape runs inside a team: infrastructure with no rate limits gets hammered by everyone’s retries at once, since no single service feels the whole cost of its own load; skipping tests under a deadline is cheap for you and expensive for whoever touches that code next. Both fix the same way as the pasture - change the payoff, not the person.
Problem set
- Payoffs in points: Temptation 9, Reward 4, Punishment 1, Sucker 0. Is it a prisoner’s dilemma? If the game repeats, do two players do better always cooperating or taking turns exploiting each other?
- Four farmers share the pasture from the second read (each cow earns
80 − C, total cowsC). How many cows each, how many in total, and how much does the village lose against the best total of 1,600? - Four friends each have 10 coins. Whatever they put in a pot is doubled and shared equally among all four. If the other three put in 10 each, what do you end with if you give 0, and if you give 10? What if nobody gives anything?
Answers
- Yes, since 9 > 4 > 1 > 0. But
2R = 8is less thanT + S = 9, so taking turns exploiting each other (9 then 0, averaging 4.5) beats steady cooperation (4). The second condition from the second read is what rules that out in a standard prisoner’s dilemma. 80 / 5 = 16cows each, 64 in total, 256 profit each, 1,024 for the village: it loses 576 of the possible 1,600.- Giving 0 leaves you
10 + 2 × 30 / 4 = 25; giving 10 leaves you0 + 2 × 40 / 4 = 20. Each coin you give returns only half a coin to you, so giving nothing is dominant. If everyone gives 10 each ends with 20; if nobody gives, each keeps 10. A public good is a prisoner’s dilemma with many players.
Try it
Find a prisoner’s dilemma you’re currently inside - cutting a corner everyone else is holding, skipping the tests, grabbing more of a shared resource. Write the 2×2: cooperate/cooperate, defect/defect, one of each. Confirm defecting dominates and mutual cooperation beats it for both of you. Then ask the only question that helps: what would change the payoffs - a visible commitment, an enforcement mechanism, a repeated relationship, a quota - so cooperating becomes your dominant move?
Then run the tournament. Save the listing from “The tournament” above as ipd.mjs:
node ipd.mjs
Three edits, each a one-line change and a re-run:
- Change
Tfrom 5 to 10 (CD: [0, 10], DC: [10, 0]). The shadow-of-the-future block now needs more rounds before cooperation wins - work out how many from T − R and R − P before you look. - Add a fifth strategy,
"tit-for-two-tats", that only defects after two betrayals in a row:(mine, theirs) => theirs.length >= 2 && theirs.slice(-2).every(m => m === "D") ? "D" : "C". Watch what always-defect does to it. - Set
roundsto 1 inplay. The whole tournament collapses to the one-shot answer, and always-defect finishes first. That single number is the difference between the two halves of this lesson.
Go deeper
- Poundstone (1992), Prisoner’s Dilemma - the game, its RAND-era history, and von Neumann.
- Hardin (1968), The Tragedy of the Commons - the n-player version.
- Ostrom (1990), Governing the Commons - how real communities escape the tragedy (Nobel 2009); the hopeful counterpoint.
- Axelrod (1984), The Evolution of Cooperation - the repeated-game escape.
Related
- Repeated Games & Cooperation takes this same tournament to Axelrod’s full field, and to the repeated games lab where you can move the round count and the mistake rate yourself.
- Dominant Strategies & Nash Equilibrium is the equilibrium concept this lesson gives its most famous, most damning example of.
- Motivation & Habit covers the reciprocity and reward that make tit-for-tat work outside a spreadsheet.
- The Road That Slows Everyone is the same trap on a road network: every driver’s best route makes everyone’s trip slower.
- Why Obey Anyone? (Philosophy) is this dilemma in prose three centuries early: Hobbes’s state of nature, and the state as the way out of it.
Retrieval practice
9 questions. Answer each one before you open it.
Set up the classic prisoner’s dilemma and identify the Nash equilibrium.
Two suspects in separate rooms; each can stay silent (cooperate) or talk (defect). Both silent = 1 year each; one talks = 0 for them, 10 for the other; both talk = 5 each. Talking dominates for both, so the unique Nash equilibrium is (talk, talk) = 5 years each - worse for both than (silent, silent).
What is the T > R > P > S structure and what does it guarantee?
The four outcomes ranked by desirability: Temptation (defect on a cooperator) > Reward (mutual cooperation) > Punishment (mutual defection) > Sucker (cooperate against a defector). When T > R > P > S, defecting strictly dominates, so the unique equilibrium is (P, P) even though (R, R) is better for both.
Why does the prisoner’s dilemma show that “rational” doesn’t mean “good outcome”?
Both players choosing their dominant strategy lands them at (P, P), which (R, R) beats for both of them at once. Individual rationality produces a collectively worse result - self-interested choices don’t automatically add up to an efficient group outcome.
What is the tragedy of the commons, and why is it the same trap as the prisoner’s dilemma?
Many players share a resource with open access. Each gains the full benefit of taking a bit more while the cost spreads across everyone, so all of them take more and the resource collapses. Restraint is best for the group; taking more is best for each individual - the same shape, scaled from two players to many.
Distinguish the free-rider problem from the tragedy of the commons, and name the general category both belong to.
The commons is over-use of a shared resource: everyone takes too much. The free-rider problem is under-provision of a shared good: everyone lets someone else pay for it. Both are collective-action problems - a group that can’t reach the outcome it would collectively prefer.
What’s the only real fix for a one-shot prisoner’s dilemma, and what changes once the game repeats?
In a genuine one-shot game between rational players, defecting is inescapable - the only fix is changing the payoffs themselves (a contract, a regulation, a quota). Once the game repeats, a new escape opens: the threat of future punishment can make cooperation pay on its own.
In the 200-round tournament, always-defect wins every single match and still finishes last. How are both true?
It scores at least as much as every opponent - 204 to 199 against tit-for-tat and grim, 1000 to 0 against always-coop - because defecting is the better move each round. But it drags every match down to the (1, 1) cell, earning about 200 per match, while tit-for-tat ties every cooperator at (3, 3) and earns 600 per match: 1808 against 2599 overall. A repeated game scores the sum across all matches, not who wins each one.
How many rounds does it take before tit-for-tat out-earns always-defect against a tit-for-tat opponent, and why that number?
Three. Played once, defect wins 5 to 3. Played twice, 6 to 6, a tie, because the 5 from round one and the 1 from round two together match two rounds of 3. From three rounds on, cooperation pulls ahead and never looks back - 600 to 204 by round 200. The one-time temptation is worth T − R = 2; every round after it costs R − P = 2, so the gain is gone after a single round of punishment.
Ten farmers share a pasture whose best total is 40 cows. What does the stable outcome look like, and why can no single farmer fix it alone?
Each farmer’s best reply to the others is 80 / (n + 1) = 7.3 cows, so 73 cows graze a field built for 40, and the village earns 529 instead of 1,600 - about a third. A farmer who cuts back alone to 4 cows earns about 42, less than the 52.9 they get by grazing along with everyone else, so restraint alone is the sucker’s payoff. Only a change to the payoffs - a quota, a fee, single ownership - moves the equilibrium.