Giter Site home page Giter Site logo

evol_pris_dilem's Introduction

Evolutionary Game Theory: Agent-Based Simulations in R

This directory contains R scripts that run agent-based evolutionary game theory simulations. The basic structure of the simulations is as follows:

  • Simulations are run over discrete "time periods".
  • In each time period, agents are randomly partitioned into pairs.
  • Each pair of agents plays a cooperate-defect style game (similar to, but not necessarily the same as the prisoner's dilemma), whose outcome determines each agent's chance of surviving to the next time period.
    • Each agent's "play" (decision to cooperate or defect) depends on their and their opponent's 2-period history of cooperate/defect decisions, together with that agent's "genetic strategy".
      • A genetic strategy is a binary vector that determines, in each of the 2^(2+2) = 16 possible 2-period histories for a pair of agents, what an agent's decision will be.
      • I use the term "genetic strategy" because this length-16 binary vector can be mutated, i.e. when an agent self-replicates there might be an error copying any of his 16 binary genes (so that 0000000000000000 might be replicated as 0010000000000000).
    • In this project, the following protocol is used:
      • 0 = cooperate
      • 1 = defect
  • Some agents die, according to their survival probability.
  • Some of the surviving agents reproduce, i.e. self-replicate.
  • When agents self-replicate, each of their 16 binary genes has a chance of being 'mutated', i.e. changed from 0 to 1 or vice-versa.

The inspiration for this project, and for many parts of the model used, comes from this paper by Kristian Lindgren, which I initially discovered through this working paper by W. Brian Arthur.

Setup

To get the scripts running in R, you must:

  • Install R.

  • Download the game_flexible_popn.R and play_flexible_popn.R scripts from this repository.

  • In R, source these two scripts:

    • On Windows, something like

      source("C:\\Users\\yourusername\\Desktop\\game_flexible_popn.R")
      source("C:\\Users\\yourusername\\Desktop\\play_flexible_popn.R")
      
    • On Mac, something like

      source("/Users/yourusername/Desktop/game_flexible_popn.R")
      source("/Users/yourusername/Desktop/play_flexible_popn.R")
      
  • Then call the game_flexible_popn() function:

    game_stats <- game_flexible_popn(T = 1000)
    
  • (Optional, I recommend) Install RStudio

    • This is a nice IDE for R.

evol_pris_dilem's People

Contributors

xtremecurling avatar

Stargazers

 avatar Henry Hz avatar Iván Paredes Reséndiz avatar  avatar

Watchers

 avatar Iván Paredes Reséndiz avatar

Forkers

rossinnes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.