Topics in Modelling, Simulation and Optimization


Prisoner's Dilemma


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 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.

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:

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.

We have just described in detail the method interfaces you need to implement:

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.

Finally, let's describe the 3-person game:

Thus, depending on the game-type, you will get one of three matrices when the simulator calls your playGame method.

What to submit:

We will find some time in class to play the full competition. It should be exciting.