NetLogo banner
 Home Page
 Download
 Models
 Community Models
 Extensions
 User Manual:
  Web version
  Printable version
  Chinese version
 FAQ
 Resources
 Contact Us

NetLogo Models Library:
Sample Models/Social Science/Unverified/Prisoner's Dilemma

Note: This model is unverified. It has not yet been tested and polished as thoroughly as our other models.

(back to the library)

PD Two Person Iterated

[screen shot] Run PD Two Person Iterated in your browser
uses NetLogo 4.0.4
requires Java 1.4.1+
(system requirements)

Note: If you download the NetLogo application, every model in the Models Library (besides the Community Models) is included. If you have trouble running this model in your browser, you may wish to download the application instead.

WHAT IS IT?

This model is an iterated version of the prisoner's dilemma. If you are unfamiliar with the basic concepts of the prisoner's dilemma, please refer to the PD BASIC model found in the PRISONER'S DILEMMA suite.

HOW IT WORKS

The PD BASIC model presents an interesting problem: In order to minimize the overall jail time you would cooperate with your partner and remain silent and not confess. However, the rational choice is to defect against your partner by confessing. If your partner does not confess you will go free. If your partner confesses, you will go to jail for three years, much better than the five you would have earned had you refused to confess. Unfortunately, your partner is in the same position. Acting rationally, you will both be worse off.

The dilemma is made more interesting when you know you will interact with the person again. Let us consider the case where you and a friend are chosen for a research study to play the prisoner's dilemma game; only instead of the payoffs being years of jail time, they are money.

The researchers separate you and your friend into separate rooms allowing communication to occur only through a computer. They give you a sheet with the rules for the iterated prisoner's dilemma that reads as follows:

1. This game will consist of an unspecified number of rounds. At the end of the game, you will receive $1 for each point you have earned.

2. Each round you and your partner will have the opportunity to earn points by choosing to either cooperate (C) or defect (D). Communication will be done only through the computer. The only message you will be able to pass is cooperate or defect. Neither person will see the other's message until both have chosen their action.

3. Your payoff for each round will determined by the actions as follows:

             | Partner's Action
Your |
Action | C D
-------|-----------------
C | 3 0
-------|-----------------
D | 5 1
-------|-----------------

(Note: This way of determining your payoff is the opposite of the PD BASIC model. In PD BASIC, you were awarded something bad- jail time. In this model, you are awarded something good- money.)

Your partner has an identical payoff matrix.

HOW TO USE IT

Buttons:

SETUP: Begin playing the iterated prisoner's dilemma. If you choose to turn the SELECT-COMPUTER-STRATEGY? switch off before pressing this button, the computer's strategy will be randomly chosen at this time.

PLAY ONCE: Play a single round of the prisoner's dilemma with the strategy you have selected.

PLAY REPEATEDLY: Repeatedly play rounds of the prisoner's dilemma between you and the computer. You can change your strategy at any time. If the SELECT-COMPUTER-STRATEGY? switch is on you can also change the computer's strategy at any time.

With both PLAY buttons, the computer's action each round will be displayed in the command center.

Switches:

SELECT-COMPUTER-STRATEGY?: If on, you may select the computer's strategy using the computer strategy slider. If off, the computer's strategy will be randomly chosen from the strategy list found below, excluding the Custom Strategy.

DISPLAY-HISTORY?: Turn on or off messaging in the command center.

Sliders:

HUMAN-STRATEGY - Select your strategy from the list below.

COMPUTER STRATEGY - Select the computer's strategy from the list below.

Strategies:

Random - randomly cooperate or defect
Cooperate - cooperate always
Defect - defect always
Tit-for-Tat - If the opponent cooperates this round cooperate next round. If the opponent defects this round, defect next round. Initially cooperate.
Tit-for-Two-Tats - If the opponent cooperates this round cooperate next round. If the opponent defects two rounds in a row, defect the next round. Initially cooperate.
Unforgiving - Cooperate always unless the opponent defects once. Upon opponent defection retaliate by defecting always.
Custom-Strategy - This strategy is intended to be written by you. It currently defaults to Tit-for-Tat.

Monitors:

HUMAN-SCORE - The total points you have earned

COMPUTER-SCORE - The total points the computer has earned

ITERATION - The number of rounds that have been played

Plots:

AVERAGE SCORE: The average scores of you and the computer each round vs. the number of iterations. This is a good indicator of how well you are doing relative to the maximum possible average of $5 per round.

THINGS TO NOTICE

Should the computer always plays strategy #1 (cooperate), then which strategy for the user results in the highest score?

If the computer always plays strategy #2 (defect), then what is the nature of the average score plot when the user plays strategy #3 - #6 (Tit-for-Tat, Tit-for-Two-Tat, Unforgiving, and Custom Strategy, respectively)? Why does such a nature arise for these combination of strategies?

What is the nature of the plot for average score when the computer always plays strategy #3 and the user plays every startegy except strategy #2 (defect) and strategy #0 (random)? Why does such a curve arise?

THINGS TO TRY

1. Turn the SELECT-COMPUTER-STRATEGY? switch off. Setup the model and play the iterated prisoner's dilemma against the computer. You may choose between selecting your strategy each round using the PLAY ONCE button, or automating your choices each round using the PLAY REPEATEDLY button. What approach wins you the most money?

2. Turn the SELECT-COMPUTER-STRATEGY? switch on. Experiment with playing different strategies against one another. Which strategies do the best? Which do the worst? Why?

3. Repeat task 1 several times. How does the best strategy vary? Based on you experience in task 2, why might this be so?

4. The researchers now tell you that they will double the amount of money the person with the most points gets at the end, but the other person will get nothing. In the event of a tie, each person still receives $1 per point. How does this change your strategy? Why?

5. Describe a real life scenario that is similar to the iterated prisoner's dilemma, preferably one you have experienced. How might the strategies examined here relate to actions taken in that scenario?

EXTENDING THE MODEL

Even the most complex strategies in this model are relatively simple. Surely you can do better. Redefine the CUSTOM-STRATEGY procedure attempting to develop a strategy that can earn a higher score than those presented in the model or a human player. Test it against the other strategies and yourself. What are its strengths? What are its weaknesses? Try to keep improving it.

Examine the PD N-PERSON ITERATED model

NETLOGO FEATURES

Note the use of the turtle variable LABEL to display each turtle's average score in the View.

Note that the SET-ACTION [STRATEGY] procedure uses "[]" to define a parameter that must be passed through when it is called.

RELATED MODELS

PD Basic
PD N-Person Iterated
PD Basic Evolutionary

CREDITS AND REFERENCES

To refer to this model in academic publications, please use: Wilensky, U. (2002). NetLogo PD Two Person Iterated model. http://ccl.northwestern.edu/netlogo/models/PDTwoPersonIterated. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 2002 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/PDTwoPersonIterated for terms of use.

(back to the NetLogo Models Library)