Spatial Prisoner's Dilemma

Spatial Prisoner's Dilemma preview image

1 collaborator

Default-person David Sousa (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.0 • Viewed 419 times • Downloaded 17 times • Run 0 times
Download the 'Spatial Prisoner's Dilemma' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


THEORY

Game theory has been extensively used to study cooperation and competition among individuals in social, political and economic contexts (eg: Nash, 1950).

In evolutionary biology, cooperation is based on reciprocal altruism. In terms of game theory: the relationship between two individuals repeatedly exposed to symmetrical reciprocal situations is exactly analogous to the Prisoner's Dillema (PD) (Trivers, 1971).

An organism does not need a brain to employ a strategy, however, game-playing is more or less rich and complex depending on the cognitive abilities of the players involved. Independently of the complexity of the strategy that an organism employs, for a cooperative strategy to evolve and be maintained in populations where non-cooperators are also present, it must be robust, stable and initially viable (Axelrod & Hamilton, 1981).

Not all biological entities that exhibit cooperative interactions evidentiate cognitive abilities such as remembering past interactions, recognizing players or anticipating future encounters. Nowak and May proposed an approach which considers only two kinds of players: those who allways cooperate and those who allways deffect. The players are placed in a two dimensional array of patches, each being cooperative or non-cooperative. Each round, every individual plays de PD with a fixed predefined number of immediate neighbors, and after that, each site in the lattice is occupied either by its original owner or by one of the neighbors, depending on who scores the highest total in that round. The authors have shown that for a wide range of values for the parameters that characterize the advantage of cheating, a simple and purely deterministic spatial version of the PD can generate self-organized spatial patterns that evolve more or less chaotically. (Nowak and May, 1992).

A more realistic assumption than copying the strategy of the best performing neighbor (deterministic update rule) is to allow for "probabilistic winning" (Nowak et al, 1994). But whether the update rule is deterministic or probabilistic, in general, cooperators and non-cooperators can persist for a wide range of values of the cheating advantage parameter. Spatial arrays promote the coexistence of strategies. In particular, cooperation can persist without any evidence of cognitive complexity.

WHAT IS IT

This model investigates the evolution and maintenance of cooperation in spatially structured populations.

HOW IT WORKS

This model is based on Nowak and May (1992), Nowak et al. (1994) and the Netlogo model PD Basic Evolutionary Wilensky, U. (2002). Each round, every individual patch plays the prisoner's dilemma with a fixed predefined number of immediate neighbors (8 or 4), and after that, each site in the lattice is occupied either by its original owner or by one of its neighbors. Deterministic and probabilistic update rules can be tested, as well as stochasticity m, and the cheating advantage b. The update is asynchronous. See the references for more details.

HOW TO USE IT

Use the slider "cooperators" and the button "setup" to start with a random spatial distribution of cooperators in the lattice. Or use the button "setup-1-at-the-center" to start with a non-cooperator in a sea of cooperators. Click "go once" to run once (one tick/generation), or click "go" to run forever.

The user can manipulate the cheating-advantage b of non-cooperators, the number of neighbors ("n-neighbors") that each site interacts with, and the "update-rule".

If the probabilistic "update-rule" is selected, the user can manipulate the stochasticity value m. Selecting the deterministic update rule is equivalent to m = ∞.

Blue is a cooperative site (C); red a non-cooperative site (D - for defection); yellow - a change from C to D; green - a change from D to C.

The plots show the number of sites in each class, and the evolution of the populations of cooperators and defectors. One tick is the time unit corresponding to one generation.

THINGS TO NOTICE

For particular combinations of the values of the cheating advantage and stochasticity it can be shown that spatial arrays promote the coexistence of strategies. Can you find these values?

THINGS TO TRY

1) Setup one defector at the center, select the deterministic update rule and run with both 8 and 4 neighbors. See the beautiful patterns arising.

2) Setup 50% of cooperators, select the probabilistic update rule and run with 8 neighbors. Observe what happens during and after 200 generations using different combinations of the cheating advantage parameter and the stochasticity parameter. Sometimes defectors "win". Sometimes cooperators "win". And sometimes cooperators survive in clusters, while defectors survive in unconnected or connected short lines, surrounded or not by constantly changing strategy sites.

2.1) See what happens with null stochasticity for any value of the cheating advantage parameter.

RELATED MODELS

PD Basic Evolutionary

CREDITS

The present model was coded by David N. Sousa. Feel free to contact.

REFERENCES

Axelrod, R., & Hamilton, W. (1981). The evolution of cooperation. Science, 211(4489), 1390-1396.

Nash Jr, John F. "The bargaining problem." Econometrica: Journal of the Econometric Society (1950): 155-162.

Nowak, M. A., & May, R. M. (1992). Evolutionary games and spatial chaos. Nature, 359(6398), 826-829.

Nowak, M. A., Bonhoeffer, S., & May, R. M. (1994). Spatial games and the maintenance of cooperation. Proceedings of the National Academy of Sciences, 91(11), 4877-4881.

Trivers, R. L. (1971). The Evolution of Reciprocal Altruism. The Quarterly Review of Biology, 46(1), 35-57.

Wilensky, U. (2002). NetLogo PD Basic Evolutionary model. http://ccl.northwestern.edu/netlogo/models/PDBasicEvolutionary. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

patches-own [
  cooperate?
  old-cooperate?
  score
  color-class
  Prob
]

to setup
  clear-all
  ask patches [setup-cooperation false update-color]
  ask n-of (cooperators * (count patches)) patches [setup-cooperation true update-color]
  reset-ticks
  update-plot
end 

to setup-1-at-the-center
  clear-all
  ask patches [
    setup-cooperation true
    update-color
  ]
  ask patch 0 0 [
    setup-cooperation false
    update-color
  ]
  reset-ticks
  update-plot
end 

to setup-cooperation [value]
  set cooperate? value
  set old-cooperate? value
end 

to go
  ask patches [update]
  tick
  update-plot
end 

to-report neighborsN
  ifelse n-neighbors = 8 [report (patch-set neighbors self)][report (patch-set neighbors4 self)]
end 

to update
  ask neighborsN [
    ifelse cooperate?
    [set score (count neighborsN with [cooperate? = true])]
    [set score (count neighborsN with [cooperate? = true]) * b]
    set old-cooperate? cooperate?
  ]
  ifelse update-rule = "deterministic" [
    if [score] of max-one-of neighborsN [score] > score [
      set cooperate? [cooperate?] of max-one-of neighborsN [score]
    ]
  ][
    let numberp sum (map [ ?1 -> ?1 ^ m ] [score] of neighborsN with [cooperate?])
    let numberq sum (map [ ?1 -> ?1 ^ m ] [score] of neighborsN)
    ifelse numberq = 0 [set Prob 0][set Prob (numberp / numberq)]
    ifelse random-float 1 <= Prob [set cooperate? true][set cooperate? false]
  ]
  update-color
end 

to update-color
  ifelse old-cooperate?
    [ifelse cooperate?
      [set pcolor blue
       set color-class 1]
      [set pcolor yellow
       set color-class 3]
    ]
    [ifelse cooperate?
      [set pcolor green
       set color-class 4]
      [set pcolor red
       set color-class 2]
    ]
end 

to update-plot
  set-current-plot "Cooperation/Defection numbers"
  plot-histogram-helper "cc" blue
  plot-histogram-helper "dd" red
  plot-histogram-helper "cd" green
  plot-histogram-helper "dc" yellow
end 

to plot-histogram-helper [pen-name color-name]
  set-current-plot-pen pen-name
  histogram [color-class] of patches with [pcolor = color-name]
end 

There is only one version of this model, created almost 5 years ago by David Sousa.

Attached files

File Type Description Last updated
Spatial Prisoner's Dilemma.png preview Preview for 'Spatial Prisoner's Dilemma' almost 5 years ago, by David Sousa Download

This model does not have any ancestors.

This model does not have any descendants.