Two members of a gang are arrested and held in separate cells. The prosecutor has enough evidence to convict both of a minor offence, and makes each the same offer. Testify against your partner. If you do and he stays silent, you go free and he gets ten years. If you both testify, you each get five. If you both stay silent, you each get one year on the minor charge.

Each prisoner reasons alone. Suppose my partner stays silent: then I do better by testifying, since I go free instead of serving a year. Suppose he testifies: I still do better by testifying, five years instead of ten. Whatever he does, testifying is better for me.

His reasoning is the same. Both testify and both serve five years, when by keeping quiet they could each have served one.

This is the prisoner's dilemma. It was devised in 1950 by two mathematicians at the RAND Corporation, Merrill Flood and Melvin Dresher, and given its story by Albert Tucker. It has been studied more than any other game in the social sciences, because the same structure appears wherever individuals gain by cheating on an arrangement that benefits everyone: arms races, price wars, overfishing, doping in sport.

Points instead of prison

Game theorists usually restate it with rewards. Each player chooses to cooperate or to defect.

They cooperate They defect
You cooperate 3 points each You 0, they 5
You defect You 5, they 0 1 point each

In a single game, defecting is always the better choice, and two rational players end up with 1 point each when they could have had 3.

Playing again and again

Real life seldom offers a single game. Neighbours, trading partners and rival firms meet repeatedly. When the game is played many times between the same two players, the logic changes. Defecting today may bring retaliation tomorrow. The future gives a reason to behave.

But which way of playing does best? Around 1980 Robert Axelrod, a political scientist at the University of Michigan, decided to find out by experiment. He wrote to game theorists in economics, psychology, mathematics and political science and invited each to submit a computer program embodying a strategy. Every program would play every other, and a copy of itself, for 200 rounds. The highest total would win.

Fourteen entries arrived. Some were intricate. One modelled its opponent's behaviour statistically and tried to exploit it.

The winner was the shortest program submitted, four lines long. It came from Anatol Rapoport, a mathematical psychologist in Toronto, and was called tit for tat. Its entire rule was to cooperate on the first move and after that to do whatever the other player did on the previous move.

The second tournament

Axelrod published the results and the analysis and announced a second round. This time 62 entries came, from six countries, and the entrants included computer hobbyists and specialists who had studied the first tournament closely. Everyone knew that tit for tat was the program to beat.

Rapoport submitted tit for tat again, unchanged. It won again.

The strange part is that tit for tat cannot beat any single opponent. It can at best tie, and it loses slightly to anyone who defects against it, because it gives the other side the first blow. It won on total points, by doing well against almost everyone.

Why it worked

Axelrod identified four properties shared by the strategies that scored highest.

Nice. They were never the first to defect. In the first tournament, the eight top-ranked entries were all nice, and none of the others was.

Retaliatory. They punished defection promptly. A strategy that always cooperates is simply exploited.

Forgiving. They returned to cooperation once the other side did. Strategies that held grudges for ever locked themselves into long runs of mutual punishment.

Clear. Their behaviour was easy for an opponent to read. Programs that were too clever looked random to their partners, who could find no way of cooperating with them.

He added a piece of advice against envy. The strategies that did badly were often trying to score more than their opponent. Tit for tat never does that. In a game where both players can gain, trying to beat the other person usually means that both lose.

Cooperation without friendship

Axelrod went on to run an ecological version. Strategies that scored well in one generation were given more copies in the next, as though they had reproduced. Aggressive strategies flourished briefly by preying on the naive ones, and then died out as their victims disappeared. The nice, retaliatory strategies took over.

In his 1984 book The Evolution of Cooperation he connected this to biology and history. His most striking example came from the Western Front in the First World War. In quiet sectors, opposing units who faced each other for months developed an unofficial system of live and let live. They shelled at predictable times, aimed to miss and observed meal breaks. If one side broke the pattern, the other retaliated in proportion and then resumed. No one had agreed to this, and the two sides could barely communicate. It arose because the same units met day after day. Commanders eventually broke it up by ordering raids, which destroyed the trust.

Biologists have applied the same reasoning to animals that cooperate with unrelated individuals, such as fish that clean parasites from larger fish without being eaten.

What later research changed

The tournaments became famous, and tit for tat acquired a reputation as the solution to the problem of cooperation. Later work has complicated that in several ways.

Noise. Real interactions involve mistakes: a signal misread, an action that misfires. Tit for tat handles this badly. If one player defects by accident, the other retaliates, the first retaliates in return, and the two echo each other indefinitely. More forgiving variants do better: generous tit for tat, which lets an occasional defection pass, and tit for two tats, which waits for two in a row.

A rival rule. In 1993 Martin Nowak and Karl Sigmund found that in simulations with noise, a different rule often prevailed. Known as win-stay, lose-shift, or Pavlov, it repeats its previous move if that move paid well and switches if it paid badly. It corrects mistakes after one round and can exploit unconditional cooperators.

Collusion. At a tournament held in 2004 to mark the twentieth anniversary, a team from the University of Southampton entered sixty programs designed to recognise each other through a coded opening sequence. Once they had done so, some sacrificed themselves by always cooperating so that a designated partner could defect and collect the maximum. Against outsiders they simply defected. The team's best programs took the top places, and the sacrificial ones finished at the bottom. The entry exploited the rules of the competition more than it advanced the theory, but it was a pointed reminder that the result depends on who else is playing.

Extortion. In 2012 the physicist Freeman Dyson and the computer scientist William Press showed mathematically that there exist strategies allowing one player to enforce a fixed, unequal relationship between the two scores, in effect extorting the other. Further work found that such strategies do badly in evolving populations, where generous relatives of them do well.

No best strategy. The firmest conclusion is one Axelrod stated himself. No strategy is best independently of the others in the population. Tit for tat won those tournaments against those entrants. In a different crowd, something else would.

What survives

The broad lessons have held up better than any particular rule.

Cooperation between self-interested parties does not need trust, friendship or a central authority. It needs repeated dealings, and a future that matters enough to both.

When the future is short, cooperation fails. The last round of a known, finite game invites defection, and so, working backwards, does every round before it. Arrangements are fragile near their end.

And the conditions can be designed. If you want people to cooperate, make their interactions more frequent and longer-lasting, make each party's behaviour visible to the other, and break large one-off transactions into many small ones.

Try it

The game can be played across a table with two coins. Heads is cooperate, tails is defect. Each player chooses secretly and both reveal together. Use the points table above and play twenty rounds without announcing how many there will be.

Then play again, this time telling both players that there will be exactly ten rounds. Note what happens in rounds nine and ten, and how early the trouble begins.