A state table associates a finite game-history state with recorded outcomes or predictions. In the pennies game, each state records the penultimate outcome, whether the player changed choices, and the last outcome; its value stores the player’s two most recent choice patterns. section 8.2
The table supports prediction by following a small update-and-lookup cycle:
- Initialize the eight valid states with unset outcomes, shrug choices, and unset outcomes. section 8.2
- Look up the current state; if it is absent during warmup, return two Shrugs so the game makes a random choice. section 8.2.2
- For a valid state, shift the previous second choice forward and record whether the latest turn stayed the same or changed. section 8.2.2
- Treat matching stored choices as a prediction; treat different choices as uncertainty and choose randomly. section 8.2.2
Always choosing heads
If a player always chooses heads, only four of the eight rows become populated because the choice remains Same. The matching stored choices eventually let the machine predict Same; a player who changes every turn similarly fills the other four rows with Changes. section 8.2
Table 8.1 The eight possible states in the pennies game (view table figure)
Browse the eight possible combinations of penultimate outcome, choice change, and last outcome that form the table’s keys. section 8.2
A C++ implementation represents the key as a tuple of Outcome, Choice, and Outcome, and stores each key with a pair of recent choices in an unordered_map. A State class separates lookup from updating, while the mind reader updates the state after every turn. section 8.2.2 section 8.2.3
