CSCI 151 Lab 2: Prisoner's Dilemma
Overview
In this lab, we will develop computational strategies for the Iterated Prisoner's Dilemma.Materials
- Eclipse
Setup
Eclipse
- First, install the Java 8 Development Kit (JDK).
- Then install Eclipse:
- If you are potentially interested in learning how to use Java to make graphical user interfaces for one of your projects, try the Eclipse All-in-One JavaFX installer. (The downside is this may be more complicated to get working.)
- Otherwise, visit the normal Eclipse downloads page. As of this writing (29 August 2017) the latest release is Eclipse Oxygen.
Project
- Download the skeleton for this project.
- Extract the file to your desired location.
- Open Eclipse.
- Select File > New > Java Project
- When the "Create a Java Project" dialog opens up, de-select "Use default location".
- Then click "Browse". Navigate to the location of your extracted archive.
- Click "Finish" to create the project.
- Go to the Package Explorer, and make sure the desired files are in place.
Description
The Prisoner's Dilemma is a classic example in Economic Game Theory. Two burglars are taken in by police. They are simultaneously interrogated in separate rooms. Each burglar must decide whether to COOPERATE with each other to stay quiet, or DEFECT and talk to the police.
- If they both COOPERATE, then they will only spend a small time in prison.
- If one DEFECTs and the other COOPERATEs, the defector is set free while the cooperator goes to prison for a long time.
- If they both DEFECT, then both will spend a medium amount of time in prison
It is temping to try and DEFECT when the other player COOPERATEs, but they will have the same idea, and the rational end result is that both DEFECT. So much for cooperation.
However, if we put the burglars in this situation repeatedly, without knowing when the process will end, a different outcome is possible. This is known as the Iterated Prisoner's Dilemma. Now, burglars can start to formulate strategies of how to play based on the history of interactions with the other player.
In this lab, you will be coding up different strategies for players. We will assign points for the different outcomes as follows, with higher points being better for the players. (negative points imply time in prison)
- If they both COOPERATE, each player gets +10.
- If one DEFECTs and the other COOPERATEs, the defector gets +15 while the cooperator gets -10.
- If they both DEFECT, then both will get -5.
Making Strategies
To create a strategy, create a class that implements the Strategy interface, and place it in thestrategies
package. Three
simple examples have been
provided.
Your grade will depend upon the total number of strategies you create, subject to the following constraints:
- No strategy may duplicate the behavior of any of the three provided strategies.
- Every strategy must use some persistent state (that is, one or more fields).
- Each strategy should be named after the author. For example, a student
named John Smith would create
JohnSmith1.java
,JohnSmith2.java
, and so forth. - To earn an "A", at least one strategy must use an array.
To run a simulation with your strategies, execute the Simulator
class.
What to Hand In
Create a .zip or .tgz file containing all of your strategy files (the .java files you wrote), and submit it by emailing it to yorgey@hendrix.edu with the following subject line: CSCI 151: Lab 2: Prisoner's Dilemma You must use exactly this subject line, or your lab may not be graded.Grading
- To earn a D, complete one strategy.
- To earn a C, complete three strategies.
- To earn a B, complete four strategies.
- To earn an A, complete five strategies (at least one of which must use an array).
- The authors of the top three winning programs will receive a grade of 100.
- The instructor reserves the right to also award an 100 to any particularly interesting or creative strategies.
© Mark Goadrich, Hendrix College