AGAI-Lab01: Simple Agents, Complex Dynamics

In short

The lab uses agents with almost no memory and two or three actions to show three things. In one-shot games, self-interest gives the Prisoner’s Dilemma mutual defection and leaves the Stag Hunt stuck between two equilibria, and in repeated games, memory lets cooperation pay. When agents adapt by copying what works instead of calculating, the replicator equation predicts where a population ends up, and the same tools explain when signals between agents stay honest. Finally, a perfect optimiser in a two-square vacuum world shows how a badly chosen reward turns a harmless new action into Reward Hacking.

The lab is ungraded practice that the lecturer calls the best preparation for the midterm. All fifteen questions are worked below with derivations. The notebook ships without outputs, so numbers from random simulations come from my own re-run of its models with the same seeds and order of random draws; they should match the classroom run, though small differences are possible. Analytic results (equilibria, thresholds, rest points, stability, policies) are exact.

Concepts tested: Nash Equilibrium, Pareto Optimality, Prisoner’s Dilemma, Stag Hunt, Repeated Game, Replicator Dynamics, Reward Hacking, Value Iteration, Markov Decision Process, simple reflex agents


Part I: one-shot games, beliefs and repeated games

The model

Every game in Part I is a symmetric two-player, two-action game: each player picks C (cooperate) or D (defect) at the same time, and four numbers give the row player’s payoff (the column player is paid the same way):

partner plays Cpartner plays D
play C (reward) (sucker)
play D (temptation) (punishment)

A best response maximises my payoff given what my partner does. A pure Nash Equilibrium is an outcome where each action is a best response to the other, so no player gains by changing its action alone: where self-interested players can end up. An outcome is Pareto optimal if no other outcome makes one player better off without making the other worse off (“not wasteful”). The social optimum maximises total welfare, the sum of the two payoffs; every social optimum is Pareto optimal, but not the reverse. With four outcomes, all are found by checking each cell. The two games used throughout:

  • Prisoner’s Dilemma (PD): , here .
  • Stag Hunt (SH): , here . A stag (C) is caught only if both hunt it; a hare (D) can be caught alone. It stands for any coordination problem where a risky joint action pays most and a safe solo action tempts, such as two coding agents that must coordinate edits to shared files.

Beliefs. An agent unsure about its partner holds a belief , the probability that the partner cooperates. Its expected payoffs are and . Setting :

where is what you lose by cooperating when the partner does not (fear) and is what you gain by cooperating when the partner also does. Dividing keeps the direction of the inequality only when , which holds in a coordination game like the SH; for the lab’s PD the formula gives , outside . The larger , the more trust hunting the stag needs.

Repeated games. In a Repeated Game the same two agents play the PD for several rounds, and a strategy maps the history to an action. Memory-0 strategies ignore the history; memory-1 strategies look at the last round. A memory-one strategy is five probabilities of cooperating: in the first round, and after each previous outcome (my last action, partner’s last action):

strategyfirstafter CCafter CDafter DCafter DD
AllC11111
AllD00000
Random0.50.50.50.50.5
TFT (Tit-for-Tat)11010
WSLS (Win-Stay Lose-Shift)11001

TFT copies the partner’s last action. WSLS repeats its last action after a “win” (3 or 5 points, which happens exactly when the partner cooperated) and switches after a “loss” (0 or 1). Memory-0 strategies are the special case with the last four numbers equal.

The tournament, modelled on Axelrod’s 1980 tournament (won by Tit-for-Tat), is a round robin: every strategy plays every strategy, including a copy of itself, each pairing is repeated 50 times, and a strategy’s score is its average payoff per round over all opponents. A noise parameter flips an agent’s chosen action with some probability (an execution error); every question uses noise 0.

Q1: predictions before the analysis

Statement

(a) You play the following game once, against an anonymous agent you will never meet again, both choosing simultaneously. Your payoff (row player): 3 if both cooperate, 0 if you cooperate and the other defects, 5 if you defect and the other cooperates, 1 if both defect. The other agent receives points the same way (a normal-form game). Which action would you choose? Which action would a purely self-interested agent choose?

(b) The same game is played 50 times against the same partner, and each agent sees the previous round. Five types enter a round-robin tournament (everyone plays everyone, including a copy of itself): AllC, AllD, Random (fair coin each round), TFT and WSLS, as defined above. Which type do you expect to obtain the highest average score per round, and which the lowest?

(a) Many people pick C, out of fairness or hope. A purely self-interested agent picks D, because D pays more whatever the other does ( and ): D is a dominant action.

(b) The tempting prediction, from the Axelrod story, is that TFT wins and AllD loses. But in this field AllC and Random can be exploited every round and WSLS every other round, so AllD collects 5 per round from AllC and about 3 from Random and from WSLS. It may well stay on top, while AllC, which never punishes, should come last. The run (Q6) confirms this: AllD 2.62, TFT 2.45, WSLS 2.34, Random 2.24, AllC 2.11.

Q2: Nash, Pareto and social optimum in the PD

Statement

The code finds, for the PD with : pure Nash equilibrium (D,D); Pareto-optimal outcomes (C,C), (C,D), (D,C); social optimum (C,C).

(a) Is the Nash equilibrium of the Prisoner’s Dilemma Pareto optimal? Is it the social optimum? Explain why.

(b) Using the idea of a best response, explain in one or two sentences why two self-interested agents end up at the Nash equilibrium even though both prefer (C,C). Hint: does the best response of the row player depend on what the column player does?

(c) (C,D) is Pareto optimal. Does that make it a “good” outcome? What does this tell you about the difference between Pareto optimality and the social optimum?

col Ccol D
row C(3, 3), welfare 6(0, 5), welfare 5
row D(5, 0), welfare 5(1, 1), welfare 2

(a) No to both. (C,C) gives each player 3 instead of 1, so (D,D) is Pareto dominated. Its welfare, 2, is the lowest of the four cells, against 6 at the social optimum (C,C).

(b) The row player’s best response is D whether the column player plays C () or D (): it does not depend on the partner at all. The same holds for the column player, so (D,D) is the only cell where both are best-responding. Preferring (C,C) jointly does not help, because at (C,C) each player gains 2 by switching alone.

(c) No. (C,D) is Pareto optimal only because any move away from it hurts the column player, who gets 5, the most anyone can get, yet it is unequal (0 against 5) and wastes welfare (5 against 6). Pareto optimality only rules out gains that cost nobody anything; it says nothing about total welfare or fairness. The social optimum, the outcome with the largest sum, is much stronger: of the three Pareto-optimal outcomes, only (C,C) qualifies.

Q3: two games, two motives

Statement

The code finds, for the SH with : pure Nash equilibria (C,C) and (D,D); Pareto optimal (C,C); social optimum (C,C).

(a) Compare the Stag Hunt with the Prisoner’s Dilemma: how many pure Nash equilibria does each game have? In which game is mutual cooperation an equilibrium?

(b) Two motives can push a player towards D: greed (defecting pays more than cooperating when the partner cooperates, ) and fear (defecting pays more than cooperating when the partner defects, ). Which of these motives is present in the PD? Which in the SH? Use this to explain why the SH has a problem of trust/coordination while the PD has a problem of incentives.

(a) The PD has one pure Nash equilibrium, (D,D); the SH has two, (C,C) and (D,D). Mutual cooperation is an equilibrium only in the SH: a stag hunter who switches to hare drops from 4 to 3. In the PD a cooperator facing a cooperator gains by switching ().

(b)

motiveconditionPD (3, 0, 5, 1)SH (4, 0, 3, 2)
greedyes, no,
fearyes, yes,

In the PD both motives point to D, so D is dominant: even an agent certain that its partner will cooperate defects. No amount of trust fixes that; the payoffs themselves must change (punishment, contracts, repetition), so it is an incentive problem. In the SH there is no greed, so an agent sure that its partner hunts stag hunts stag too; only fear, doubt about the partner, pushes it to D. Fix the beliefs and cooperation follows, so the problem is trust and coordination.

Q4: which Stag Hunt equilibrium? (prediction)

Statement

Two agents meet once to play the Stag Hunt (). They cannot communicate and know nothing about each other.

(a) Which outcome do you expect to be most frequent: (C,C), (D,D), or a miscoordinated outcome?

(b) Suppose the hare becomes more attractive: increases from 3 to 4, everything else fixed. Will (C,C) become more or less frequent? Why?

Careful prediction. With no information, the natural model, which the lab then uses, gives each agent a belief drawn uniformly from , and each plays its best response. Here , so an agent hunts stag with probability . Independently for the two agents:

(a) (C,C) is by far the least frequent outcome; (D,D) and miscoordination are equally likely in expectation. The simulation of 10,000 encounters gives (C,C) 0.110, (D,D) 0.446, miscoordinated 0.445.

(b) Less frequent, in fact never. With , , and no belief exceeds 1, so nobody hunts stag: (C,C) 0.000, (D,D) 1.000. A larger shrinks the gain from cooperating with a cooperator ( drops from 1 to 0) while the fear term stays at 2. At the game is no longer a strict Stag Hunt: hare pays the same as stag against a stag hunter and more against a hare hunter, so D weakly dominates C.

Q5: a rule for which equilibrium wins

Statement

(a) Find a simple rule, written only in terms of , that predicts which equilibrium is played more often.

(b) Consider this sentence: “Rational agents will always coordinate on (C,C), because it is better for both of them.” Which evidence from this section contradicts this, and what is the flaw in the argument?

(c) The results depend on how we modelled what agents believe before playing. Describe one situation (for example, related to communication or memory) in which you would expect a different outcome.

(a) Under uniform beliefs, and , so (C,C) is more frequent exactly when

Rule: (C,C) is played more often when the gain from cooperating with a cooperator, , exceeds the loss from cooperating with a defector, ; (D,D) when fear outweighs gain. My re-runs agree: gives (C,C) 0.573 against (D,D) 0.065, and a tie (0.252 against 0.251). (Outside the lab, game theory calls the equilibrium that wins this comparison risk dominant, a term from Harsanyi and Selten.)

(b) The baseline run: rational best-responders reach (C,C) in only 11% of encounters and (D,D) in 45%. The argument confuses “better for both if both do it” with “best for me given what I expect”. Each agent chooses alone, and (C,C) being Pareto superior does not make stag the best response unless the agent believes its partner hunts stag with probability above . With no reason for that belief, the safe hare wins.

(c) Anything that makes beliefs high and shared changes the result. Communication: if agents can say “I will hunt stag” before playing, keeping the promise pays, because once the partner believes it and hunts stag, stag is the sender’s own best response; beliefs jump above and (C,C) becomes common. Memory and repetition: agents who meet repeatedly update from experience, so a few successful stag hunts lock in (C,C) and a few failures lock in (D,D). Reputation or shared conventions: a partner known to hunt stag, or agents built by the same company, start with near 1.

Q6: one-shot against repeated tournament

Statement

The tournament of Q1(b) is run twice, with 1 round and with 50 rounds.

(a) Compare the two rankings. How did the scores of AllD, TFT and WSLS change when going from 1 to 50 rounds? Was your prediction in Q1(b) correct? In the one-shot game AllC, TFT and WSLS take exactly the same action, yet their scores differ slightly: why, and what does this tell you about how to read small differences in these rankings?

(b) Look at the cooperation-rate matrix. Which strategies cooperate at different rates depending on who they play against, and which do not? Relate this to the memory of each strategy. Why is this ability essential for cooperation to pay off against a defector?

(c) AllD may still score well in this strategy space. Using the payoff matrix, identify whose payoff AllD’s score mostly comes from. Quote the numbers.

Rankings (points per round), with the exact expected values I derived alongside:

rankone-shotexact50 roundsexact
1AllD 3.823.80AllD 2.622.616
2Random 2.962.95TFT 2.452.443
3AllC 2.122.10WSLS 2.342.347
4WSLS 2.052.10Random 2.242.264
5TFT 2.022.10AllC 2.112.100

(a) From 1 to 50 rounds, AllD falls from 3.82 to 2.62, TFT rises from 2.02 to 2.45 and WSLS from 2.05 to 2.34. In a single round TFT and WSLS are plain cooperators and get exploited. Over 50 rounds TFT is exploited by AllD only in the first round and WSLS only every other round, and both earn 3 per round from each other. Whether the Q1(b) prediction was right depends on what you wrote: AllD still wins this field and AllC is last, so “TFT wins” was wrong here.

In the one-shot game AllC, TFT and WSLS all play C, so their expected score is identical: . The spread (2.12, 2.05, 2.02) comes only from the Random opponent’s coin in each strategy’s own 50 games against it: a payoff of 3 or 0 with equal chance has standard deviation 1.5, so the tournament score carries a standard error of about . Differences of a few hundredths are noise; trust only gaps well above 0.1, or derive the expected values.

(b) Cooperation rates over 50 rounds:

vs AllCvs AllDvs Randomvs TFTvs WSLS
AllC1.001.001.001.001.00
AllD0.000.000.000.000.00
Random0.500.500.520.470.50
TFT1.000.020.521.001.00
WSLS1.000.500.531.001.00

AllC, AllD and Random cooperate at the same rate whoever they face (Random’s wiggles are sampling noise): they are memory-0, so they cannot react to the partner. TFT and WSLS are memory-1, and their rates depend on the partner: full cooperation with cooperators, but 0.02 (only the first round) for TFT against AllD and 0.50 for WSLS against AllD.

This conditioning is what makes cooperation pay against a defector. An unconditional cooperator is exploited every round (AllC earns 0 against AllD). A strategy that withdraws cooperation after being defected on caps its loss at one round (TFT earns 0.98 against AllD) while still earning 3 per round with fellow cooperators. WSLS is weaker here: mutual defection (1 point) counts as a loss, so it switches back to C and is exploited every other round (0.50).

(c) AllD’s 2.62 averages its scores against AllC (5.00), itself (1.00), Random (3.01), TFT (1.08) and WSLS (3.00). Of the 13.09 total, 11 points come from AllC, Random and WSLS: AllC hands it every round while getting , and Random and WSLS give it 5 about half the time (earning 0.50 themselves). Against the reciprocator TFT it gets 1.08, barely above mutual defection. AllD’s score is paid for by exploitable partners, so it depends on how many of them are in the field.

Q7: when does AllD stop being best?

Statement

In a strategy space with only AllD, TFT and WSLS: from how many rounds onwards do you expect AllD to stop being the best strategy? Give a number and a one-line reason.

Answer: from 4 rounds onwards. One-line reason: AllD’s edge over TFT is a one-off first-round temptation, while TFT and WSLS earn 3 per round from each other, so from 4 rounds that edge is too diluted.

Derivation. No noise, so everything is deterministic. With rounds, per-round payoffs in each pairing:

  • AllD vs AllD: 1. AllD vs TFT: 5 in round 1, then 1, so . AllD vs WSLS: WSLS switches after every loss, so it plays C, D, C, … and AllD gets 5, 1, 5, 1, …, a total of .
  • TFT vs AllD: 0 then 1, so . TFT vs TFT and TFT vs WSLS: 3 each.
  • WSLS vs AllD: 0, 1, 0, 1, …, so . WSLS vs TFT and vs WSLS: 3.

Tournament scores (average over the three opponents), multiplied by 3:

TFT is always at least WSLS, so AllD is best exactly when it beats TFT:

  • even: ;
  • odd: .

So AllD wins for and TFT from . The run agrees exactly: AllD against TFT is 2.33 against 2.22 at 3 rounds, 2.00 against 2.25 at 4, and 1.69 against 2.33 at 50 (WSLS 2.17). Removing AllC and Random is what flips the 50-round result of Q6: without exploitable partners AllD falls to 1.69.

Beyond the questions: execution noise

My own extra run, with 5% noise (the notebook uses 0). One accidental D sends two TFT players into an echo of alternating retaliation, and TFT’s self-play payoff over 200 rounds drops to 2.26. WSLS recovers in two rounds: after an accidental (D,C) the defector won and stays D, the victim lost and switches to D, and at (D,D) both lose and switch back to C. WSLS self-play stays at 2.77, and in the five-strategy field over 50 rounds WSLS (2.38) overtakes TFT (2.22).

Common pitfalls in Part I

  • Pareto optimal is not socially optimal. (C,D) in the PD is Pareto optimal and still a bad outcome.
  • Greed and fear mixed up. The PD has both (an incentive problem, fixed by changing payoffs); the SH has only fear (a trust problem, fixed by changing beliefs).
  • “TFT always wins.” Rankings depend on the field: with AllC and Random present, AllD wins the 50-round tournament.

Part II: replicator dynamics and deception

The replicator equation

In Part I agents calculated. Many agents instead adapt: a trading bot keeps the rule that made money, a reinforcement learner repeats what paid off, a platform deploys more copies of the agent that sells best. Evolutionary game theory asks where that adaptation leads.

Take a large population in which a fraction cooperates and defects, paired at random. A partner cooperates with probability , so the expected payoffs (fitness) are

and the replicator equation says a strategy grows when it earns more than average, at a rate proportional to the gap and to how common it already is:

With strategies, frequencies and payoff matrix : (at in the PD both forms give for cooperators). The equation is the average behaviour of a population where agents copy a random peer with probability proportional to how much better the peer does (imitation of success), and the expected behaviour of a simple reinforcement learner (Cross learning) with a small learning rate (Börgers and Sarin, 1997).

A rest point is an with . It is stable if the population returns after a small push either way, unstable otherwise. The starting states that end at a stable rest point form its basin of attraction. The equation is solved numerically with the Runge-Kutta method (RK4, step 0.05).

A quick stability test, derived from the factorised form of Q9(a): write , so . Then and , so (all defect) is stable when (fear protects defection), and (all cooperate) is stable when (no greed protects cooperation).

Q8: predictions before the analysis

Statement

A large population of agents is repeatedly paired at random to play a game. The agents do not compute equilibria; strategies that earn more than average spread (agents copy successful peers, or successful agents are deployed more often).

(a) The population plays the Prisoner’s Dilemma () and starts with 90% cooperators. What happens to the fraction of cooperators over time?

(b) The population plays the Stag Hunt () and starts with 60% cooperators (stag hunters). What happens to the fraction of cooperators over time?

(a) Cooperators die out. Defectors earn more than cooperators against any mix of partners (D is dominant), so their share grows from any start; 90% only delays it. At : , . Run: falls below 0.5 at and below 0.01 at .

(b) The tempting prediction is that a cooperative majority wins. Compare payoffs at : and . Hare hunters earn more, so stag hunting declines, and keeps declining because the gap widens as falls. Run: at , at , then 0. Cooperation needs more than (Q10).

Q9: the Prisoner’s Dilemma under replicator dynamics

Statement

The code reports, for the PD: rest points (stable) and (unstable), and all ten trajectories from fall to 0.

(a) Show, in one or two lines of algebra, that .

(b) For the Prisoner’s Dilemma, write in terms of and . Using the greed () and fear () motives from Part I, explain why it is negative for every . What does this imply for the phase line, and for your prediction in Q8(a)?

(c) Compare the rest points with the Nash equilibrium of the Prisoner’s Dilemma. Which rest point is stable, and which Nash equilibrium does it correspond to? The state (everybody cooperates) is also a rest point: why does the population not stay there after a single defector appears?

(a) Substitute :

and multiply by . The factor makes change slow when either strategy is rare; the sign is set by alone.

(b)

Greed means and fear means . For the expression is a weighted average of two negative numbers, so it is negative for every ; for the lab’s PD it is . So on the whole open interval : the phase line lies below zero everywhere between the endpoints, and every population with any defectors slides to . Q8(a): 90% cooperators end at 0.

(c) Rest points: (stable) and (unstable). There is no interior one: the formula lies outside , because never reaches zero. The stable rest point , everyone defecting, corresponds to the unique Nash equilibrium (D,D). The state is a rest point only because there is nobody to copy: with no defectors, the defector share cannot grow. A single defector among cooperators earns against their , so it is copied and its share grows (). A rest point without stability holds only while nothing disturbs it.

Q10: the Stag Hunt under replicator dynamics

Statement

The code reports, for the SH: rest points (stable), (unstable), (stable); trajectories starting at 0.75 and above rise to 1, those at 0.65 and below fall to 0.

(a) Study the sign of for the Stag Hunt. Where do you expect the equation to be positive, negative, zero?

(b) List the rest points of the Stag Hunt and their stability. The interior rest point corresponds to the mixed Nash equilibrium of the game (each agent cooperates with probability ). Is this equilibrium something an adaptive population will end up in? Why or why not?

(c) Compare the interior rest point with the threshold belief from Part I (same payoffs). In Part I, rational agents chose a best response to a belief; here agents have no beliefs and only copy what works. Why do both models give the same threshold? Hint: what plays the role of the belief when partners are drawn at random from the population?

(d) Check your prediction Q8(b). Consider the sentence: “If the majority already cooperates, cooperation must win, because (C,C) is better for everyone.” Which output contradicts this, and what is wrong with the argument?

(a) : negative for , zero at , positive above. So is negative on , zero at , and , and positive on .

(b)

rest pointstabilitywhybasin
(all hare)stable
(mixed)unstableonly the point itself
(all stag)stable

An adaptive population will not end up at the mixed equilibrium. Both strategies earn the same there, but any small push tips it: slightly more stag hunters make stag pay more, which attracts more stag hunters, and the reverse below. It is the watershed between the two basins, kept only by a population that starts exactly there and is never disturbed.

(c) The interior rest point is

Under random matching, the probability that my partner cooperates is the population share . So and : the fitness functions are Part I’s expected payoffs with the share standing in for the belief. A rest point needs , the same equation as the rational agent’s indifference , so it has the same solution. The rational agent cooperates when its belief exceeds ; the population grows its cooperators when the actual share exceeds .

(d) Q8(b) is confirmed: from 60% stag hunters the population falls to 0, and even the trajectory from 65% ends at 0, as the unstable rest point at predicts. The flaw: what spreads is what earns more than average given the current mix. “Everyone is better off if everyone cooperates” compares whole outcomes, which no adapting agent ever does. With 60% stag hunters a stag hunter fails 40% of the time and averages 2.4, below a hare hunter’s 2.6. The bar is rather than because the fear term () outweighs the gain ().

Deception: the signalling game

Many interactions have asymmetric information: one agent knows its own quality and the other does not. The informed agent can send a signal (a “premium” label), which is useful only if reliable, and low-quality agents are tempted to fake it. A malicious agent that presents itself as trustworthy is the agentic version.

  • A fraction of signallers is high quality (H), the rest low quality (L). Signallers know their quality; receivers do not.
  • Each signaller sends the signal or not, at cost for H and for L.
  • Each receiver is trusting (accepts a signaller if and only if it signals) or sceptical (accepts nobody).
  • An accepted signaller gains , whatever its quality. A receiver gains from accepting H and loses from accepting L.

A low-quality signaller that signals deceives. Let , be the fractions of H and L signallers that signal and the fraction of trusting receivers. Each strategy’s advantage over the alternative (which pays 0) is for signalling H, for signalling L, and for trusting. Each group follows the two-strategy replicator equation (” times the advantage”):

H and L are separate groups because an agent chooses whether to signal but not its quality. The reliability of the signal is ; without a signal a receiver knows only the prior . Defaults: , , so accepting a random signaller loses () and receivers benefit only from an informative signal. Each run lasts until and the summary averages the second half; a receiver’s average payoff is times the advantage of trusting.

Q11: does faking pay? (prediction)

Statement

Fix (the signal is cheap for high-quality signallers) and start from . Consider two cases: (A) faking is expensive, ; (B) faking is cheap, . For each case, predict the long-run behaviour. Do low-quality signallers deceive? Do receivers keep trusting? Is the signal reliable?

(A) Faking pays at most even if every receiver trusts, so falls whatever happens. For H, signalling pays whenever . Once fakers are rare, trusting pays (), so rises, which makes signalling even better for H. Expected end: , , , an honest (separating) signal with reliability 1. Receivers then earn and H signallers .

(B) Now faking pays whenever , and no state leaves all three groups content. High trust lets fakers spread; common fakers make trusting lose (), so trust falls; below faking stops paying and fakers decline; then trusting pays again. Expect cycles, with H signallers still signalling since hovers around 0.5, above their break-even of 0.2. The cycles turn around the point where L signallers and receivers are both indifferent, with :

where reliability is : better than the prior of 0.3, far from reliable.

Runs (second-half averages):

(A) (B)
1.0001.000
(deceives)0.0000.444 (cycles 0.19 to 0.69)
(trust)1.0000.498 (cycles 0.28 to 0.72)
reliability1.0000.513
receiver payoff0.300

Both predictions hold. In (A) fakers vanish fast ( by ) and the signal becomes fully honest. In (B) low-quality signallers deceive much of the time, trust rises and falls with them in cycles that do not shrink, and receivers gain essentially nothing.

Q12: the uniform fee

Statement

A platform designer looks at the market of Q11 (B), where the label costs and and low-quality sellers fake it. Fearing that the label will always be misused, the designer makes it expensive for everyone: every seller that shows the label pays an extra fee (an expensive verification procedure). The designer cannot observe quality, so the fee is the same for every seller: and .

(a) Prediction (before running the next cell): will the fee stop deception? Will receivers be better off? Will high-quality sellers?

(b) Run the next cell and compare the two markets. Did the fee eliminate deception, and how? Compare the receivers’ payoff, the high-quality sellers’ payoff and the total welfare in both markets. Hint: why is the receivers’ payoff close to 0 even in the market with deception?

(c) Is the high fee good or bad? Rewrite the designer’s reasoning so that it is correct.

Total welfare per encounter is one receiver’s payoff plus one randomly drawn seller’s: .

(a) With , even an honest seller loses money on the label when every receiver trusts, so H sellers stop signalling, and L sellers too (). Deception ends because the label disappears. Receivers were earning about 0 already (Q11 B) and with no signals earn exactly 0, so they gain nothing. High-quality sellers lose the 0.3 they were earning.

(b)

(second-half averages)no fee, fee for everyone,
, 1.000, 0.4440.000, 0.000
0.4980.453 (frozen)
receiver payoff0.000
H seller payoff0.2980.000
total welfare0.0840.000

The fee eliminated deception by eliminating signalling: both seller groups abandon the label within about 10 time units. Trust freezes at 0.453 because once nobody signals, trusting and scepticism pay the same and .

Why receivers earn about 0 even with deception: low-quality sellers fake as much as trust allows, and the cycle turns around , where trusting pays the same as scepticism. More precisely (my derivation), is the advantage of trusting; since stays between 0.28 and 0.72 the log-odds stays bounded, so that advantage averages about 0. A receiver’s payoff is times the advantage; because the two move together over the cycle its average is not exactly zero, but it is small (). The deceivers absorb what receivers would gain from honest sellers, so the fee neither cost receivers anything nor helped them.

(c) The fee is bad. Receivers stay at 0, high-quality sellers fall from 0.298 to 0, total welfare from 0.084 to 0. Deception is gone only because the market for the label is gone.

The designer’s error: what stops faking is a cost difference between types. An honest signal survives when it pays for high-quality sellers and not for low-quality ones,

as in case (A). A fee charged to everyone moves both costs by the same , so it can help only if it lands between them: , so ; overshoots and prices out the honest sellers too. (My extra runs: even collapses the market from the 50/50 start, because trust of 0.5 is below the honest sellers’ new break-even of 0.8; from a high-trust start, , , , it reaches the honest outcome with welfare 0.36.)

The corrected reasoning: “The label is misused because faking it is cheap relative to what being trusted is worth. I should make it costly to fake while keeping it cheap for genuine sellers, for example a verification that genuine sellers pass and fakers fail, or a penalty for sellers caught faking. Raising the price for everyone removes honest sellers along with the fakers.”

Common pitfalls in Part II

  • Rest point taken for stable. in the PD and in the SH are rest points that one push destroys. Check and .
  • Share confused with belief. They play the same role under random matching, which is why , but adaptive agents hold no beliefs.
  • “Expensive signals are honest signals.” Honesty needs the cost to differ by type; a uniform fee large enough to stop fakers also stops honest senders.

Part III: the vacuum world and reward hacking

The model

Payoffs in Parts I and II were given. When an AI agent is trained, someone has to write the reward function, and the agent then does whatever earns most reward, including things the designer never intended (Reward Hacking). The lab shows this in the two-square vacuum world of Russell and Norvig, with dirt that comes back.

  • Two squares, A (left) and B (right), each clean or dirty; the robot is in one of them.
  • Left moves to A, Right to B; moving into the wall leaves the robot where it is (the motor still runs).
  • Suck on a dirty square cleans it and puts the dirt in the bag (which holds 0 or 1). Suck on a clean square does nothing.
  • Dump (added later by a software update) empties a full bag onto the current square, which becomes dirty. With an empty bag it does nothing.
  • After the action’s effect, each clean square becomes dirty with probability (the dirt rate, 0.1 by default), independently. A dirty square stays dirty until sucked.

The state is (robot position, A dirty, B dirty, bag full), so states: a small Markov Decision Process. Two rewards :

  • Bob: +1 for every clean square in the next state , at every time step.
  • Alice: +1 for every unit of dirt sucked up (Suck on a square that was dirty in ).

The robot knows the dynamics and computes an optimal policy with Value Iteration, discount :

starting from and repeating until the values stop changing. Ties (actions within of the best) are broken at random. The robot runs 1000 steps from “robot in A, both squares dirty, bag empty”, with the same random dirt for every robot, and is judged by a performance measure that ignores its reward: floor clean (%), moves per step (wall bumps included), dumps per step (with a full bag), dirt collected per step, and the reward per step it sees. Since the optimiser is exact, any odd behaviour comes from the reward.

Q13: predictions before the analysis

Statement

The goal is a clean office. Which reward function best accomplishes this?

(a) Bob’s reward: +1 for every clean square, at every time step, and no other benefits or costs. Suppose that, after the start, no new dirt ever appears. What will the robot do once both squares are clean?

(b) Alice’s reward: +1 for every unit of dirt the robot sucks up. In the test lab (actions Left, Right, Suck), which robot keeps the floor cleaner: Bob’s, Alice’s, or neither? A software update then adds a fourth action, Dump, which empties the robot’s bag onto its current square (useful, say, to empty the bag above a bin). Predict what each robot does after the update.

(a) Once both squares are clean, every action earns the same +2 per step forever, so the robot is indifferent and the tie-breaking rule decides. With random tie-breaking it wanders, moving on about two steps in three (two of its three actions are moves).

(b) In the lab, neither: dirt can only arrive from the environment and only Suck removes it, so both rewards are maximised by sucking dirt as fast as possible, and the robots should behave the same. After the update, Bob’s robot never dumps, because dirt on the floor lowers his reward. Alice’s robot dumps and re-sucks the same dirt, since every dump creates a new +1 one step later.

Q14: Bob’s robot

Statement

Bob’s reward, no new dirt (dirt rate 0), robot starts in A with both squares dirty. The policy table shows the bag-empty states.

(a) Look at the policy table. In which states does the robot have more than one optimal action? Why are these actions equally good under Bob’s reward?

(b) Check your prediction Q13(a). Once the floor is clean and no new dirt arrives, what does the robot do? Is the robot behaving irrationally? Answer in terms of what the robot maximises.

Bob’s optimal policy at dirt rate 0 (* marks dirt, brackets the robot): suck when on dirt ([A*] B, [A*] B*, A [B*], A* [B*]); move towards the dirt when standing on a clean square ([A] B* goes Right, A* [B] goes Left); Left, Right and Suck all optimal in [A] B and A [B].

Over 1000 steps with no new dirt the floor is 99.9% clean and the reward is 1.998 per step.

(a) More than one optimal action only in the two states where both squares are clean: Left, Right and Suck are all optimal. Whatever the robot does there, the floor stays clean, so it earns 2 now and at every future step: for each action. Bob’s reward depends only on how many squares are clean, and nothing in it distinguishes moving, bumping into a wall or sucking a clean floor. With dirt rate 0.1 the same tie remains (all three at 34.00), because A and B get dirty equally often, so being in either with a clean floor is worth the same.

(b) The robot cleans both squares in three steps (Suck, Right, Suck), then wanders: Right, Right, Suck, Suck, Left, Left, …, moving on 0.665 of all steps, close to the of random choice among Left, Right and Suck. It is not irrational: it maximises Bob’s reward, and every action earns the maximum of 2 per step. The wandering costs energy and wear, which the owner cares about and the reward never mentions. (My own check with the notebook’s move-cost helper: a cost of 0.5 per move makes Suck, which leaves the robot in place, the unique optimum in the clean states, and the robot sits still.)

Q15: Alice’s robot and the Dump action

Statement

Alice’s and Bob’s robots are compared in the test lab (Left, Right, Suck; dirt rate 0.1; no move cost), then both get Dump, with the same rewards, dirt rate and dirt.

(a) Without Dump, compare Alice’s and Bob’s robots. Could any test in this environment, using only the robots’ behaviour, reveal which reward each robot is optimising?

(b) With Dump, describe what Alice’s robot does, quoting numbers from the table and the trace. In which states of the policy table does it dump? Explain why dumping is optimal under Alice’s reward and never optimal under Bob’s.

(c) Check your prediction Q13(b). Nobody programmed the robot to dump dirt on the floor. Where does this behaviour come from? What does this suggest about giving an agent more actions or tools?

dirt rate 0.1, 1000 stepsBob, labBob, with DumpAlice, labAlice, with Dump
floor clean (%)84.484.484.459.1
moves per step0.5650.5650.5650.073
dumps per step0.0000.0000.0000.400
dirt collected per step0.1960.1960.1960.527
reward per step1.6871.6870.1960.527

(a) In the lab the two robots have the same set of optimal actions in all 16 states (suck when on dirt, move towards dirt from a clean square, anything when the floor is clean), so with the same tie-breaking they chose the same action at every one of the 1000 steps. Their values differ in size (Bob’s about 30 to 34, Alice’s about 3.5 to 5.2) but are maximised by the same actions. So no behavioural test in this environment can tell them apart. The reason: with only Left, Right and Suck, a square becomes clean only by being sucked and dirt comes only from the environment, so “squares clean” and “dirt sucked” move together. Only a change to the environment that separates the two can reveal the difference.

(b) With Dump, Alice’s robot farms dirt: it dumps on 40% of all steps, collects 0.527 units of dirt per step (2.7 times the lab’s 0.196), keeps the floor only 59.1% clean (against 84.4%) and barely moves (0.073). The trace starts Suck (+1) in A, Right, Suck (+1) in B, then Dump, Suck (+1), Dump, Suck (+1): the robot settles in B and alternates Dump and Suck, earning +1 every two steps, while A, which got new dirt at step 1, stays dirty until a tie at step 10 sends the robot Left; it sucks A and starts the same loop there.

Dump is optimal in exactly the four states where the bag is full and the robot’s square is clean: uniquely in [A] B and A [B] (both squares clean), and tied with moving to the dirt in [A] B* (Right or Dump) and A* [B] (Left or Dump). The ties arise because both options deliver the next +1 two steps later and lead to states of equal value: once the robot can make its own dirt, dirt elsewhere adds nothing, and a state’s value depends only on how soon it can next suck (standing on dirt 10.78, one step away 10.24, empty bag on a clean floor 8.24).

Why dumping is optimal for Alice: her reward counts sucking events. Dump then Suck returns the robot to the same state with +1 earned, a guaranteed 0.5 per step, against waiting for dirt that arrives at rate 0.1 per square. (The 0.527 is above 0.5 because new dirt sometimes lands right after a suck.) Even with no new dirt at all, my run of Alice’s robot with Dump earns 0.500 per step and keeps the floor only 75% clean; without Dump it would earn 0.002.

Why never for Bob: his reward counts clean squares and ignores the bag, so dumping onto a clean square costs a point at every step until the dirt is sucked again, and buys nothing. Dump appears among his optimal actions only in the two states with an empty bag and a clean floor, where it does nothing at all. In the run his bag is full after his first suck and stays full: every number matches the lab exactly.

(c) Q13(b) is confirmed. Nobody programmed dumping, and the planner is exact (it gives Bob’s robot no dumping): the behaviour comes from optimising a reward that measured a proxy (dirt collected) in place of the goal (a clean floor). In the lab the proxy and the goal moved together, because the only source of dirt was the environment, so the proxy looked perfect in every test. The new action gave the robot a way to raise the proxy without serving the goal (create dirt in order to collect it), and a perfect optimiser takes any such way. That is Reward Hacking in its simplest form.

For agents with more actions or tools: every new action or tool can break the link between the reward and the intended goal, so a reward validated with one action set is not validated for a larger one; behaviour in testing cannot certify the reward, since the two robots were indistinguishable step for step; and rewards should target the outcome the designer wants (the state of the floor) over an activity that usually accompanies it (sucking), and be tested again whenever the agent’s capabilities change.

Common pitfalls in Part III

  • “The robot is buggy or irrational.” Wandering and dumping both come from an exact optimiser; unwanted behaviour from an exact optimiser points at the reward.
  • “Identical behaviour in testing means identical objectives.” Two rewards can share a policy in one environment and diverge when the environment changes.

What to be able to write

  • Find pure Nash equilibria, Pareto-optimal outcomes and the social optimum of any symmetric 2x2 game, and explain why the PD’s equilibrium is inefficient.
  • Greed () and fear (), and which games have which.
  • Derive , the uniform-belief outcome frequencies, and the rule for (C,C) being played more often.
  • Explain why memory-1 strategies can make cooperation pay, and derive the crossover length (4 rounds) for AllD against TFT and WSLS.
  • Derive , the rest points and their stability, and why the interior rest point equals .
  • The signalling game: when an honest signal survives (), why deception makes signals cycle, and why a uniform fee kills the market.
  • The vacuum world: why Bob’s and Alice’s robots are indistinguishable in the lab, where Alice’s robot dumps and why, and what that says about tools and rewards.

Exam questions

Flashcards