b2KIT

prisoners-dilemma-simulator

Play iterated prisoner dilemma against strategies (tit-for-tat, always defect, random). Tournament mode compares all strategies.

Tested tool guide Tested browser tools Checked August 16, 2026

What prisoners-dilemma-simulator does, with a checked example

Pick two strategies and this tool plays an iterated prisoner's dilemma between them: each round both choose cooperate or defect, and the classic payoffs apply - mutual cooperation earns 3 each, mutual defection earns 1 each, defecting against a cooperator earns 5, and being exploited earns 0. Presets include tit-for-tat, always defect, and random, and tournament mode pits every strategy against every other over a chosen number of rounds. The result that surprises most users: always defect beats tit-for-tat one-on-one, yet loses the tournament, because a one-time 5-point bonus is worth less than many rounds of 3-point cooperation.

Worked example

A concrete input and expected output from the current implementation.

Input

Tit-for-tat vs. Always defect, 10 rounds

Expected output

Round 1: cooperate vs. defect (0-5). Rounds 2-10: defect vs. defect (1-1 each round). Final totals: tit-for-tat 9, always defect 14.

Tit-for-tat cooperates on its opening move, so always defect collects the 5-point temptation once; after that tit-for-tat retaliates and both defect for the remaining nine rounds at 1 point per round. The defector wins this match 14-9, which is precisely why the tournament result is different: 14 against this one opponent, but only 1 per round against every other.

How the result is produced

1

Payoff matrix

The tool applies the classic prisoner's dilemma table: mutual cooperation pays 3-3, mutual defection pays 1-1, defection against a cooperator pays 5-0. Because 5 beats 3 and 1 beats 0, defecting looks better in any single round, yet both defecting scores less than both cooperating - the dilemma the simulation makes visible by totalling points across repeated rounds.

2

Strategy logic and tournament mode

Tit-for-tat opens with cooperation and thereafter mirrors the opponent's previous move; always defect plays defect every round; random chooses unpredictably each round. Tournament mode pairs every strategy against every other for the set number of rounds and compares accumulated points across all matches, so a strategy ranks well by scoring against the whole field, not by beating any one opponent.

Good uses

  • See for yourself why tit-for-tat beat more elaborate strategies in Axelrod's famous tournaments: watch mutual cooperation accumulate when it faces a cooperator, then compare its total with always defect's against the same field.
  • Test whether the temptation to defect actually pays: run always defect against always cooperate and against tit-for-tat, and compare the one-time 5-point bonus with sustained 3-point cooperation over many rounds.
  • Demonstrate the one-shot versus repeated-game distinction to students or colleagues - defecting dominates in a single round, cooperating wins over time - with live round-by-round scores on screen.

Limits and checks

  • Scores assume the standard 5/3/1/0 payoffs. Under a different table (reward 4, temptation 6, and so on) every total changes and some strategy rankings can flip, so treat the numbers as specific to this payoff set rather than universal game-theory results.
  • A single match is not a tournament. Always defect beats tit-for-tat head-to-head yet loses the tournament, so never rank strategies from one pairing - only the all-against-all totals support a ranking.
  • Matches against the random strategy differ on every run, and the round count changes the winner: few rounds favor defection, many favor cooperation. Read single runs as samples, not expected values, and re-run before drawing conclusions.

Common questions

Why does always defect beat tit-for-tat head-to-head if tit-for-tat is considered the better strategy?

Always defect grabs the 5-point temptation in round one, then both sides defect at 1 point per round, so over ten rounds the defector leads 14-9 and never gives it back. In a tournament, though, always defect collects about 1 point per round against everyone, while tit-for-tat earns 3 per round against cooperative opponents. Total points across all matches, not one pairing, decide the winner.

Will I get the same result twice if I replay against the random strategy?

No. The random strategy's choices vary run to run, so two ten-round matches will usually end with different totals. If you want a fair comparison against randomness, run the match several times and average the totals - or stick to the deterministic pairings, which reproduce exactly every time.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools