Back to Projects

Prisoner's Dilemma

Play the classic game theory experiment against AI opponents with different strategies

Your Strategy

Opponent Strategy

You

0
VS

Opponent

0
Round: 0 / 10

Game History

Cumulative Score

Payoff Matrix

Opponent Cooperates Opponent Defects
You Cooperate Both: +3 You: 0
Opponent: +5
You Defect You: +5
Opponent: 0
Both: +1

Strategy Descriptions

Tit for Tat: Cooperates first, then copies opponent's last move

Tit for Two Tats: Cooperates unless opponent defects twice in a row

Always Cooperate: Always cooperates regardless

Always Defect: Always defects regardless

Grudger: Cooperates until opponent defects once, then always defects

Detective: Tests with C,D,C,C then plays Tit for Tat or Always Defect

Pavlov: Repeats last move if it led to good outcome, switches if not

Suspicious Tit for Tat: Like Tit for Tat but defects first — distrust as an opening move

Bully: Defects first, then does the opposite of your last move — exploits cooperators, retreats from retaliators

Prober: Opens D,C,C — exploits you forever if you didn't punish the opening defection, otherwise plays Tit for Tat

Handshake: Opens D,C as a secret signal — cooperates forever only with opponents who echoed the same greeting

Generous Tit for Tat: Tit for Tat that forgives a defection 1/3 of the time — immune to revenge spirals

Joss: Tit for Tat that sneaks in a betrayal 10% of the time — tests whether occasional cheating pays

Extortioner: Zero-determinant strategy (Press & Dyson, 2012) — uses fixed cooperation odds per outcome to force twice your surplus, no matter how you play

Custom Reactive: You set the odds — probability of cooperating after their cooperation and after their defection

Random: Randomly chooses to cooperate or defect

Why this game matters

The dilemma: Whatever your opponent does, defecting scores you more in that single round (+5 beats +3, and +1 beats 0). Two purely rational players therefore both defect — and end up with +1 each, far worse than the +3 each they'd get by cooperating. That "both defect" outcome is the Nash equilibrium: neither player can improve by changing only their own move, yet it's collectively the worst cell in the table.

Repetition changes everything: When the game is played many times, today's betrayal can be punished tomorrow. This "shadow of the future" makes cooperation rational. Watch the cumulative score chart: strategies that find mutual cooperation track the dashed +3-per-round line, while mutual defectors fall far below it.

Axelrod's tournaments: In famous 1980s computer tournaments, the simplest entry — Tit for Tat — beat sophisticated rivals. Winning strategies shared four traits: they were nice (never defect first), retaliatory (punish defection promptly), forgiving (return to cooperation once the opponent does), and clear (easy to read, so opponents can learn to trust them).

Probabilistic strategies: Some strategies roll dice instead of following fixed rules — game theorists call these mixed strategies. Randomness serves three very different purposes here. Generous Tit for Tat uses it for forgiveness: by pardoning a defection a third of the time, it escapes the endless revenge cycles that trap regular Tit for Tat (run it against Suspicious Tit for Tat to see the cycle break). Joss uses it for sneakiness: a 10% random betrayal that probes whether cheating goes unpunished. The Extortioner uses it for control — a 2012 discovery by Press and Dyson that shocked game theorists: by choosing exact cooperation probabilities for each outcome, it mathematically pins your payoff to its own, taking twice the surplus no matter what you do. Your best response is still to cooperate — you'll just always earn half as much. In single matches extortion works; in evolving populations it dies out, because extortioners starve each other. Since these strategies roll dice, replay the same matchup several times and watch the scores vary — then average them in your head. That's how game theorists actually evaluate strategies: by expected payoff, not one lucky game.

Nice vs. nasty: Strategies that open by cooperating are called nice; those that open by defecting are nasty. Axelrod found that every top finisher in his tournaments was nice — a nasty opening tends to cost more trust than it gains in points. The clearest demo: Suspicious Tit for Tat vs. regular Tit for Tat. One opening defection triggers an endless alternating revenge cycle, and both players score far below two ordinary Tit for Tats — the first move poisons the whole game.

Try it: Pit Grudger against Detective to see a probe punished forever. Run Bully against Always Cooperate to watch a pushover get exploited every single round, then swap in Tit for Tat and watch Bully retreat. Pit Prober against Tit for Two Tats — its patience reads as weakness, and Prober exploits it. Pit Always Defect against Tit for Tat and note that Always Defect "wins" the match but posts a terrible score — then remember the goal is points, not beating the other player. Real-world versions of this game include price wars, arms races, and evolutionary biology.