Katas

Axelrod’s Tournament

Written by Chris Brown | May 19, 2026 9:58:11 AM

In 1980 Professor Robert Axelrod invited game theorists to submit strategies for a winner-takes-all tournament which promised to describe how cooperation develops in the nature of humans or animals. You are required to make that tournament happen.

The tournament centres around a game called the Prisoners Dilemma. Two players are separately given the option, do they want to Cooperate or Defect? When their decisions are revealed they receive points based on the outcome;

  • Both players choose cooperate: Both get 3 points each.

  • Both players choose defect: Both get 1 point each.

  • One player cooperates and one player defects: The defector gets 5 points and the cooperator gets 0.

As a one-off the best outcome may be to defect whichever way the opponent decides (5 or 1 points vs 3 or 0). However, Axelrod suggested that playing the game against the same person repeatedly demonstrated how the nature of cooperation evolves in communities of people or animals.

The tournament would therefore match up strategies against each strategy (including itself) to play 200 rounds of the prisoners dilemma each match-up. The goal of the tournament for each strategy is to win as many points as possible across all it's match-ups. Finally, the whole tournament is repeated 5 times and each strategy gets the average of their tournament totals. These final scores would need to be ordered and displayed as a table.

A strategy can see how many rounds have been played and what they and their opponent have played. The submitted strategies ranged from just responding to the opponents last move, to calculating moves through probability or other formulae.

The strategies are outlined below. You will need to make as many as you can, remember the Open-Closed principle. All maths may have been simplified due to the limit of the authors knowledge.



Strategies:

TitForTat

Cooperate on first move, then copy the previous action of the opponent.

Grudger

Starts by cooperating. If the opponent ever defects this will defect for the remaining rounds.

Davis

Cooperates for first 10 rounds. Then it will continue to cooperate until the opponent defects, at which point this will defect for the remaining rounds.

Random

Randomly chooses between cooperating and defecting.

TitForTat

Cooperate on first move, then copy the previous action of the opponent.

Grofman

If the players did different things on the previous move then this rule cooperates with probability 2/7. Otherwise it always cooperates.

Joss

Always defects after a defection by the opponent. Cooperates 90% of the time after the opponent cooperates.

Feld

Cooperate on first move, then copy the previous action of the opponent if they defect. If they cooperate then only cooperate with a probability which is:

CooperationProbability = 1 + (-0.5 * (currentRound / totalRounds))

Tullock

Cooperates on first 11 moves.
Then randomly cooperates 10% less than the opponent has in the previous 10 rounds.

Nydegger

Cooperate on first move, then copy the actions of the opponent for the first 3 moves, unless the opponent defects on the first then cooperates on the second, in which case this strategy defects on the third move.

After that each move is chosen based on the 3 preceding outcomes. First each move is scored by adding 2 if the opponent defected and 1 if the strategy defected. Then the scores are weighted in chronological order and added by Total = 16a1 + 4a2 + a3. (a3 is the previous move and a1 is 3 moves previously).

Finally, the strategy will defect if the total score is in this list of numbers:

{1, 6, 7, 17, 22, 23, 26, 29, 30, 31, 33, 38, 39, 45, 49, 54, 55, 58, 61}.

Shubik

Cooperates until the other defects. When the opponent defects first time then the strategy will defect once then resume cooperating. When the opponent then defects again the strategy will defect twice then resume cooperating. The number of retaliatory defects will keep increasing by one.

Tideman & Chieruzzi

Cooperate on first move, then copy the previous action of the opponent.

The strategy defects in the last 2 moves.

Persists a number of defections to retaliate to the opponent with, starting with 1. Every run of defections played by the opponent increases the number of retaliatory defections by 1. (If the opponent defects then cooperates, the strategy will copy the defection on the move after. If the opponent then defects twice then cooperates, the strategy will copy the 2 defections and then defect once more, etc.)

The strategy allows for a 'fresh start' where it will play 2 cooperations then wipes the memory of previous moves. This is played when:

  • The opponent is 10 points behind the strategy

  • and it has not just started a run of defections

  • and it has been at least 20 rounds since the last fresh start

  • and there are more than 10 rounds remaining in the match

  • and total defections differs from a 50-50 random sample by at least 3.0 standard deviations = ((0.25 * defections + -0.25 * cooperations) / countRounds * players) < 2.25

Downing

Defects on first two moves.

Finds all moves made by the strategy except the last and how the opponent responded to them. Get counts of:

Total cooperations played

Total opponent cooperations after a cooperation was played

Total defects played

Total opponent cooperations after a defect was played.

 

Then calculate the alpha and beta which are the percentage chances of cooperation being played after cooperation and defects (alpha and beta start off as 0.5 then are updated each turn):

alpha = Total opponent cooperations after a cooperation was played / Total cooperations played

beta = Total opponent cooperations after a defect was played / Total defects played

 

Then it calculates the expected rewards for cooperating and defecting:

ExpectedAfterCooperating = (alpha * 3) + ((1 - alpha) * 0)

ExpectedAfterDefecting = (beta * 5) + ((1 - beta) * 1)

 

Finally, if ExpectedAfterCooperating > ExpectedAfterDefecting then cooperate

else if ExpectedAfterCooperating < ExpectedAfterDefecting then defect

else if ExpectedAfterCooperating == ExpectedAfterDefecting then do the opposite of the last move (cooperate if the last move was defect or defect if the last move was cooperate)

Stein & Rapoport

Cooperates for the first 4 moves.

Defects on the last 2 moves.

Every 15th move it uses a chi-squared test to check if opponent playing randomly and if so defects.

 

Chi-square test

Compare the opponents moves to the strategy move just before them. There are 4 possible outcomes; cooperate after defect, defect after defect, cooperate after cooperate, defect after cooperate (CD, DD, CC, DC). If there is a pattern of CD then DC then defect.

Get counts of the 4 outcomes.

Then calculate expected with the following formulae:

ExpectedCCCount = (CCCount + CDCount) * (CCCount + DCCount) / (CCCount + CDCount + DCCount + DDCount)

ExpectedCDCount = (CDCount + CCCount) * (CDCount + DDCount) / (CCCount + CDCount + DCCount + DDCount)

ExpectedDCCount = (DCCount + DDCount) * (DCCount + CCCount) / (CCCount + CDCount + DCCount + DDCount)

ExpectedDDCount = (DDCount + DCCount) * (DDCount + CDCount) / (CCCount + CDCount + DCCount + DDCount)
 

Now compare the 4 observed to expected with the following formulae:

CC = (CCCount - ExpectedCCCount)² / ExpectedCCCount

CD = (CDCount - ExpectedCDCount)² / ExpectedCDCount

DC = (DCCount - ExpectedDCCount)² / ExpectedDCCount

DD = (DDCount - ExpectedDDCount)² / ExpectedDDCount

 

Sum those 4 values and if >= 3.841459 then defect.

 

Graaskamp

Cooperate on first move, then copy the previous action of the opponent for the first 50 moves.

Defects on move 51.

Copies the previous action of the opponent for 5 moves.

Performs a chi-squared test to see if the opponent is playing randomly, in which case defect for the remaining rounds (See Stein & Rapoport above for the chi-squared test).

Check whether the opponent has played all the same moves or has been copying the strategy moves. If so then copy the previous action of the opponent. If not it starts a loop where it picks a random step number between 5 & 15 moves ahead, defects on that move then picks the next random step.

Extra work

Afterwards Axelrod identified 4 characteristics to classify the strategies. Assign these to the strategies and then add columns to the final table for each characteristic so the results show how they classify. See if there are patterns that show what types of strategies perform well.

The characteristics are:

Nice: Does the strategy try to cooperate first or are they the first to defect?

Forgiving: If a strategy reacts to defecting does it go back to normal or does it hold a grudge?

Retaliatory: Does the strategy respond to the opponent defecting?

Clear: Is the strategy clear or complicated?