The Computational Beauty of Nature
Source code

sipd

simulate the spatial iterated Prisoner's Dilemma

Full screen →

sipd -help
  or
sipd   [-width integer] [-height integer] [-steps integer]
       [-rounds integer] [-seed integer] [-CC double] [-CD
       double]  [-DC  double] [-DD double] [-Iallc double]
       [-Itft  double]  [-Irand  double]  [-Ipav   double]
       [-Ialld   double]  [-rcp  double]  [-noise  double]
       [-mute  double]  [-stats]  [-inv]  [-mag   integer]
       [-term string]

Simulates and plots the spatial iterated Prisoner's Dilemma over time according to the specified parameters. Each cell in a grid plays a specific strategy against its eight neighbors for several rounds. At the end of the last round, each cell copies the strategy of its most successful neighbor, which is then used for the next time step. Possible strategies include “Always-Cooperate,” “Always-Defect”, “Random,” “Pavlov,” and “Tit-for-Tat.”

The spatial iterated Prisoner's Dilemma is simulated and plotted over time according to the specified parameters. Each cell in a grid plays a specific strategy against its eight neighbors for several rounds. At the end of the last round, each cell copies the strategy of its most succesful neighbor, which is then used for the next time step. Possible strategies include 'Always Cooperate,' 'Always Defect,'

Payoffs

The payoff matrix for the Prisoner's Dilemma game is usually expressed as: Player B's Move +-----------+-----------+ Player A's Move | cooperate | defect | +-----------+-----------+-----------+ | cooperate | CC, CC | CD, DC | +-----------+-----------+-----------+ | defect | DC, CD | DD, DD | +-----------+-----------+-----------+

where the table entries are (A's payoff, B's payoff) and CC, CD, DC, and DD are the reward, sucker, temptation, and punish payoffs, respectively. For each of these four outcomes you will probably want the payoffs to reflect the relationships:

(DC > CC > DD > CD) and ((CD + DC) / 2 < CC).

Miscellany

The option for the probability of mutation (-mute) corresponds to the act of a cell spontaneously changing to a

randomly selected strategy independent of the outcome of the most recent set of rounds.

random noise (via the -noise option) manifests itself as a cell making a randomly selected move in a single round. In this case, both the cell whose action was altered as well as that cell's opponents "remember" what the random move was on the next round.

The value supplied with the -term option may be "none," in which case no graphic output is performed. This is useful if you simply want the statistics to be calculated for each time step (via the -stats option).

The initial population levels for all strategies will be normalized, so the scaling of the option values is irrelevant.

Bugs

No sanity checks are performed to make sure that any of the options make sense.

Options

-widthWidth of world.100
-heightHeight of world.100
-stepsNumber of steps to simulate.10000000
-roundsNumber of rounds per step.5
-seedRandom seed for initial state.0
-CCReward Payoff.3.0
-CDSucker Payoff.0.0
-DCTemptation Payoff.5.0
-DDPunish Payoff.1.0
-IallcInitial population of All-C.0.2
-ItftInitial population of TFT.0.2
-IrandInitial population of Random.0.2
-IpavInitial population of Pavlov.0.2
-IalldInitial population of All-D.0.2
-rcpProbability of C for Random strategy.0.5
-noiseProbability of noise.0.0
-muteProbability of mutation.0.0
-statsPrint statistics?False
-invInvert all colors?False
-magMagnification factor.1
-termHow to plot points.None

sipd.c on GitHub