What reinforcement learning is
Reinforcement learning is learning what to do by trying things and seeing what happens. Nobody tells the learner which action is right. It acts, receives a number saying how well things are going, and has to work out for itself which actions lead to more of that number over time, often long after the action was taken.
01Two features that define it
Trial-and-error search. The learner discovers good actions by trying them. There is no teacher with correct answers, only an evaluation of the action actually taken.
Delayed reward. An action can affect not just the next reward but the situation that follows and every reward after that. A chess move may look neutral now and decide the game twenty moves later. Assigning credit for an outcome to the decisions that caused it is the central difficulty.
This sets reinforcement learning apart from supervised learning, which learns from labelled examples of correct behaviour, and from unsupervised learning, which looks for structure in unlabelled data. A reinforcement learner is trying to maximise a reward signal, not to find hidden structure, and in interactive problems it is usually impossible to supply examples of correct behaviour for every situation the agent will meet.
It also brings a trade-off the other settings lack: exploration versus exploitation. To earn reward the agent should repeat actions that worked; to find such actions it must try ones it hasn't. Neither can be pursued alone without failing at the task. Chapter 2 studies this trade-off in its simplest form.
02The elements of a reinforcement learning system
Besides the agent and its environment, four elements recur throughout the book:
Rewards are given directly by the environment. Values must be estimated, and re-estimated, from the sequences of observations an agent makes over its whole lifetime. That is why value estimation sits at the centre of almost every algorithm in this series.
03Worked example: learning tic-tac-toe
Suppose you want a player that beats an imperfect opponent at tic-tac-toe. A classical minimax player assumes the opponent plays perfectly and so can never exploit its mistakes. A value-function approach instead learns from play against this particular opponent.
Keep a table with one number per board position: the estimated probability of winning from there. Positions with three X's in a row start at 1, positions that are lost or full start at 0, and every other position starts at 0.5. To move, look at the positions each legal move would produce and usually pick the one with the highest value (a greedy move). Occasionally pick at random instead (an exploratory move) to see positions you'd otherwise never visit.
After each greedy move, nudge the value of the earlier position toward the value of the later one:
Here St is the position just after one of your moves and St+1 the position after your next move (or the final position, if the game ended in between). The update moves an estimate toward a later estimate: this is a temporal-difference update, the idea developed in chapter 6. Exploratory moves don't trigger an update, so the values keep describing greedy play.
A tic-tac-toe player that learns values
You learn as X and move first; the opponent is O. Small numbers show the value of the position each move would create, at your last decision.
Results over the last 100 games
What to try
- Play a few single moves. Early on every candidate is 0.5, so greedy moves are ties broken at random and updates do nothing, until a game ends and a 1 or 0 starts flowing backwards one position per game.
- Run 2,000 games against the random opponent. Losses become rare: the player has learned which positions lead to wins against this opponent.
- Switch to the opponent that wins or blocks when it can. It is harder to beat: after the same number of games you win less and lose more, because the only way past a blocker is a fork, two threats at once, and the player has to discover those lines. Values are always relative to the opponent faced.
- Set ε = 0 from the start. The player can lock into the first lines it happens to find; with some exploration it keeps discovering better ones.
Notice what this simple method already shows: the player learns from interaction without a model of the opponent, it plans ahead implicitly because values summarise future outcomes, and it improves during play rather than only after a game is fully analysed. It also has limits the book goes on to address: a table works because tic-tac-toe has a few thousand positions, but backgammon has around 1020, which calls for the function approximation of Part II.
04Values versus evolutionary methods
Another way to get a good tic-tac-toe player is to search policy space directly: try many fixed policies for many games each, keep the best, and vary them (as genetic algorithms or hill climbing do). Such evolutionary methods use only the final outcome of each game and ignore everything that happened during it. Value-function methods use each individual state visited, so they can credit specific moves. When the agent can sense its state accurately, learning values usually uses experience far more efficiently.
05Where the field came from
Modern reinforcement learning joined three earlier threads.
- 1890s–1950sTrial-and-error learning in animal psychology: actions followed by satisfaction become more likely to recur, Thorndike's “law of effect”. Early machines such as Minsky's SNARC (1951) explored it in hardware.
- 1950sOptimal control: Bellman's dynamic programming and the Bellman equation, and Markov decision processes, gave the mathematical framework of states, values and optimal policies.
- 1959–1980sTemporal-difference learning: Samuel's checkers player (1959) learned from differences between successive position evaluations. Klopf, then Sutton and Barto, developed the idea, and Sutton formalised TD(λ) in 1988.
- 1989Watkins's Q-learning tied the three threads together, connecting trial-and-error learning and TD learning to dynamic programming.
- 1992 onwardTesauro's TD-Gammon reached master-level backgammon by self-play; later, deep networks combined with these methods produced Atari-playing agents and AlphaGo (chapter 16).
06How the rest is organised
Part I (chapters 2–8) develops the core ideas where values fit in a table: bandits, MDPs, dynamic programming, Monte Carlo, temporal difference, n-step methods and planning. Part II (chapters 9–13) extends them to huge state spaces with function approximation, then covers eligibility traces and policy gradient methods. Part III (chapters 14–17) connects the algorithms to psychology and neuroscience, surveys applications, and looks at open problems.