Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

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

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.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.