Personal projectGo

Iterated Prisoner's Dilemma Tournament Manager

Run tournaments between strategies in the iterated prisoner's dilemma and test Robert Axelrod's theses on populations.

Iterated Prisoner's Dilemma Tournament Manager

A small Go console utility that runs tournaments between strategies in the iterated prisoner’s dilemma — either a classic round-robin tournament or evolutionary experiments with populations.

The Problem

The prisoner’s dilemma is one of the key problems in game theory: its solution reduces to a Nash equilibrium, from which no single agent can improve by acting alone. Robert Axelrod, in his book “The Evolution of Cooperation”, proposed looking at this dilemma with a shadow of the future — in other words, made it iterated — and ran a computer tournament between strategies submitted by scientists, psychologists, sociologists, and political scientists. This project recreates that tournament and lets you run your own experiments.

You can read more in my article.

Architecture

  • cmd/
    • play/Classic round-robin tournament
      • main.go
    • experiments/Experiment scenarios
      • main.go
      • experiments.go
  • internal/Tournament core
    • config.go
    • match.go
    • population.goPopulation description for evolutionary experiments
    • tournament.go
  • strategies/Strategy implementations
    • factory.goStrategy factory
  • justfile

A strategy is an implementation of the Strategy interface with three methods: Name() string, Move(opponentHistory History) Action, and Reset(). Strategies see nothing but the opponent’s move history, and reset their own internal state in Reset().

How to Run

The utility is built and run via just:

just play          # classic round-robin tournament
just expN          # experiment number N
just all           # run all experiments in sequence

Each run saves its results to a CSV file — handy for browsing result tables without parsing console output.