The outcome for each player depends on both choices
This models many real situations: arms races, price wars, environmental agreements
2-Player Payoff Table
Opponent Cooperates
Opponent Defects
You Cooperate
You: 3, Opp: 3
You: 0, Opp: 5
You Defect
You: 5, Opp: 0
You: 1, Opp: 1
The Dilemma
No matter what your opponent does, defecting gives you more points
If they cooperate: defecting gives 5, cooperating gives 3
If they defect: defecting gives 1, cooperating gives 0
Yet if both defect, each gets only 1
If both cooperate, each gets 3, much better for everyone
Individual self-interest leads to a worse outcome for both players
Iterated Prisoner’s Dilemma
What if you play the same opponent many times in a row?
Now your choices have consequences: you can reward or punish past behavior
This changes everything, cooperation can emerge as a rational strategy
Famous example: Tit-for-Tat
Cooperate on round 1
Then copy whatever your opponent did last round
Simple, but surprisingly effective against many strategies
Why Iteration Matters
With a single game, defecting is always rational
With many rounds, a player who always defects will be punished in future rounds
A player who cooperates can build mutual trust and earn more points over time
The best strategy depends on what your opponent does, this is what makes it interesting
3-Player Prisoner’s Dilemma
Now there are three players: you and two opponents
Each round all three independently choose: cooperate or defect
Your score depends on your own move and how many opponents cooperated
The more opponents cooperate, the more points you can earn
3-Player Payoff Table
Your Move
Opponents Who Cooperated
Your Points
Cooperate
2
3
Cooperate
1
1
Cooperate
0
0
Defect
2
5
Defect
1
3
Defect
0
1
Reading the Table
Defecting always earns more than cooperating, no matter what opponents do
But if all three defect, everyone earns only 1 point per round
If all three cooperate, everyone earns 3 points per round
The tension is the same as the 2-player version, but now spread across three players
The Exercise
You will implement a strategy for the 3-player iterated game in Java
Your strategy is a class with two methods:
getTeamName()
Returns the name of your team as a String
decision(history1, history2)
history1 is the history of opponent 1’s past moves
history2 is the history of opponent 2’s past moves
Returns Move.COOPERATE or Move.DEFECT
The game runs for a variable amount of rounds, between 150 and 250
Your team’s total score is the sum of your points across all rounds
What You Are Given
// Three provided strategies to test against:
new IPD3RandomTeam() // cooperates or defects randomly
new IPD3AlwaysDefect() // always defects
new IPD3Lenient() // cooperates unless BOTH opponents defected last round
Your class is IPD3Team where you must implement the getTeamName and decision methods
The MoveLists passed in have the most recent moves of your opponents first
You can look at any number of past rounds to inform your decision
You can also add fields to the class to track things such as the round number or other data about your opponents