PyIPD


PyIPD is a Python module for playing around with the Iterated Prisoner's Dilemma. It's based on the computer tournament run by Robert Axelrod and described in his book The Evolution of Co-operation. Most of the decision rules included here are re-coded (with varying degrees of success) from this source.

The Prisoner's Dilemma is a two-player, two-option game. The options available to each player are co-operate or defect. Played with the standard payoffs, possible results are:

  1. Both co-operate, and get 3 points each.
  2. One co-operates and the other defects. The co-operator gets no points (the sucker's payoff) while the defector gets a juicy 5 points.
  3. Both defect, and get only 1 point each.

Cold, calculating logic says the best move is to always defect: whatever the opponent does, you always get more points. The dilemma is that when your opponent deduces the same, you're both going to get only 1 point each. But if only you had both co-operated, you'd both be 2 points richer!

The main point of Robert Axelrod's book is that even though in a one-shot Prisoner's Dilemma defection is the only logical outcome, when the players play the game repeatedly those prepared to co-operate will do better, because there is the possibility of building up mutual trust. Axelrod ran a series of contests which pitted different playing strategies against each other, with some pretty interesting results.

This module allows you to run your own versions of these contests. Here's some example output from the round-robin tournament:

263.1  NPF  Forgiving_Tit_For_Tat
255.1  .PF  Downing
254.3  NPF  Tit_For_Two_Tats
254.2  NP.  Tit_For_Tat
253.5  NPF  Revised_State_Transition
245.2  NPF  Soft_Majority
240.3  NP.  Two_Tits_For_Tat
240.3  .PF  Tester
238.1  NPF  Revised_Downing
233.4  NP.  Spiteful
232.6  .PF  Periodic_CCD
228.9  N.F  All_C
227.2  .PF  Periodic_CD
225.6  NPF  Pavlov
223.6  .PF  Random
220.9  .P.  Tranquilizer
209.7  .P.  Suspicious_Tit_For_Tat
205.0  .P.  Joss
200.0  .PF  Periodic_DDC
194.8  .PF  Hard_Majority
178.0  .P.  All_D


Mail me at zondo42@googlemail.com | Back to top | Site map | Last modified: Fri Dec 5 17:51:09 2008

All content in this site is distributed under the GNU Free Documentation License

memebot.png muse-made-with.png eyes.png gfx_by_gimp.png anybrowser.png