← All problemsFree · Python · 50 min

Algorithm design / guarantees under an adversary

The Night Guard

A thief picks a room to rob and a guard a room to watch. Find the value of a two-room game by hand, the guard's best mix for three rooms, then solve any zero-sum game with strategies that prove the value from both sides.

0 / 3 graded parts passSaved in this browser · loading saved work…
Jump to your work ↓

Every night a thief picks a room of a small museum to rob, and the night guard picks a room to watch. Neither knows the other's choice. If the guard is watching the room the thief robs, the thief is caught and loses 3. Otherwise the thief takes what the room holds.

the guard the thief watches Gold watches Silver robs Gold −3 caught 9 robs Silver 4 −3 caught Gold room holds 9, Silver room 4; a caught thief loses 3

The thief wants the largest expected haul and the guard wants the smallest, so this is a zero-sum game. Neither side should be predictable: a guard who always watches Gold loses 4 every night. A mixed strategy chooses at random, with fixed probabilities. Von Neumann's minimax theorem says that there is a number v, the value of the game, such that:

  • the thief has a strategy that expects at least v whatever the guard does, and
  • the guard has a strategy that holds the thief to at most v whatever the thief does.

A pair of such strategies is its own proof. Each one guarantees v from its side, so neither side can do better.

In code, a game is a matrix M. M[i][j] is what the row player (here, the thief) wins and the column player (the guard) loses when the row player plays i and the column player j.

Background: Zero-Sum Games.

easy · Part A

Two rooms

In the two-room museum of the figure, what is the value of the game: the thief's expected haul per night when both sides play as well as possible?

Explore in the sandbox

Experiment here, then copy a rule into the editor and test its guarantees.