Overview

This is PyIPD, 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, for those who don't already know, is a two-player, two-option game. The options available to each player are `co-operate' (be nice) or `defect' (be nasty). 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 -- you always get more than you would have done by co-operating. 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 be nicer 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.