An open API service indexing awesome lists of open source software.

https://github.com/giakoumoglou/game_theory_spatial_pd

[Nature 1992] Evolutionary Games and Spatial Chaos
https://github.com/giakoumoglou/game_theory_spatial_pd

evolutionary-games game-theory martin matlab nowak simulation

Last synced: about 1 year ago
JSON representation

[Nature 1992] Evolutionary Games and Spatial Chaos

Awesome Lists containing this project

README

          



# 1. Game Theory: Spatial Prisoner's Dilemna

[![made-with-matlab](https://img.shields.io/badge/Made%20with-MATLAB-cb6015)](https://www.mathworks.com/products/matlab.html)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/giakou4/game_theory_spatial_PD/LICENSE)
[![View Spatial Prisoners Dilemna on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/76781-spatial-prisoners-dilemna)
[![forks](https://img.shields.io/github/forks/giakou4/game_theory_spatial_PD.svg)](https://img.shields.io/github/forks/giakou4/game_theory_spatial_PD.svg)
[![stars](https://img.shields.io/github/stars/giakou4/game_theory_spatial_PD.svg)](https://img.shields.io/github/stars/giakou4/game_theory_spatial_PD.svg)
[![issues-open](https://img.shields.io/github/issues/giakou4/game_theory_spatial_PD.svg)](https://img.shields.io/github/issues/giakou4/game_theory_spatial_PD.svg)
[![issues-closed](https://img.shields.io/github/issues-closed/giakou4/game_theory_spatial_PD.svg)](https://img.shields.io/github/issues-closed/giakou4/game_theory_spatial_PD.svg)
[![size](https://img.shields.io/github/languages/code-size/giakou4/game_theory_spatial_PD)](https://img.shields.io/github/languages/code-size/giakou4/game_theory_spatial_PD)

This script is a simulation of Martin A. Nowak and Robert M. May paper about "Evolutionary Games and Spatial Chaos" 1992. It is created by N. Giakoumoglou, M. Demetriou and P. Manouselis for a presentation in Game Theory course in May 2020.

## 1.1 The Spatial Prisoner's Dilemna

In spatial prisoner's dileman there are two players those who always cooperate, C, and those who always defect, D. We place those players on a two dimensional lattice (grid), each lattice site is occupied either by a C or a D. In each round of the game (each generation), the players play the PD game with nearest neighboring sites and with one's own site (thus we define these sites as a territory – a 3x3 grid). The score for each player is the sum of the payoffs in these encounters with neighbors. At the start of the next generation, each lattice-site is occupied by the player with the highest score among the previous owner and the immediate neighbors. Boundaries are fixed but we can also define the lattice as a torus. Conclusions we will deduct remain true if players interact only with the four orthogonal neighbors in square lattices or self-interactions are included.

## 1.2 The Prisoner's Dilemna Game

The PD can be formulated in tabular form as follows, where T > R > P ≥ S

| | C | D |
|----------|:-------------:|------:|
| C | R=1 | S=0|
| D | T=b>1 | P=0 |

## 1.3 Chaos in the Spatial PD game

The dynamical behavior of the system depends on the parameter b.

* (b > 1.8) 2x2 or larger cluster of D will continue to grow at the corners.
* (b < 1.8) big D cluster will shrink
* (b < 2) 2x2 or larger cluster of C will continue to grow
* (b > 2) C clusters do not grow
* (2 > b > 1) C clusters can grow in regions of D and vice versa

Chaos persists in shifting patterns C → D, D → C, D → D, C → C

## 1.4 Some Examples

Color assignments:
* C → C blue
* D → D red
* D → C yellow
* C → D green

fc = frequency of cooperators
limT→inf fc = 12log2 – 8 = 0.318 can be proven
Although this approximation always works when we have 10% random D and 1.8




### 1.4.2 10% D randomly at 99x99 lattice, T=200, b=1.9






### 1.4.3 10% D randomly at 99x99 lattice, T=200, b=2.5






### 1.4.4 1 D at the center of the 99x99 lattice, T=2000, b=1.9






### 1.4.5 8 Neighbors (thus self interaction exluded)

* “Interesting Region" is 5/3>b>8/5 (here b=1.62 with 10% random D)
* Similar symmetric patterns 
* fc → 0.299






### 1.4.6 5 Neighbors (including self)

* “Interesting Region” is 2>b>5/3 (here b=1.8 with 10% random D)
* Similar symmetric patterns 
* fc  → 0.374






### 1.4.7 4 Neighbors (thus self interaction exluded)

* “Interesting Region” is 3/2>b>4/3 (here b=1.4 with 10% random D)
* Similar symmetric patterns 
* fc → 0.374






## 1.5 Conclusions and Applications

Although the details of the patterns depend on the value of b, a wide range of values leads to chaotic patterns whose nature is almost always independent of the initial proportions of C and D.
Such deterministically generated spatial structures may model and describe pre-biotic evolution of cooperation (among molecules, cells or organisms) as well as Turing models and 2-state Ising models.

## 2. Code

* ```Spatial_PD_4_NN.m```: In this implementation, the spatial PD game is played among 4 orthogonal neighbours. One can define the following parameters for the PD game:
* ```b```: Defection payoff
* ```torus```: If ~0, define the lattice as a torus, 0 else
* ```p```: Proportion of defectors in [0, 1]
* ```self_interaction```: If 0, self interaction is excluded, if ~0, included
* ```rounds```: Number of rounds/generation/time step
* ```n``` : Squared lattice side size
* ```printLattice``` : If 1, prints the lattice over rounds
* ```printFc```: If 1, prints the frequency of cooperators over rounds
* ```limit```: If >0, prints limit in fc as a horizontal line
* ```Spatial_PD_8_NN.m```: In this implementation, the spatial PD game is played among 4 orthogonal neighbours. One can define the following parameters for the PD game:
* ```b```: Defection payoff
* ```torus```: If ~0, define the lattice as a torus, 0 else
* ```p```: Proportion of defectors in [0, 1]
* ```self_interaction```: If 0, self interaction is excluded, if ~0, included
* ```rounds```: Number of rounds/generation/time step
* ```n```: Squared lattice side size
* ```flag```: If 1, places a single D in the center of the nxn lattice (n must be odd to work correctly)
* ```printLattice```: If 1, prints the lattice over rounds
* ```printFc```: If 1, prints the frequency of cooperators over rounds
* ```limit```: If >0, prints limit in fc as a horizontal line
* ```main.m```: Includes the reproduction of the figures of the paper and much more!

## 3. Support
Reach out to me:
- [Giakoumoglou's email](mailto:nikolaos.giakoumoglou@gmail.com "nikolaos.giakoumoglou@gmail.com")

## 4. Citation
* Nowak, M., May, R. Evolutionary games and spatial chaos. Nature 359, 826–829 (1992). https://doi.org/10.1038/359826a0