In this assignment, we will have some fun with a classic
game called the Prisoner's Dilemma. You will write strategies
for this game. We will hold a class-wide competition and play off
all strategies against each other in an iterated fashion to see
which strategy performs best in the long run. In addition
to the standard 2-person game, we will introduce a variation
and play 3-person games as well.
Let's start by understanding how the game is played a single
time between two players:
We will do more than play an iterated game. We will play all
players pairwise against each other multiple times. That is, A plays B
N times; then A plays C N times; then B plays C
N times, and so on. In each game played, each player will
come away with zero or more in winnings. The player with the maximum
winnings after all games is the overall champion.
Your goal is to play to win overall.
Here's how we will describe the winnings for a particular game:
To play, you will need to write a strategy as a Java
class. For each game played, you will get the following
as input:
We have just described in detail the method interfaces
you need to implement:
Finally, let's describe the 3-person game:
What to submit:
We are going to be interested in the Iterated Prisoner's
Dilemma, in which such games are repeatedly played and in which
one player can "learn" how the other reacts. The objective is
to maximize winnings totalled across many games.
How should such a player play? One can reason as follows: "If I only betray,
and do this repeatedly, I'll never win anythingn if I play
against players like me". So, it might
make sense to occasionally remain silent.
0 0 Both A and B betray.
0 1 A betrays, B stays silent.
1 0 A is silent, B betrays.
1 1 Both are silent.
0 0 Both get $0
0 1 A gets $4, B gets $0
1 0 A gets $0, B gets $4
1 1 A gets $2, B gets $2 (they share the loot)
public static final int[][] TWO_PLAYER_PAYOFF_MATRIX = {
{0,0, 0,0},
{0,1, 4,0},
{1,0, 0,4},
{1,1, 2,2}
};
Here, the actual payoff information is in the third and
fourth columns. Just for completeness, we also provide
the combinations in the first two columns. Thus, if you
know the matrix, then you know the rules of the game.
Of course, you will also want to know what your opponent
did in a game. Thus, after you've played, we will provide
you with the action taken by the other opponent. We will also
provide you with your payoff and your total current score.
You will also need the game simulator. Download
this jar file, which has the
simulator and related classes. When you unpack, you
can run PrisonerGame, which will bring up a frame.
To run the simulator:
At this point, you have enough to start implement your 2-player
strategies. If you like, you may
examine the code in PrisonerGame.java
to see how the rounds are conducted. Essentially one tournament
round consists of every player playing every other player exactly
once. Then, this is repeated for each round for as many rounds
are there are.
Thus, depending on the game-type, you will get one of
three matrices when the simulator calls your playGame
method.
0 0 0 All three betray.
0 0 1 Only C is silent.
0 1 0 Only B is silent.
0 1 1 Only A betrays.
1 0 0 Only A is silent.
1 0 1 Only B betrays.
1 1 0 Only C betrays.
1 1 1 All three betray.
0 0 0 A,B,C all get $0
0 0 1 A and B escape and share ($3 each), C gets $0
0 1 0 A and C get $3 each, B gets $0
0 1 1 A escapes and gets $6, whereas B and C get $0
1 0 0 A gets $0, B and C get $3 each
1 0 1 B gets $6, A and C get $0
1 1 0 C gets $6, A and B get $0
1 1 1 All escape and get $2 each.
public static final int[][] THREE_PLAYER_MINORITY = {
{0,0,0, 0,0,0 },
{0,0,1, 3,3,0 },
{0,1,0, 3,0,3 },
{0,1,1, 6,0,0 },
{1,0,0, 0,3,3 },
{1,0,1, 0,6,0 },
{1,1,0, 0,0,6 },
{1,1,1, 2,2,2 }
};
public static final int[][] THREE_PLAYER_MAJORITY = {
{0,0,0, 0,0,0 },
{0,0,1, 3,3,0 },
{0,1,0, 3,0,3 },
{0,1,1, 0,3,3 },
{1,0,0, 0,3,3 },
{1,0,1, 3,0,3 },
{1,1,0, 3,3,0 },
{1,1,1, 2,2,2 }
};
We will find some time in class
to play the full competition. It should be exciting.