{"id":20572952,"url":"https://github.com/giakoumoglou/game_theory_spatial_pd","last_synced_at":"2025-04-14T17:23:34.163Z","repository":{"id":169781137,"uuid":"271260558","full_name":"giakoumoglou/game_theory_spatial_pd","owner":"giakoumoglou","description":"[Nature 1992] Evolutionary Games and Spatial Chaos","archived":false,"fork":false,"pushed_at":"2024-07-15T14:42:30.000Z","size":3691,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T06:04:18.339Z","etag":null,"topics":["evolutionary-games","game-theory","martin","matlab","nowak","simulation"],"latest_commit_sha":null,"homepage":"https://www.nature.com/articles/359826a0","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giakoumoglou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-10T11:38:47.000Z","updated_at":"2025-02-17T12:49:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"46ba5d7e-f1f1-4c91-b9bb-35da0c3719d2","html_url":"https://github.com/giakoumoglou/game_theory_spatial_pd","commit_stats":null,"previous_names":["giakou4/game_theory_spatial_pd","giakoumoglou/game_theory_spatial_pd"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giakoumoglou%2Fgame_theory_spatial_pd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giakoumoglou%2Fgame_theory_spatial_pd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giakoumoglou%2Fgame_theory_spatial_pd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giakoumoglou%2Fgame_theory_spatial_pd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giakoumoglou","download_url":"https://codeload.github.com/giakoumoglou/game_theory_spatial_pd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248924360,"owners_count":21184065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["evolutionary-games","game-theory","martin","matlab","nowak","simulation"],"created_at":"2024-11-16T05:24:51.698Z","updated_at":"2025-04-14T17:23:34.120Z","avatar_url":"https://github.com/giakoumoglou.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=https://c.tenor.com/i4cgk6ejhBMAAAAC/chess.gif\u003e\n\u003c/div\u003e  \n\n# 1. Game Theory: Spatial Prisoner's Dilemna\n\n[![made-with-matlab](https://img.shields.io/badge/Made%20with-MATLAB-cb6015)](https://www.mathworks.com/products/matlab.html)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/giakou4/game_theory_spatial_PD/LICENSE)\n[![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)\n[![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)\n[![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)\n[![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)\n[![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)\n[![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)\n\nThis 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.\n\n## 1.1 The Spatial Prisoner's Dilemna\n\nIn 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.\n\n## 1.2 The Prisoner's Dilemna Game\n\nThe PD can be formulated in tabular form as follows, where T \u003e R \u003e P ≥ S\n\n\u003cdiv align=\"center\"\u003e\n\n|          |      C     |  D |\n|----------|:-------------:|------:|\n| C |  R=1 | S=0|\n| D | T=b\u003e1 |    P=0 |\n\n\u003c/div\u003e\n\n## 1.3 Chaos in the Spatial PD game\n\nThe dynamical behavior of the system depends on the parameter b.\n\n* (b \u003e 1.8) 2x2 or larger cluster of D will continue to grow at the corners.\n* (b \u003c 1.8) big D cluster will shrink\n* (b \u003c 2) 2x2 or larger cluster of C will continue to grow\n* (b \u003e 2) C clusters do not grow\n* (2 \u003e b \u003e 1) C clusters can grow in regions of D and vice versa\n\nChaos persists in shifting patterns C → D, D → C, D → D, C → C\n\n## 1.4 Some Examples\n\nColor assignments:\n* C → C blue\n* D → D red\n* D → C yellow\n* C → D green\n \nfc = frequency of cooperators  \nlimT→inf fc = 12log2 – 8 = 0.318 can be proven  \nAlthough this approximation always works when we have 10% random D and 1.8\u003cb\u003c2 we don’t know why it does so!\n\n### 1.4.1 10% D randomly at 99x99 lattice, T=200, b=1.6\n\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201708-03e20e50-56ea-4cf8-bc3a-bd4228dce3d4.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201760-7302bf74-36b0-447f-b45e-4a94128c49a8.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n### 1.4.2 10% D randomly at 99x99 lattice, T=200, b=1.9\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201826-1942f801-b7cf-4bbf-b09c-fe2a071c6908.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201835-584f44c6-56d6-410b-b97a-eaebe52ae3fa.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n### 1.4.3 10% D randomly at 99x99 lattice, T=200, b=2.5\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201846-90b35462-127c-4d08-a3c4-769ef73700dd.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155204559-de01b018-ea13-40b7-a0f7-5f2004abd880.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n### 1.4.4 1 D at the center of the 99x99 lattice, T=2000, b=1.9\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201865-d4ee3265-b2e4-4c8f-a72b-da733f0a5bbf.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201872-1c087247-8118-44e7-8206-6b7d7c7a3ee4.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n### 1.4.5 8 Neighbors (thus self interaction exluded)\n\n* “Interesting Region\" is 5/3\u003eb\u003e8/5 (here b=1.62 with 10% random D)\n*  Similar symmetric patterns \n* fc → 0.299\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201888-3c6b2419-b0ee-4a3e-847b-5d9bf70c92f8.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201895-85bce395-2909-4144-b8be-8f1ea9a344f7.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n### 1.4.6 5 Neighbors (including self)\n\n* “Interesting Region” is 2\u003eb\u003e5/3 (here b=1.8 with 10% random D)\n* Similar symmetric patterns \n* fc  → 0.374\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201919-91048e86-9421-402d-be25-c654174ef531.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201925-c72df11d-5540-4349-90ad-7caf72dc5362.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n### 1.4.7 4 Neighbors (thus self interaction exluded)\n\n* “Interesting Region” is 3/2\u003eb\u003e4/3 (here b=1.4 with 10% random D)\n* Similar symmetric patterns \n* fc → 0.374\n\n\u003cdiv align=\"center\"\u003e\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201940-ad524a6d-0977-4871-bcd1-4e486be19d7e.png\" width=\"500\" height=\"400\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/57758089/155201946-5b227b02-938f-4826-9e59-0fd0ac904f95.png\" width=\"500\" height=\"400\"\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n## 1.5 Conclusions and Applications\n\nAlthough 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.\nSuch 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.\n\n## 2. Code\n\n* ```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:\n  * ```b```: Defection payoff\n  * ```torus```: If ~0, define the lattice as a torus, 0 else\n  * ```p```: Proportion of defectors in [0, 1]\n  * ```self_interaction```: If 0, self interaction is excluded, if ~0, included\n  * ```rounds```: Number of rounds/generation/time step\n  * ```n``` : Squared lattice side size\n  * ```printLattice``` : If 1, prints the lattice over rounds\n  * ```printFc```: If 1, prints the frequency of cooperators over rounds\n  * ```limit```: If \u003e0, prints limit in fc as a horizontal line\n* ```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:\n  * ```b```: Defection payoff\n  * ```torus```: If ~0, define the lattice as a torus, 0 else\n  * ```p```: Proportion of defectors in [0, 1]\n  * ```self_interaction```: If 0, self interaction is excluded, if ~0, included\n  * ```rounds```: Number of rounds/generation/time step\n  * ```n```: Squared lattice side size\n  * ```flag```: If 1, places a single D in the center of the nxn lattice (n must be odd to work correctly)\n  * ```printLattice```: If 1, prints the lattice over rounds\n  * ```printFc```: If 1, prints the frequency of cooperators over rounds\n  * ```limit```: If \u003e0, prints limit in fc as a horizontal line\n* ```main.m```: Includes the reproduction of the figures of the paper and much more!\n\n## 3. Support\nReach out to me:\n- [Giakoumoglou's email](mailto:nikolaos.giakoumoglou@gmail.com \"nikolaos.giakoumoglou@gmail.com\")\n\n## 4. Citation\n* Nowak, M., May, R. Evolutionary games and spatial chaos. Nature 359, 826–829 (1992). https://doi.org/10.1038/359826a0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiakoumoglou%2Fgame_theory_spatial_pd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiakoumoglou%2Fgame_theory_spatial_pd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiakoumoglou%2Fgame_theory_spatial_pd/lists"}