Project 6: Prisoner's Dilemma

Due: Tuesday 22 November 2007



This time we're playing a game! You are asked to implement a class that represents a player in the Prisoner's Dilemma (PD), a game that finds itself at the core of many problems in economics, management and organizational theory, sociobiology, group dynamics, evolutionary dynamics, and your CSIT 114: Project 6. Get excited. The Prisoner's dilemma is almost always mentioned when discussion genetic algorithms or evolutionary dynamics because of a famous tournament set up by political scientist Robert Axelrod in the 1970s. In this assignment we're going to recreate history. But first, here's is a short fable that describes the basic premise of that dilemma that I shameless lifted from another problem set at MIT.


In the mid-1920's, the Nebraska State Police achieved what may still be their finest moment. After a 400-mile car chase over dirt roads and corn fields, they finally caught up with the notorious bank robbers Bonnie and Clyde. The two criminals were brought back to the police station in Omaha for further interrogation.

Bonnie and Clyde were questioned in separate rooms, and each was offered the same deal by the police. The deal went as follows (since both are the same, we need only describe the version presented to Bonnie):

"Bonnie, here's the offer that we are making to both you and Clyde. If you both hold out on us, and don't confess to bank robbery, then we admit that we don't have enough proof to convict you. However, we will be be able to jail you both for one year, for reckless driving and endangerment of corn. If you turn state's witness and help us convict Clyde (assuming he doesn't confess), then you will go free, and Clyde will get twenty years in prison. On the other hand, if you don't confess and Clyde does, then he will go free and you will get twenty years."

"What happens if both Clyde and I confess?" asked Bonnie.

"Then you both get ten years," said the interrogator.

Bonnie, who had been a math major at Caltech before turning to crime, reasoned this way: "Suppose Clyde intends to confess. Then if I don't confess, I'll get twenty years, but if I do confess, I'll only get ten years. On the other hand, suppose Clyde intends to hold out on the cops. Then if I don't confess, I'll go to jail for a year, but if I do confess, I'll go free. So no matter what Clyde intends to do, I am better off confessing than holding out. So I'd better confess."

Naturally, Clyde employed the very same reasoning. Both criminals confessed, and both went to jail for ten years. (Actually, they didn't go to jail. When they were in court, and heard that they had both turned state's witness, they strangled each other. But that's another story.) The police, of course, were triumphant, since the criminals would have been free in a year had both remained silent.

The Code

I have written a class that represents the Prisoner's Dilemma game. To create a player that works with PDGame, you must implement the Prisoner's Dilemma player interface that I have designed for this project. The strategy that you write into your player class should take into consideration the moves of your opponent from the previous two games played. (Note that you will need to hard-code a decision for the first and second games.)

I will host a tournament in lecture on Thursday, 29 November 2007 to determine a class winner.

The methods that comprise the PD player interface are contained in To signal to Java that your class adheres to the interface you must use the reserved word implements in your class declaration. For example, the class CooperatingJosh that we saw in lecture begins like this:

public class CooperatingJosh implements PDPlayer{

	// Class definition here.

Additionally, provide a constructor that takes no arguments so that I can instantiate your class during the tournament. For example,

PDPlayer player1 = new CooperatingJosh();

Be sure to comment your code fully and prefix your Matrix class file with comments that include your name, course title, date, and the project number and title. For example:

// Joshua Reyes
// CSIT 114
// 12 November 2007
// Project 6: Prisoner's Dilemma

The Write-up

Once you have implemented the method above, write longer essay detailing your experience programming in a plain text file called memo.txt. (Do not use an editor like MS Word.) Remember that your analysis counts for the majority of your grade. Please write in clear, proper English. As above, be sure to include your name, class, and project title.

Here are some questions to keep in mind:

If you worked with others, explain what each person contributed to your project. Cite others appropriately. Even if you worked with others, the code you pass in ought to be your own.

Turning the Project In

Use a secure FTP client to create a subdirectory of csit114 called project6. Upload your implementation of the PDPlayer interface (You will have to pick an appropriate name for your class.) and memo.txt to that directory by Tuesday, 27 November 2007.