Skip to content

morgannivan/tit4tat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tit4tat 3.0

Axelrod's 1980 Prisoner's Dilemma tournament — reinvented. Find a strategy that beats Tit-for-Tat.

→ Play it live: https://tit4tat-nivanmorgan-purfect-labs.vercel.app

tit4tat menu vanilla-js


What this is

In 1980, Robert Axelrod ran a tournament asking game theorists to submit strategies for the iterated Prisoner's Dilemma. Tit-for-Tat (cooperate once, then mirror your opponent) won. It's been the default "how to cooperate" benchmark ever since.

tit4tat 3.0 is what TFT3 might look like if an AI submitted it today — a web game where you:

  • run round-robin tournaments across classic and post-Axelrod strategies
  • play head-to-head vs. any strategy, one move at a time
  • tune a custom strategy in the Strategy Lab and save named variants
  • grid-search parameter space in Param Sweep mode to find winning configurations
  • read Why They Win — a per-noise-level explainer of the mechanism behind each top finisher

The menu runs a live attract-mode demo that cycles through tournaments at 0 / 10 / 20 % noise so visitors can watch the leaderboard reshuffle in real time.

Strategies included

Classic (Axelrod 1980 roster): Tit-for-Tat, Tit-for-Two-Tats, Two-Tits-for-Tat, Generous TFT, Pavlov (WSLS), Grim Trigger, Always Cooperate, Always Defect, Random.

AI-era roster: Contrite TFT, Firm-but-Fair, Gradual (Beaufils 1996), ZD-Extortion, ZD-Generous (Press & Dyson 2012 / Stewart & Plotkin 2013), Adaptive probe-and-classify.

Your own: the Strategy Lab lets you tune a Custom strategy along five params (nice-first, forgiveness %, retaliation count, memory window, trigger threshold) and save named variants to localStorage.

Findings so far

Running the default classic roster at 0 % noise, 100 rounds, seed 1:

  1. Grim Trigger
  2. Two-Tits-for-Tat
  3. Tit-for-Tat
  4. Tit-for-Two-Tats
  5. Pavlov

Grim wins at low noise because it punishes random/accidental defection more decisively than TFT. At 10 % noise, Grim falls off a cliff (it can't recover from its own noise-induced defection) and TFT-family strategies take over. At 20 % noise, everyone degrades and even Always-Defect climbs into the top 3.

The parameter sweep turned up "Harsh" (forgiveness = 5 %, retaliation = 2, memory = 5, threshold = 1) as the first tuned strategy to reach #2 — beating every TFT variant. Grim is still the bar to clear.

Running locally

npm install
npm run dev   # vite on :5173

Build: npm run build (emits dist/).

URL routes (deep links)

  • #menu / #tournament/run / #h2h/play/C,D,C,... / #lab/preview / #sweep/run / #guide

Stack

Vanilla JavaScript + HTML canvas, Vite dev server, no runtime dependencies. ~37 KB of JS gzipped for the whole thing. Deployed on Vercel.

License

MIT.

About

tit4tat 3.0 — Axelrod's 1980 Prisoner's Dilemma tournament, reinvented

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors