Home » Staff » Homepages » Homepage of dr. Hans Pruijt » Publications » Prisoner’s Dilemma Case Study: A Tool for Learning to Apply the Power of ICT to Sociology

Prisoner’s Dilemma Case Study: A Tool for Learning to Apply the Power of ICT to Sociology

Hans Pruijt 2003

For a fuller exposition see: Pruijt, H., 2000 "Programming the Evolution of Cooperation" in Social Science Computer Review, Vol. 18 No. 1, Spring, 77-81

There seems to be a dearth of case studies that meet the criteria of relevance with respect to social theory and of technical simplicity. A case study, designed with these criteria in mind, will be presented below. Its subject is the Prisoner's Dilemma. The Prisoner's Dilemma is relevant to social science students because of its importance in game theory, collective behavior, policy studies, negotiation theory, industrial relations and the debate on social capital.

Tournaments for computer programs played a key part in the research on the repeated Prisoner's Dilemma (Axelrod 1984). This fact establishes the link between the Prisoner's Dilemma and programming.

In the tournaments, the overall winner turned out to be the most simple of all competing programs. In the case of the Prisoner's Dilemma, at least as presented by Axelrod (1984), there is a negative relationship between program complexity and theoretical relevance.

The fact that knowledge of the Prisoner's Dilemma is indispensable for social science professionals, that computer programming made an especially relevant contribution to it (Coleman 1990: 210-211), and the negative relationship between relevance and technical complexity make it a promising basis for a teaching tool in the shape of a case study that unites programming and social theory.

The case study, following Axelrod (1984), involves a game for two players. Each round in the game consists of each player choosing whether to cooperate ("C") or not ("N"). The payoff for each player depends on the actions of both players, according to table 1.

Action Player 1

Action Player 2

Score Player 1

Score Player 2

C

C

3

3

N

N

1

1

C

N

0

5

N

C

5

0

Table 1: payoffs in the game

It is possible to introduce the case study by asking a group of students to play this game, after dividing themselves up into pairs (or groups of three, in which one student keeps the scores). Each player can use a coin to signal the choice made for cooperation or non-cooperation.

Heads indicate cooperation, tails non-cooperation. Players lay their coin on the table in such a way that the other player cannot see the choice made, and then both players reveal their choices simultaneously. For a short but meaningful game, ten rounds are sufficient. Afterwards, the lecturer can collect some of scores, and then ask the students about the strategies that they had used. When I did this, students reported the following strategies:

  • purely altruistic

  • purely non-cooperative, guaranteeing a minimum of ten points

  • random

  • mirroring the other player's behavior

The lecturer can then initiate a discussion based on the question: suppose that all strategies compete against one another, which one will the most effective in the long run?

This is the question that motivated the tournaments, in which all kinds of people were invited to send in programs. The overall winner was the program Tit-for-Tat. In the first round it is always cooperative. In the next rounds Tit-for-Tat always matches the competitor's action in the preceding round. Tit-for-Tat did not win individual matches, but collected the highest number of points across the tournaments.

Visual Basic for Applications (VBA), the built-in macro language in Microsoft Office products, provides an accessible way for experimenting with different strategies for playing the repeated the Prisoner's Dilemma game. Excel is a particularly suitable platform, because of the ability of VBA programs to access cells in the worksheet. This allows the use of cells as visible variables.

In VBA in Excel, Tit-for-Tat takes five lines of code. Spreadsheet cells are referenced as Cells(Row, Column). Tit-for-Tat writes its actions in column 2, the competing program in column 3. For lay-out reasons, the game starts in row 6. This is the code for Tit-for-Tat:

If Round = 1 Then

Let Cells(5 + Round, 2) = "C"

Else

Let Cells(5 + Round, 2) = Cells(4 + Round, 3)

End If

The companion Excel worksheet contains a complete program, including a random playing competitor and necessary score-keeping. The entire program is placed under a command button on the worksheet. The program illustrates all major programming constructs.

Download the companion Excel worksheet (Note: when prompted, choose “Enable Macros”.)

Experiments may include modifying the program in order to test other strategies. Suitable are all strategies that students developed in the "coins game". Alternatively, students can insert into the program the strategy "Pavlov" that was developed using evolutionary simulations (Nowak and Sigmund 1993). This strategy is as simple as "Tit-for-Tat". Pavlov cooperates if both players cooperated in the previous round or if in the previous round both players did not cooperate. Pavlov can be seen as more robust than Tit-for-Tat when we allow for the possibility that players make mistakes. Suppose that two players both play Tit-for-Tat. When one player makes a mistake, a long series of N-N's follows. Pavlov can also exploit unconditional cooperators. When an unconditional cooperator makes one mistake, Pavlov starts systematic exploitation. The idea is that when a population contains a lot of unconditional cooperators, it becomes vulnerable to an invasion by always-exploiters.

References

Axelrod, R. (1984). The evolution of cooperation. New York, Basic Books.

Coleman, J. S. (1990). Foundations of Social Theory. Cambridge, MA, Harvard University Press.

Nowak, M. and K. Sigmund (1993). “A Strategy Of Win Stay, Lose Shift That Outperforms Tit-For-Tat In The Prisoners-Dilemma Game.” Nature 364(1 July 1993): 56-58.