GAME THEORY

Rational agents, irrational outcomes

L215 MINMATH & LOGIC
PREDICT

Tit-for-tat cooperates first, then copies the other player's last move. Mutual cooperation pays 3 a round each. Two tit-for-tat players play 200 rounds. Each move is flipped by accident 5% of the time. What happens to their average payoff?

In the prisoner’s dilemma two players choose to cooperate (C) or defect (D). Mutual cooperation pays 3 each, mutual defection 1 each, and a lone defector gets 5 while the sucker gets 0. Played once, defecting is better whatever the other does, so rational players both get 1.

Played repeatedly, a defection can be punished later. That needs a future. With a fixed, known last round, backward induction unravels it: defect in the last round, so also in the one before, and so on back to the first. Cooperation holds up in theory when there is no known last round or the future is discounted. The strategies here are simple rules that never count down to round 200. Tit-for-tat cooperates first, then copies the other player’s last move. That works until a move is flipped by noise.

▶ SIMULATION
PLAYER A
strategy: thinking
score 0
last 0: —
GAME
round 0 / 200
mutual cooperation 0%
avg payoff — (goal ≥ 2.5)
PLAYER B
strategy: thinking
score 0
last 0: —
payoffsCC 3/3 · CD 0/5 · DC 5/0 · DD 1/1
last—
✓ cooperation is sustained: average payoff ≥ 2.5 per round
SCHEDULE
01[A]A: best response to C, then to D
02[B]B: same reasoning
03[SETUP]both play their best response
04[SETUP]report
Start of one-shot scenario. 4 steps.
Prisoner's dilemma (row, column):
              C        D
     C     3, 3     0, 5
     D     5, 0     1, 1

One shot: D beats C whatever the other does (5 > 3, 1 > 0).
  (D, D) is the only Nash equilibrium; (C, C) pays both more.

Repeated, 200 rounds:
  tit-for-tat:   play C first, then copy their last move
  generous TFT:  like TFT, but after their D play C with prob 1/3
  noise:         each move is flipped with probability NOISE

TFT vs TFT after one flipped move:
  C C D C D C D …   (A)
  C C C D C D C …   (B)   retaliation echoes until another flip
Generous TFT breaks the echo after ~3 rounds on average.

The strip checks that cooperation holds: the average payoff stays at or above 2.5 per round. ONE-SHOT fails at once. TFT + NOISE fails under 5% noise. FIX: GENEROUS TFT faces the same flipped moves and ends at 2.83. Lower-case letters in the history are the flips.

TUNE IT NOT YET

Plain tit-for-tat collapses at 5% noise. Drag NOISE down and find how much noise it can tolerate while still averaging 2.5 per round over 200 rounds. Read the line under the sim at each setting.

GOAL: tit-for-tat vs tit-for-tat averages ≥ 2.5 per round

FIX IT NOT YET

Write strategy(history, rnd), returning 'C' or 'D'. history holds the moves that actually happened, oldest first. rnd() is a seeded random number in [0, 1): use it instead of Math.random so every grading run plays the same games. The grader plays 200 rounds with 5% noise against a copy of you, tit-for-tat and generous TFT (you need ≥ 2.5 per round against each), and against always-defect (you need ≥ 0.6, so you cannot be a pushover).

Mental model:

a dominant strategy can make everyone worse off; repetition fixes that by making the future matter, as long as there is no known last round. A good repeated strategy is nice (never defects first), retaliatory (punishes a defector) and forgiving (lets one mistake go). In any system with noise, forgiveness is what stops one error from becoming a permanent feud.

IN PRODUCTION

Congestion control (fair TCP versus aggressive senders), BitTorrent's tit-for-tat choking, peer-to-peer free-riding, blockchain mining incentives, and price wars. Mechanism design is the practice of changing the payoffs so the selfish choice is the good one.

IN INTERVIEWS

“What is a Nash equilibrium, and why is the prisoner's dilemma one bad?” or “design a strategy for the repeated game.” Show that defect dominates, explain how repetition supports cooperation, and say that with noise you need forgiveness, such as generous TFT or tit-for-two-tats, and that too much of it gets exploited.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: MONEY IN FLOATING POINT →