Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

IPD Simulator

Python simulator for the Iterated Prisoner's Dilemma, inspired by classic IPD tournaments.

This project collects a large set of strategies and runs them against each other in tournament-style matchups.

Contents

  • 30+ strategy functions in IPD_tournament/IPDStrategies.py
  • match simulation logic in IPD_tournament/IPD_Simulations.py
  • a small entry script in IPD_tournament/IPDtournament_main.py

  • IPD_tournament/IPDtournament_main.py Current entry point. By default it runs:
ClassicTourney(Player_list, 200, 4)
  • IPD_tournament/IPD_Simulations.py Core tournament logic:

    • Fight(player1, player2, playto) runs a head-to-head match
    • RoundRobin(playerlist, playto) computes average performance across the full pool
    • ClassicTourney(playerlist, playto, permutations) runs a bracket-style tournament
  • IPD_tournament/IPDStrategies.py Strategy definitions and registration lists.

Scoring

Moves are represented as:

  • 1 = cooperate
  • 0 = defect

Payoffs: Standard

  • (1,1) -> (3,3)
  • (1,0) -> (0,5)
  • (0,1) -> (5,0)
  • (0,0) -> (2,2)

Strategy Format

Each strategy is a Python function that receives:

strategy(player, score, modifiers=[None])

Where:

  • player is player 1 or 2
  • score is the prior match history as a list of (p1_move, p2_move) tuples
  • the return value is usually a single move or a short list of upcoming moves

Strategies are registered in:

  • Player_dict
  • Player_list

So adding a new strategy usually means:

  1. Define the function in IPDStrategies.py
  2. Add it to Player_dict
  3. Run the main script again

About

A Python simulation of Neuman's "Iterated Prisoner's Dilemma" with a multitude of strategies

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages