Prisoner's Dilemma Simulation
The Prisoner's Dilemma is a fundamental concept in game theory that demonstrates why two rational individuals might not cooperate, even when it's in their best interest to do so. This interactive simulation shows how different strategies perform when competing in a population over many iterations.
Watch as agents with different strategies interact, accumulate scores, and visualize how cooperative versus selfish strategies fare in various conditions.
The Prisoner's Dilemma
In the classic Prisoner's Dilemma, two individuals must decide whether to cooperate or defect. If both cooperate, they each receive a moderate reward. If both defect, they each receive a small punishment. If one cooperates and the other defects, the defector gets a large reward while the cooperator gets nothing.
This creates a paradox: while mutual cooperation would benefit both players more than mutual defection, the rational strategy for an individual is to defect, leading to a worse outcome for both.
Strategies Explained
This simulation includes several well-known strategies:
- Cooperator: Always cooperates regardless of what the opponent does.
- Defector: Always defects regardless of what the opponent does.
- Tit for Tat: Starts by cooperating, then copies the opponent's previous move.
- Random: Randomly chooses to cooperate or defect with equal probability.
- Grudger: Cooperates until the opponent defects, then always defects.
- Detective: Starts with a specific sequence, then switches to Tit for Tat if the opponent ever defects, otherwise defects.
- Pavlov: Starts by cooperating, then changes strategy only when receiving a low payoff.
Simulation Mechanics
This simulation creates a population of agents using two selected strategies. The agents are paired randomly and play multiple rounds of the Prisoner's Dilemma, accumulating scores based on their interactions.
The visualization shows both the agents (the dots on the left) and the score distribution (the histogram on the right). The size of each agent reflects its score: more successful agents appear larger.