/angry-moran-simulator

A general game-theoretical framework to carry out scientific simulations of populations' evolution according to the Moran model 🧮

Primary LanguageJupyter NotebookMIT LicenseMIT

Build Status Coverage Status Code style: black GitHub license

Moran [Py]cess

scheme.svg

Table of Contents

General information

The following git repository presents a general game-theoretical framework to carry out scientific simulations according to the Moran model. Registering distinct types of individuals together with specification of payoffs between them allows to replicate evolution of the population and observe growth dynamics.

Example results

General Moran Model

figure.png

Simulations of population evolution according to four basic models of game theory: (A) Stag Hunt, (B) Chicken, (C) Prisoners Dilemma, (D) Rock-Paper-Scissors

Moran Model based on 2D neighbourhood

Average payoff for an individual is calcualted based on interactions with 8 direct neighbours of a given individual (2D grid). Periodic boundary conditions are applied.

figure.png

Population snapshots during an evolution according to a Prisoners Dilemma model. Starting from a small subpopulation of Defectors (A, t=0) we observe gradual growth (B, t=50000), (C, t=200000) until the whole population is almost completely overtaken (D, t=500000).

figure.png

Growth curve for the population evolution according a Prisoners Dilemma model.

Moran Model based on 3D neighbourhood

Average payoff for an individual is calcualted based on interactions with 26 direct neighbours of a given individual (3D grid). Periodic boundary conditions are applied.

figure.png

Growth curve for the population evolution according a Prisoners Dilemma model.

Installation instructions

Our software is built as a Python 3 package. Keeping research reproducibility in mind in this repository we provide a recipe for conda virtual environments which would contain all the required dependencies in their proper versions.
We provide a YAML-formatted list of dependencies for the software execution here.
We provide a YAML-formatted list of dependencies for the software development here.
Please inspect the files above for a detailed list of dependencies and their versions.

Download and install Miniconda

To install the latest version of miniconda please execute:

[Linux]:

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
source .bashrc

[macOS]:

wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh
source .bashrc

Clone the repository

Please use git to clone this repository into a desired location (here: moran-simulator) with the following command:

git clone https://github.com/AngryMaciek/angry-moran-simulator moran-simulator

Build and activate a virtual environment

Dedicated environment might be created and activated with the following commands:

cd moran-simulator
conda env create -f env/main.yml
conda activate moranpycess

Install the package

Finally, please install our package into the new virtual environment with the Python package manager:

pip install .

Code documentation

Inspect the documentation & how-to here.

Contributing

This project lives off your contributions, be it in the form of bug reports, feature requests, discussions, or fixes and other code changes. Please refer to the contributing guidelines if you are interested to contribute. Please mind the code of conduct for all interactions with the community.

Contact

For questions or suggestions regarding the code, please use the issue tracker.

License

MIT License