The Prisoner's Dilemma

by Serge Helfrich

The spatial variant of the iterated prisoner's dilemma is a simple yet powerful model for the problem of cooperation versus conflict in groups. The applet below demonstrates the spread of 'altruism' and 'exploitation for personal gain' in an interacting population of individuals learning from each other by experience. Initially the population consists of cooperators and a certain amount of defectors (a fraction represented by p). The advantage of defection is determined by the the value of b in the 'payoff matrix' (see below) which is used to calculate the payoff after each round for each 'player' on the basis of its strategy. For the next round a player determines its new strategy by selecting the most favourable strategy from itself and its direct neighbours.

You can use the links below to learn more about this fascinating topic in 'game theory':

demonstration applet

BTW I stole the idea for this applet from A.L. Lloyd (Sci. Amer., June 1995, 80-83).

the payoff matrix


  • is cooperating, did cooperate
  • is defecting, did defect
  • is cooperating, did defect
  • is defecting, did cooperate
b: advantage for defection when opponent cooperates

p: fraction (0..1) of defectors in the first round

Applet FAQ

Applet source code

Get Java if the applet does not start:
Get Java

suggested experiments