Understanding the prisoner's dilemma calculator — concept and principle
This calculator sets up a prisoner's dilemma payoff matrix, checks whether your payoffs really form a dilemma, finds the one-round Nash equilibrium and plays two strategies against each other over repeated rounds. Use it for game theory courses and to explore why cooperation is hard to sustain.
How it is calculated
- Payoffs: R if both cooperate, P if both defect, T to a lone defector and S to the lone cooperator.
- It is a prisoner's dilemma when T > R > P > S. For the repeated game the usual extra condition is 2R > T + S.
- The one-shot pure-strategy Nash equilibria are found by checking each cell for a profitable one-player deviation.
- The repeated game plays the chosen strategies for the set number of rounds and adds up each player's payoffs.
Strategies: Always cooperate, Always defect, Tit for Tat (cooperate first, then copy the opponent's last move), Grim trigger (cooperate until the opponent defects once, then defect forever) and Alternate.
The principle
Whatever the other player does, defecting pays more: T > R if they cooperate and P > S if they defect. So in a single round, rational players both defect and get P each, even though both cooperating would give each R, which is higher. That gap between individual and collective interest is the dilemma. When the game is repeated, future rounds can reward cooperation and punish defection, which is why reciprocal strategies such as Tit for Tat can do well. The condition 2R > T + S makes steady cooperation beat taking turns exploiting each other.
Worked example
Default inputs: T = 5, R = 3, P = 1, S = 0; Tit for Tat against Always defect; 10 rounds.
- Check: 5 > 3 > 1 > 0 and 2 × 3 = 6 > 5 + 0, so it is a prisoner's dilemma. One-shot equilibrium: both defect.
- Round 1: Tit for Tat cooperates, Always defect defects: player 1 gets S = 0, player 2 gets T = 5.
- Rounds 2–10: Tit for Tat copies the defection, so both defect for 9 rounds and each gets P = 1.
- Player 1 total: 0 + 9 × 1 = 9; player 2 total: 5 + 9 × 1 = 14.
- Averages per round: 0.9 and 1.4; no rounds of mutual cooperation, 9 rounds of mutual defection.
| Punishment P (both defect) | Total payoff, player 1 |
|---|---|
| 0.25 | 2.25 |
| 0.5 | 4.5 |
| 0.75 | 6.75 |
| 1 | 9 |
| 1.25 | 11.25 |
| 1.5 | 13.5 |
| 2 | 18 |
How to read the result
Totals show who did better in this pairing. Tit for Tat never beats its opponent in a single match, but it loses only by the first round's T − S and does very well against cooperative strategies. Try Tit for Tat against itself: it earns R every round.
Common mistakes
- Using payoffs that do not satisfy T > R > P > S and still calling it a dilemma.
- Concluding that defection is always best in repeated games.
Frequently asked questions
Why is mutual defection an equilibrium?
Neither player can gain by switching alone: switching to cooperate would drop that player from P to S.
What made Tit for Tat famous?
It won Robert Axelrod's computer tournaments around 1980, despite being one of the simplest strategies.
What is the difference between Tit for Tat and Grim trigger?
Tit for Tat forgives as soon as the opponent cooperates again; Grim trigger never forgives.
Sources: Stanford Encyclopedia of Philosophy, "Prisoner's Dilemma"