<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mitansh Gor</title>
    <description>The latest articles on DEV Community by Mitansh Gor (@mitanshgor).</description>
    <link>https://dev.to/mitanshgor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F999457%2F1e38e750-fe49-48f5-8f41-8b0a1ea57000.png</url>
      <title>DEV Community: Mitansh Gor</title>
      <link>https://dev.to/mitanshgor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mitanshgor"/>
    <language>en</language>
    <item>
      <title>RL 9: Superhuman Achievement in Games (1992–1999)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Mon, 02 Nov 2026 08:21:34 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-9-superhuman-achievement-in-games-1992-1999-457h</link>
      <guid>https://dev.to/mitanshgor/rl-9-superhuman-achievement-in-games-1992-1999-457h</guid>
      <description>&lt;p&gt;For about 30 years, strong backgammon players opened certain rolls the same way. It was in the books. Then a program that had never read a backgammon book said they were all wrong, and it turned out to be right.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In Blog 8 the Q-table hit a wall: one cell per situation, and real problems have more situations than atoms in the universe. The obvious fix was a neural network that guesses values for situations it has never seen. But theory said that mixing a neural network with TD updates might blow up. One researcher at IBM tried it anyway, on a board game with dice. This post covers what happened, how the math works, and why the trick was partly luck.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Where We Are, and Where We're Going
&lt;/h2&gt;

&lt;p&gt;By the end of this post you'll be able to explain, in plain words:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why backgammon (a game with dice) was a &lt;em&gt;harder&lt;/em&gt; test for learning than chess.&lt;/li&gt;
&lt;li&gt;How a neural network replaces the Q-table, with a step-by-step example using real numbers.&lt;/li&gt;
&lt;li&gt;Where the weight-update formula comes from, and what an eligibility trace does to it.&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;self-play&lt;/strong&gt; is, and why "your opponent levels up with you" is such a powerful trick.&lt;/li&gt;
&lt;li&gt;Why TD-Gammon stunned human experts, and why the same recipe didn't instantly work everywhere else.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Words from earlier blogs I won't re-explain:&lt;/strong&gt; value function &lt;code&gt;V(s)&lt;/code&gt; and TD error &lt;code&gt;δ&lt;/code&gt; (Blog 7), eligibility traces, a.k.a. "breadcrumbs" (Blog 8), ε-greedy exploration and "model" (Blog 8). If any feel fuzzy, a quick skim of those posts will set you up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New words in this post:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Word&lt;/th&gt;
&lt;th&gt;Plain meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Neural network&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A stack of layers. Each layer takes numbers in, mixes them using adjustable dials, and passes numbers out. Numbers in one end, a guess out the other.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Weights&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Those adjustable dials inside the network. Learning = turning the dials.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Gradient&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;For every dial: "if I turn you up a tiny bit, how much does the network's guess change?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Function approximator&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Any formula with tunable dials that &lt;em&gt;guesses&lt;/em&gt; a value, instead of storing it in a table. A neural network is one.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Self-play&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The agent plays against a copy of itself.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ply&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One player's turn (a "half-move").&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Rollout&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Play a position out to the end thousands of times with random dice, and count who wins. (It's Monte Carlo from Blog 7, in action.)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  1. Why Backgammon?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkdw0t52jd4mb7ckg1n8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkdw0t52jd4mb7ckg1n8.jpg" alt="Gerald Tesauro" width="620" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Gerald Tesauro, a researcher at IBM, picked backgammon on purpose. Not because it was easy, but because it was awkward in exactly the ways that break the usual tricks.&lt;/p&gt;

&lt;p&gt;Chess is deterministic. No dice. A program can look many moves ahead because the number of options per turn stays manageable: roughly 30–40 legal moves in chess, 8–10 in checkers. In backgammon every turn starts with a dice roll. There are 21 distinct rolls, each allowing around 20 legal moves, so &lt;strong&gt;several hundred branches per ply&lt;/strong&gt;. Look-ahead search drowns almost immediately.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frekbwn211m4owniqej18.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frekbwn211m4owniqej18.jpg" alt="backgammon" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You only need three ideas to follow this post: it's a &lt;strong&gt;race&lt;/strong&gt; around the board, you can &lt;strong&gt;hit&lt;/strong&gt; a lone enemy checker and send it back to the start, and you can &lt;strong&gt;block&lt;/strong&gt; with stacked checkers. Dice make every plan fragile, so even a position's &lt;em&gt;value&lt;/em&gt; is a probability, not a verdict.&lt;/p&gt;

&lt;h3&gt;
  
  
  The old way: copy the experts
&lt;/h3&gt;

&lt;p&gt;Tesauro had already tried the standard approach. His earlier program, &lt;strong&gt;Neurogammon&lt;/strong&gt;, was trained by supervised learning (the "show it labeled examples" method) on recorded games by expert humans. It won the 1989 Computer Olympiad. But it had a ceiling, and the ceiling was &lt;em&gt;the humans it copied&lt;/em&gt;. And experts aren't infallible: in backgammon and Othello, expert opinion had been substantially revised over the previous twenty years.&lt;/p&gt;

&lt;p&gt;So he built a head-to-head experiment. Same designer, same kind of network, two teachers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Teacher A:&lt;/strong&gt; expert-labeled examples (Neurogammon).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Teacher B:&lt;/strong&gt; nobody. The network plays itself and learns from who wins (TD-Gammon).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was a gamble. Samuel tried self-play with checkers in the 1950s (Blog 4), and self-playing learners had a reputation for developing weird, brittle strategies that beat &lt;em&gt;themselves&lt;/em&gt; but lose to everyone else.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. The Recipe: How a Network Replaces the Table
&lt;/h2&gt;

&lt;p&gt;Blog 8 ended with the table's fatal flaw. Backgammon has more than &lt;code&gt;10^20&lt;/code&gt; positions, so a table with one cell per position is impossible. Tesauro's replacement was a plain multilayer perceptron: numbers go in one end, one guess comes out the other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl64z7y481bzppz0sk9lk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl64z7y481bzppz0sk9lk.png" alt="multilayer perceptron" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What goes in, what comes out
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Input:&lt;/strong&gt; 198 numbers describing the board. Roughly: for every &lt;strong&gt;point&lt;/strong&gt; (one of the 24 narrow slots checkers sit on), a few numbers saying how many checkers each player has there, plus a handful for checkers on the bar, checkers borne off, and whose turn it is. (The very first version used &lt;em&gt;only&lt;/em&gt; this raw board. No strategy hints.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hidden layer:&lt;/strong&gt; 40 units in the first version, 80 in later ones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt; the network's estimate of who's winning. Textbooks simplify this to one number, the probability of winning. Tesauro's actual network had four outputs, covering normal wins and "gammons" (landslide wins worth double) for each side.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That output is &lt;code&gt;V(s, w)&lt;/code&gt;: the value of board &lt;code&gt;s&lt;/code&gt;, computed by a network whose dials (weights) are &lt;code&gt;w&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Count the dials: &lt;code&gt;198 × 40 + 40 × 4&lt;/code&gt; is roughly &lt;strong&gt;8,000 weights&lt;/strong&gt;. Eight thousand numbers standing in for &lt;code&gt;10^20&lt;/code&gt; positions. That compression only works because the network &lt;em&gt;generalizes&lt;/em&gt;: what it learns about one position carries over to thousands of near-twins. A table can't do that.&lt;/p&gt;

&lt;h3&gt;
  
  
  How it picks a move
&lt;/h3&gt;

&lt;p&gt;Because the rules of backgammon are known, the agent doesn't need a Q-table. (Remember the "model" from Blog 8? In a board game with clean rules, you can write the map by hand.) On each turn it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rolls the dice.&lt;/li&gt;
&lt;li&gt;Lists every legal move and the board each one &lt;em&gt;would&lt;/em&gt; create.&lt;/li&gt;
&lt;li&gt;Feeds each resulting board into the network.&lt;/li&gt;
&lt;li&gt;Plays the move whose board has the best estimated outcome. Greedy. No ε-greedy, no random exploration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No exploration at all? That should worry you after Blog 8. Section 3 explains why it works anyway: the dice do that job for free.&lt;/p&gt;

&lt;h3&gt;
  
  
  How it learns, part 1: one game, with numbers
&lt;/h3&gt;

&lt;p&gt;Here's a toy game. The network scores four positions in a row, then the game ends in a win. Inside one game there's no reward until the end and we use &lt;code&gt;γ = 1&lt;/code&gt;, so the TD error &lt;code&gt;δ&lt;/code&gt; from Blog 7 boils down to &lt;em&gt;next estimate minus this estimate&lt;/em&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Position&lt;/th&gt;
&lt;th&gt;Network's win estimate&lt;/th&gt;
&lt;th&gt;What happens next&lt;/th&gt;
&lt;th&gt;TD error &lt;code&gt;δ&lt;/code&gt; (next minus this)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0.50&lt;/td&gt;
&lt;td&gt;next position is rated 0.55&lt;/td&gt;
&lt;td&gt;+0.05&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0.55&lt;/td&gt;
&lt;td&gt;next position is rated 0.45&lt;/td&gt;
&lt;td&gt;−0.10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0.45&lt;/td&gt;
&lt;td&gt;next position is rated 0.70&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+0.25&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;0.70&lt;/td&gt;
&lt;td&gt;game ends: &lt;strong&gt;win&lt;/strong&gt; (= 1.0)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+0.30&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read the last row first. The network said "70% for me", and the game ended in a win. It was underconfident, so the surprise is positive. Notice that &lt;strong&gt;the only real information from the outside world is that final win.&lt;/strong&gt; Everything else is the network comparing its own consecutive guesses (the "fix your guess with a better guess" idea from Blog 7).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faehmdpi89d6encxq3azd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faehmdpi89d6encxq3azd.png" alt="One game: win estimates, surprise arrows and fading breadcrumbs" width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How it learns, part 2: where the update rule comes from
&lt;/h3&gt;

&lt;p&gt;The surprise tells us &lt;em&gt;how wrong&lt;/em&gt; a guess was. How do we turn that into "turn these dials this way"? It's ordinary gradient descent (the same idea as Blog 6), with one twist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, what's a gradient?&lt;/strong&gt; Take a tiny network, &lt;code&gt;V = 0.2·x₁ + 0.5·x₂&lt;/code&gt;, and a board described by &lt;code&gt;x = [2, 1]&lt;/code&gt;. Then &lt;code&gt;V = 0.4 + 0.5 = 0.9&lt;/code&gt;. Nudge the first dial from 0.2 to 0.21 and &lt;code&gt;V&lt;/code&gt; becomes 0.92: it moved by &lt;code&gt;0.01 × x₁ = 0.02&lt;/code&gt;. So the sensitivity of &lt;code&gt;V&lt;/code&gt; to dial 1 is &lt;code&gt;x₁ = 2&lt;/code&gt;, and to dial 2 it's &lt;code&gt;x₂ = 1&lt;/code&gt;. The list of sensitivities &lt;code&gt;[2, 1]&lt;/code&gt; is the &lt;strong&gt;gradient&lt;/strong&gt;, written &lt;code&gt;∇_w V&lt;/code&gt;. A real network has about 8,000 dials, and backprop (Blog 6) computes that whole list efficiently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcunhztyn5o2gz0ka3du0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcunhztyn5o2gz0ka3du0.png" alt="tiny 2-weight 'hill' picture" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now the rule.&lt;/strong&gt; We want the guess at position &lt;code&gt;t&lt;/code&gt; to move toward the &lt;em&gt;next&lt;/em&gt; guess, which is our "better guess". Measure the miss with a squared error, treating the target as a fixed number:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;L&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;y&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;y&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;held&amp;nbsp;fixed&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Its slope with respect to the dials is &lt;code&gt;−(y_t − V_t) · ∇_w V_t&lt;/code&gt;. Stepping &lt;em&gt;downhill&lt;/em&gt; (with step size &lt;code&gt;α&lt;/code&gt;) gives:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∇&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathbf mtight"&gt;w&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Read it in words: &lt;strong&gt;turn each dial in proportion to (how surprised I was) × (how much that dial mattered).&lt;/strong&gt; That's TD(0) with a neural network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhou0hvf09wkp4ty8kzkr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhou0hvf09wkp4ty8kzkr.png" alt="TD with NN" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;For the mathematically curious.&lt;/strong&gt; We froze the target &lt;code&gt;y_t&lt;/code&gt; while taking the slope, even though &lt;code&gt;y_t&lt;/code&gt; itself depends on &lt;code&gt;w&lt;/code&gt;. Because of that, this update is &lt;em&gt;not&lt;/em&gt; the true gradient of any single fixed loss. Sutton and Barto call it a &lt;strong&gt;semi-gradient&lt;/strong&gt; method. It's the reason the theory is harder than ordinary supervised learning, and it's the thread we pull in Section 5.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  How it learns, part 3: adding the trace (and &lt;em&gt;when&lt;/em&gt; things happen)
&lt;/h3&gt;

&lt;p&gt;TD(0) only fixes the position that just happened. But a surprise at move 4 is partly the fault of moves 1 to 3. The &lt;strong&gt;eligibility trace&lt;/strong&gt; (Blog 8's breadcrumbs) handles that. In a table the breadcrumbs sat on cells. A network has no cells, so they sit on the &lt;strong&gt;weights&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5l94newcvtfpxxuimxiy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5l94newcvtfpxxuimxiy.png" alt="eligibility trace in TD + NN " width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The update happens after every move, not after the game.&lt;/strong&gt; Each trip around the loop touches two piles of numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The weights &lt;code&gt;w&lt;/code&gt;&lt;/strong&gt;: the network's actual brain (about 8,000 numbers).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The trace &lt;code&gt;e&lt;/code&gt;&lt;/strong&gt;: a scratchpad &lt;em&gt;the same length as &lt;code&gt;w&lt;/code&gt;&lt;/em&gt;. A fading memory of "which dials were involved in my recent guesses". It starts at all zeros at the start of every game, and &lt;strong&gt;it never changes the network by itself.&lt;/strong&gt; Only a surprise &lt;code&gt;δ&lt;/code&gt; does that.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For each move &lt;code&gt;t&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Forward pass.&lt;/strong&gt; Rate the current board: &lt;code&gt;V_t&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient.&lt;/strong&gt; Backprop gives &lt;code&gt;g_t&lt;/code&gt;, the list of "how much did each dial matter".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update the scratchpad.&lt;/strong&gt; Fade the old memory, add the fresh footprint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The move happens and the next board arrives.&lt;/strong&gt; Rate it (or use the real result if the game just ended) and compute the surprise &lt;code&gt;δ_t&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn the dials&lt;/strong&gt;, each in proportion to its breadcrumb.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As formulas, one per step:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;g&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∇&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;e&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γλ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;e&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbf"&gt;g&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbf"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;w&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbf"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;w&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All the dials (about 8,000 numbers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;g_t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The gradient: how much each dial influenced the guess at move &lt;code&gt;t&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;e_t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The trace: a fading sum of recent gradients, same length as &lt;code&gt;w&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;γ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Discount. We use &lt;code&gt;γ = 1&lt;/code&gt; inside a game, so it drops out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;λ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How slowly the memory fades. &lt;code&gt;λ = 0&lt;/code&gt;: no memory (plain TD(0)). &lt;code&gt;λ&lt;/code&gt; near 1: long memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;δ_t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The surprise at move &lt;code&gt;t&lt;/code&gt; (&lt;code&gt;z&lt;/code&gt;, the real result, replaces the next guess on the last move)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;α&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Learning rate: how big a step to take&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice that with &lt;code&gt;λ = 0&lt;/code&gt; the trace is just &lt;code&gt;g_t&lt;/code&gt;, and the update collapses to the TD(0) rule we derived above. The trace is TD(0) plus memory.&lt;/p&gt;

&lt;p&gt;Also notice the timing: &lt;code&gt;δ_t&lt;/code&gt; needs the &lt;em&gt;next&lt;/em&gt; board's rating, so move &lt;code&gt;t&lt;/code&gt;'s update lands the moment move &lt;code&gt;t+1&lt;/code&gt;'s board appears. That's why the update sits &lt;em&gt;between&lt;/em&gt; positions, not at the end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsd6wepiglnzn48acp9ko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsd6wepiglnzn48acp9ko.png" alt="td error" width="598" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How it learns, part 4: run it on the toy game
&lt;/h3&gt;

&lt;p&gt;To keep the vectors small, pretend the network has just &lt;strong&gt;3 dials&lt;/strong&gt; (&lt;code&gt;w_a, w_b, w_c&lt;/code&gt;) instead of 8,000. The gradients are made up (move 1 touches dial a, move 2 touches b, moves 3 and 4 touch c), but the arithmetic is exactly the real algorithm. Settings: &lt;code&gt;λ = 0.5&lt;/code&gt; (old memory halves each step), &lt;code&gt;α = 0.1&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Move &lt;code&gt;t&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Gradient &lt;code&gt;g_t&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Trace &lt;code&gt;e_t = 0.5·e_(t-1) + g_t&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Surprise &lt;code&gt;δ_t&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Dial change &lt;code&gt;α · δ_t · e_t&lt;/code&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1, 0, 0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1, 0, 0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;+0.05&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[+0.005, 0, 0]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0, 1, 0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0.5, 1, 0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;−0.10&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[−0.005, −0.010, 0]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0, 0, 1]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0.25, 0.5, 1]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;+0.25&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[+0.006, +0.013, +0.025]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0, 0, 1]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0.125, 0.25, 1.5]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;+0.30 (game won)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[+0.004, +0.008, +0.045]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;[+0.01, +0.01, +0.07]&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(Rounded to three decimals; the totals use exact values.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Two things to read off it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The trace column&lt;/strong&gt; is the breadcrumb trail. After move 4, dial c (used by the late positions) carries big breadcrumbs (1.5), while dial a (used only in position 1) carries a faint one (0.125).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The last column&lt;/strong&gt; is where it pays off. Dial a was only involved in position 1, yet the late good news still reached it. That's credit assignment traveling backward through time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What the trace actually changed.&lt;/strong&gt; Compare with &lt;code&gt;λ = 0&lt;/code&gt; (plain TD(0)), where each move only touches its own gradient:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Total change&lt;/th&gt;
&lt;th&gt;&lt;code&gt;w_a&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;w_b&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;w_c&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TD(0), no trace&lt;/td&gt;
&lt;td&gt;+0.005&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;−0.010&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;+0.055&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TD(λ), with trace&lt;/td&gt;
&lt;td&gt;+0.010&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+0.010&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;+0.070&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Look at dial b. Without a trace, position 2's dial gets &lt;em&gt;punished&lt;/em&gt;, because its own next-step surprise was negative (−0.10). With a trace, it also hears the later news: the game was &lt;strong&gt;won&lt;/strong&gt;, and position 2 was on the path to that win. The final verdict flips the sign.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2etpm377xy9gpumq9nk7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2etpm377xy9gpumq9nk7.png" alt="state td vs td lambda" width="800" height="698"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmkdh6xx2ckb6tz7gejx4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmkdh6xx2ckb6tz7gejx4.png" alt="td lambda vs td" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The food-critic version: you eat ten courses and get a stomachache. TD(0) blames only the last dish. TD(λ) spreads the blame backward, most to the last course, less to each earlier one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Online vs offline.&lt;/strong&gt; You &lt;em&gt;could&lt;/em&gt; save up all four rows of the last column and apply them together after the game (&lt;strong&gt;offline&lt;/strong&gt; TD(λ)). You'd still add up &lt;em&gt;every&lt;/em&gt; row, not just the last one. TD-Gammon updated after each move (&lt;strong&gt;online&lt;/strong&gt;), so later guesses in the same game already benefit from earlier lessons.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;For the mathematically curious.&lt;/strong&gt; There's a second way to read &lt;code&gt;λ&lt;/code&gt;. Instead of breadcrumbs looking &lt;em&gt;backward&lt;/em&gt;, imagine each position looking &lt;em&gt;forward&lt;/em&gt;: it forms the target "look &lt;code&gt;n&lt;/code&gt; steps ahead, then trust my own estimate" for every &lt;code&gt;n&lt;/code&gt;, and averages them with weights that decay by &lt;code&gt;λ&lt;/code&gt;:&lt;br&gt;
&lt;code&gt;G_t^λ = (1 − λ) · Σ_{n≥1} λ^(n−1) · G_t^(n)&lt;/code&gt;.&lt;br&gt;
At &lt;code&gt;λ = 0&lt;/code&gt; that's the one-step TD(0) target. At &lt;code&gt;λ = 1&lt;/code&gt; it's the full Monte Carlo return from Blog 7. So &lt;code&gt;λ&lt;/code&gt; is a smooth dial between "bootstrap from the next guess" and "wait for the real outcome". The trace is the &lt;em&gt;backward view&lt;/em&gt; that achieves the same averaging online, without having to store the future. The two views give the same total update (exactly in the offline case, closely in the online case).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6rrqakmtyajtxscowyr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6rrqakmtyajtxscowyr.png" alt="tdlambda" width="474" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two roles, to keep straight: &lt;strong&gt;TD&lt;/strong&gt; decides &lt;em&gt;what the target should be&lt;/em&gt; when nobody gives you labels (Blog 7). &lt;strong&gt;Backprop&lt;/strong&gt; decides &lt;em&gt;how to turn the dials&lt;/em&gt; to move toward that target (Blog 6). TD-Gammon is those two ideas bolted together.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Self-Play and the "Infinite Curriculum"
&lt;/h2&gt;

&lt;p&gt;Tesauro started the network with random weights, which means random play. Both sides played randomly, against each other, and the only feedback was who won.&lt;/p&gt;

&lt;p&gt;Early games were absurd. Random backgammon can run for hundreds or even thousands of moves, compared to about 50–60 plies in a normal human game. And yet the network learned. In the first few thousand games it picked up the basics: hit the opponent, avoid leaving lone checkers exposed, build solid structures. Subtler ideas showed up after tens of thousands of games.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fotmt1dzmqha5xmg92cex.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fotmt1dzmqha5xmg92cex.png" alt="steps of learnings visualize" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the opponent never gets too easy or too hard
&lt;/h3&gt;

&lt;p&gt;Because the agent plays &lt;em&gt;itself&lt;/em&gt;, its opponent is always exactly as strong as it is. The moment it discovers a slightly better strategy, its opponent (itself) uses that strategy too. Difficulty rises automatically with ability. Researchers later called this an &lt;strong&gt;infinite curriculum&lt;/strong&gt;: a training setup that adjusts its own difficulty, with no human designing lesson plans.&lt;/p&gt;

&lt;p&gt;It's the same loop AlphaGo Zero used in 2017, playing millions of games against itself (4.9 million, per the paper) starting from random moves.&lt;/p&gt;

&lt;h3&gt;
  
  
  The dice are secretly doing the exploring
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnlq1ookl6ct9qv98q12o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnlq1ookl6ct9qv98q12o.png" alt="dice are secretly doing the exploring" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember ε-greedy from Blog 8? The deal was: you need random moves or you'll never discover better options. TD-Gammon had none, and it worked anyway. Tesauro's explanation: &lt;strong&gt;the dice already randomize which positions the agent visits&lt;/strong&gt;. Every game wanders through different territory whether the player wants to or not. A deterministic game like chess would need some other source of randomness, or self-play can get stuck replaying one narrow style forever.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Plot Twist: Why Didn't It Copy-Paste to Chess and Go?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeleil3rhjiyyu501iyt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeleil3rhjiyyu501iyt.png" alt="surprise" width="422" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If a neural network trained by TD and self-play could master backgammon, surely chess and Go were next? They weren't. A major 1996 survey of RL noted that no success close to TD-Gammon's had been repeated.&lt;/p&gt;

&lt;p&gt;Three explanations emerged, and the third one is where the math comes back.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation 1: Backgammon was a uniquely friendly game.&lt;/strong&gt; Tesauro himself listed reasons (we met the first one already):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;dice&lt;/strong&gt; provide exploration for free. (Remember the worry from Section 1 that self-play learners get brittle? In a deterministic game, a self-player can settle into one narrow style that looks great &lt;em&gt;against itself&lt;/em&gt; and falls apart against anyone else. Random dice keep knocking it into new positions.)&lt;/li&gt;
&lt;li&gt;Games always &lt;strong&gt;end&lt;/strong&gt;, even with random play. (A deterministic game can loop forever, and then the network never sees a final result to learn from.)&lt;/li&gt;
&lt;li&gt;The true value of a position is &lt;strong&gt;smooth&lt;/strong&gt;: a small change to the board nudges the win probability slightly, instead of flipping between "win" and "lose".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Explanation 2: Maybe TD wasn't even the star.&lt;/strong&gt; In 1996–98, Jordan Pollack and Alan Blair ran a provocative follow-up titled &lt;em&gt;"&lt;a href="https://papers.neurips.cc/paper_files/paper/1996/file/459a4ddcb586f24efd9395aa7662bc7c-Paper.pdf" rel="noopener noreferrer"&gt;Why did TD-Gammon work?&lt;/a&gt;"&lt;/em&gt; They trained a small network (about 4,000 parameters) with plain hill-climbing evolution: no backprop, no reinforcement learning, no TD. It still reached a competitive backgammon level. Their hypothesis: much of the success came from the &lt;em&gt;setup&lt;/em&gt; (co-evolving players against each other) and the dynamics of backgammon itself. TD-Gammon still got further, so this didn't erase Tesauro's achievement. But it was a warning that "RL + neural net" wasn't a magic recipe yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation 3: The math says it shouldn't have been safe.&lt;/strong&gt; Remember the semi-gradient twist from Section 2: we froze the target while taking the slope. That's fine for tables. With a function approximator, three ingredients can combine badly. Sutton and Barto later named the combination the &lt;strong&gt;deadly triad&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ingredient&lt;/th&gt;
&lt;th&gt;Where we met it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Function approximation&lt;/strong&gt; (a network instead of a table)&lt;/td&gt;
&lt;td&gt;This blog&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Bootstrapping&lt;/strong&gt; (using your own next guess as part of the target)&lt;/td&gt;
&lt;td&gt;TD, Blog 7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Off-policy learning&lt;/strong&gt; (learning about a different policy than the one acting)&lt;/td&gt;
&lt;td&gt;Q-learning, Blog 8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzge1xkjbv6vqdu9o99m2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzge1xkjbv6vqdu9o99m2.png" alt="three overlapping circles" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With all three present, value estimates can &lt;strong&gt;diverge&lt;/strong&gt;: instead of settling toward the right answer, they grow without bound. &lt;/p&gt;

&lt;p&gt;TD-Gammon had two of the three. It learned about its &lt;em&gt;own&lt;/em&gt; play, so it was on-policy. That's one plausible reason it got away with it, though nobody has proven that's the whole story. It sat on a lucky island, and the surrounding waters were rough.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. What TD-Gammon Left Behind
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;For backgammon.&lt;/strong&gt; By 1995, rollouts by TD-Gammon were regarded as the most reliable way to analyze checker plays, and opening theory had been rewritten.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For RL.&lt;/strong&gt; It was the first large-scale success of RL with a &lt;em&gt;nonlinear&lt;/em&gt; function approximator, and the blueprint for what came next. The stability problem it dodged is exactly the plot of &lt;strong&gt;DQN (Blog 11)&lt;/strong&gt;: DeepMind's real contribution was making this combination &lt;em&gt;stable&lt;/em&gt;, not inventing it. And its self-play loop was an early example of the recipe later used in AlphaGo Zero.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An open question.&lt;/strong&gt; Why did it work? Dice, smoothness, on-policy luck, or the setup? Researchers were still arguing about it years later, which is what makes it such a good puzzle.&lt;/p&gt;




&lt;h2&gt;
  
  
  Cheat Sheet
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TD-Gammon&lt;/strong&gt; = a neural network &lt;code&gt;V(s, w)&lt;/code&gt; trained by TD(λ) through self-play; the first big proof that function approximation + RL can work at scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update rule&lt;/strong&gt; = turn each dial by &lt;code&gt;α × (surprise) × (breadcrumb)&lt;/code&gt;. With &lt;code&gt;λ = 0&lt;/code&gt; it's TD(0); the trace adds memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semi-gradient&lt;/strong&gt; = we freeze the target while taking the slope, so it isn't a true gradient of a fixed loss.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-play&lt;/strong&gt; = you are your own sparring partner, so difficulty rises with your skill (an &lt;em&gt;infinite curriculum&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why it worked on backgammon:&lt;/strong&gt; dice (free exploration), games always end, smooth values, and on-policy learning. Maybe the setup mattered too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deadly triad&lt;/strong&gt; = function approximation + bootstrapping + off-policy. TD-Gammon had two of three.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honest caveat:&lt;/strong&gt; later versions added hand-made features and a short search, and the result didn't transfer to chess or Go.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What's Coming Next
&lt;/h2&gt;

&lt;p&gt;TD-Gammon worked, but the theory says value-based methods with function approximation can fail to converge. So what if we &lt;strong&gt;skip the value function and improve the policy directly&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;That's Blog 10.&lt;/p&gt;




&lt;h3&gt;
  
  
  Sources and Further Reading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;G. Tesauro, &lt;em&gt;"Temporal Difference Learning and TD-Gammon"&lt;/em&gt;, Communications of the ACM, 1995 (the primary source for the architecture, scores, and the opening-play story).&lt;/li&gt;
&lt;li&gt;G. Tesauro, &lt;em&gt;"Practical Issues in Temporal Difference Learning"&lt;/em&gt;, Machine Learning, 1992.&lt;/li&gt;
&lt;li&gt;J. Pollack, A. Blair, &lt;em&gt;"Why did TD-Gammon Work?"&lt;/em&gt;, NIPS 1996.&lt;/li&gt;
&lt;li&gt;Sutton and Barto, &lt;em&gt;Reinforcement Learning: An Introduction&lt;/em&gt; (TD-Gammon case study; semi-gradient methods; the deadly triad).&lt;/li&gt;
&lt;li&gt;J. Tsitsiklis, B. Van Roy, &lt;em&gt;"An Analysis of Temporal-Difference Learning with Function Approximation"&lt;/em&gt;, 1997.&lt;/li&gt;
&lt;li&gt;R. Sutton, D. McAllester, S. Singh, Y. Mansour, &lt;em&gt;"Policy Gradient Methods for Reinforcement Learning with Function Approximation"&lt;/em&gt;, NIPS 1999.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>computerscience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>RL 8: Q-Learning, Model-Free Breakthroughs, and the Off-Policy Meta (1988–1994)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 22 Oct 2026 20:41:29 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-8-q-learning-model-free-breakthroughs-and-the-off-policy-meta-1988-1994-277f</link>
      <guid>https://dev.to/mitanshgor/rl-8-q-learning-model-free-breakthroughs-and-the-off-policy-meta-1988-1994-277f</guid>
      <description>&lt;p&gt;In Blog 7 we watched Sutton teach machines to &lt;em&gt;predict&lt;/em&gt;: chase a moving target of better and better value estimates, and the estimates settle down on the truth. That was a big deal. But there was a catch.&lt;/p&gt;

&lt;p&gt;Prediction without action is a weather forecast you can't do anything about.&lt;/p&gt;

&lt;p&gt;Knowing "this situation is worth 8 points" is nice. Knowing "so I should turn left" is what actually wins games. This post is about the five years (1988–1994) when RL went from &lt;strong&gt;predicting&lt;/strong&gt; to &lt;strong&gt;deciding&lt;/strong&gt;, and did it without ever being handed a map of the world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fleoo5af5egxne2tzn8ty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fleoo5af5egxne2tzn8ty.png" alt="RL tree" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the end of this post you'll be able to explain, in plain words:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;why "knowing how good a state is" isn't enough to act&lt;/li&gt;
&lt;li&gt;what &lt;strong&gt;Q-Learning&lt;/strong&gt; does and why it was a breakthrough&lt;/li&gt;
&lt;li&gt;what &lt;strong&gt;on-policy&lt;/strong&gt; and &lt;strong&gt;off-policy&lt;/strong&gt; mean (the most important vocabulary split in RL)&lt;/li&gt;
&lt;li&gt;why the fastest route along a cliff edge can be the &lt;em&gt;wrong&lt;/em&gt; thing to learn&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Quick refresher (and four new words)
&lt;/h2&gt;

&lt;p&gt;Blog 7 already covered state, action, reward, policy, return, value, the discount &lt;code&gt;γ&lt;/code&gt;, bootstrapping and the TD error &lt;code&gt;δ&lt;/code&gt;, so I won't re-explain them here. If any feel fuzzy, a quick skim of Blog 7 will set you up. Four words show up in this post that are new:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Word&lt;/th&gt;
&lt;th&gt;Plain meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A map of the world: "if I do X here, I end up there"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Model-free&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Learning what to do &lt;em&gt;without&lt;/em&gt; that map&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Q-value&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The score of a specific &lt;em&gt;action&lt;/em&gt; in a specific state (not just the state)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;On-policy / off-policy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Whether you learn about the way you actually behave, or about some ideal way of behaving (the big idea of this post)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The gap: knowing the score vs knowing the move
&lt;/h2&gt;

&lt;p&gt;Blog 7's value function &lt;code&gt;V(s)&lt;/code&gt; answers "how good is it to be &lt;em&gt;here&lt;/em&gt;?" That's the exact gap: it scores &lt;strong&gt;places&lt;/strong&gt;, not &lt;strong&gt;moves&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now suppose you're standing at a crossroads and you know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the road left leads to a town worth &lt;strong&gt;7&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;the road right leads to a town worth &lt;strong&gt;9&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Easy, go right. But notice what you needed: &lt;strong&gt;you had to know where each road leads.&lt;/strong&gt; That's the model, the map: &lt;code&gt;P(s' | s, a)&lt;/code&gt;, the probability of landing in &lt;code&gt;s'&lt;/code&gt; after doing &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In a board game with clean rules, you can write that map by hand. In a robot's kitchen, a stock market, or a video game you've never seen? Nobody hands you the map. And building one is often harder than the original problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiotkl0t42yxodkxue5uq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiotkl0t42yxodkxue5uq.png" alt="RL" width="625" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix, in one sentence:&lt;/strong&gt; stop scoring &lt;em&gt;places&lt;/em&gt; and start scoring &lt;em&gt;choices&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If you know "taking road right from this junction is worth 9," you don't need to know where it goes. You just pick the best-scoring choice. Algorithms that work this way, without a map of the world, are called &lt;strong&gt;model-free&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Three ideas, arriving between 1988 and 1994, made that practical. We'll take them in order.&lt;/p&gt;




&lt;h2&gt;
  
  
  Idea 1: TD(λ), a dial between "impatient" and "patient" (Sutton, 1988)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjp8scqk7r6cv8yoz2wvo.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjp8scqk7r6cv8yoz2wvo.webp" alt="sutton" width="800" height="924"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Technically this one is still about prediction, so why is it here? Because it upgrades the credit-assignment machinery from Blog 7, and Watkins is about to reuse that machinery for choosing actions.&lt;/p&gt;

&lt;p&gt;Blog 7 left you with two separate tools: &lt;strong&gt;TD(0)&lt;/strong&gt; (update from the very next state) and &lt;strong&gt;Monte Carlo&lt;/strong&gt; (wait for the whole episode, then update). Sutton's 1988 paper, &lt;em&gt;Learning to Predict by the Methods of Temporal Differences&lt;/em&gt;, showed they're not two tools at all. They're the two ends of &lt;strong&gt;one dial&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8imb7cmflzdj4uy17dc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8imb7cmflzdj4uy17dc.png" alt="MONTE CARLO" width="606" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The dial is &lt;code&gt;λ&lt;/code&gt; (lambda), a number from 0 to 1.&lt;/strong&gt; At &lt;code&gt;λ = 0&lt;/code&gt; you get TD(0). At &lt;code&gt;λ = 1&lt;/code&gt; you get (roughly) Monte Carlo. Everything in between is a blend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the dial works: eligibility traces.&lt;/strong&gt; Think of breadcrumbs. Every state you visit gets a breadcrumb, and the crumbs fade as time passes:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γλ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;−&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbf"&gt;1&lt;/span&gt;&lt;span class="mopen"&gt;[&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In words: "a state's crumb fades by a factor of &lt;code&gt;γλ&lt;/code&gt; each step, and gets topped up whenever you visit it."&lt;/p&gt;

&lt;p&gt;When a surprise arrives (the TD error &lt;code&gt;δ&lt;/code&gt; from Blog 7), it gets spread backward along the breadcrumb trail. Fresh crumbs get a big share of the credit. Faded ones get a little.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;The eligibility trace idea has roots in Klopf's biological thinking from Blog 6. Sutton turned it into a precise, tunable tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters for what comes next:&lt;/strong&gt; TD(λ) gives RL its &lt;em&gt;credit-assignment machinery&lt;/em&gt;. Watkins would soon bolt the same trick onto action-learning (his version is called Q(λ)). But first he needed to solve the bigger problem: learning actions at all.&lt;/p&gt;




&lt;h2&gt;
  
  
  Idea 2: Q-Learning, scoring choices instead of places (Watkins, 1989)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb38lkpuseema68uonx67.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb38lkpuseema68uonx67.jpg" alt="watkins" width="294" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Chris Watkins introduced Q-Learning in his 1989 Cambridge PhD thesis, &lt;em&gt;Learning from Delayed Rewards&lt;/em&gt;. The idea sounds almost too simple to be a breakthrough.&lt;/p&gt;

&lt;p&gt;Instead of &lt;code&gt;V(s)&lt;/code&gt; (how good is this &lt;em&gt;state&lt;/em&gt;?), learn &lt;code&gt;Q(s, a)&lt;/code&gt; (how good is &lt;em&gt;this action in this state&lt;/em&gt;?). The "Q" stands for "quality."&lt;/p&gt;

&lt;p&gt;Formally, &lt;code&gt;Q*(s, a)&lt;/code&gt; is the total future reward you'd expect if you take action &lt;code&gt;a&lt;/code&gt; in state &lt;code&gt;s&lt;/code&gt; and play &lt;strong&gt;perfectly&lt;/strong&gt; from then on:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size2"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="delimsizing mult"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size1"&gt;&lt;span&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size1"&gt;&lt;span&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size2"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;That's Bellman's optimality idea from Blog 3, rewritten for actions. And here's the payoff: &lt;strong&gt;once you have &lt;code&gt;Q*&lt;/code&gt;, the best policy is trivial.&lt;/strong&gt; In every state, pick the action with the highest Q. No map required.&lt;/p&gt;

&lt;h3&gt;
  
  
  The table
&lt;/h3&gt;

&lt;p&gt;Picture a spreadsheet. One row per state, one column per action. Each cell holds the agent's current guess for "how good is this action here?" At the start, every cell is 0 (or random). The agent knows nothing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkx94ctywiss7hr2ezn4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkx94ctywiss7hr2ezn4.png" alt="q-map" width="782" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The update rule
&lt;/h3&gt;

&lt;p&gt;Every time the agent takes a step, it fixes one cell of the table:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size2"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size2"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Let's unpack it piece by piece:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Q(s_t, a_t)&lt;/code&gt; is the &lt;strong&gt;old guess&lt;/strong&gt; for this action.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r_{t+1}&lt;/code&gt; is the reward the agent actually got.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;γ max Q(s_{t+1}, a')&lt;/code&gt; is the &lt;strong&gt;best the next state can offer&lt;/strong&gt;, discounted. (Bootstrapping again, just as in Blog 7.)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r + γ max Q(...)&lt;/code&gt; together form the &lt;strong&gt;target&lt;/strong&gt;: "what this action looks like now that I've seen what happened."&lt;/li&gt;
&lt;li&gt;The bracket is the &lt;strong&gt;TD error&lt;/strong&gt;: target minus old guess. How wrong was I?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;α&lt;/code&gt; is the learning rate: how much of the error to correct per step.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A worked example (with actual numbers)
&lt;/h3&gt;

&lt;p&gt;Say the agent stands in state A and takes action "right," landing in state B.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Old guess: &lt;code&gt;Q(A, right) = 0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reward for the step: &lt;code&gt;r = 0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Best option in B: &lt;code&gt;max Q(B, ·) = 10&lt;/code&gt; (it already learned that B is next to the goal)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;γ = 0.9&lt;/code&gt;, &lt;code&gt;α = 0.5&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The target is &lt;code&gt;0 + 0.9 × 10 = 9&lt;/code&gt;. The error is &lt;code&gt;9 − 0 = 9&lt;/code&gt;. The update is &lt;code&gt;0 + 0.5 × 9 =&lt;/code&gt; &lt;strong&gt;4.5&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;Q(A, right)&lt;/code&gt; jumps from 0 to 4.5, &lt;strong&gt;even though the agent got zero reward on that step.&lt;/strong&gt; It earned that credit because it &lt;em&gt;led somewhere good&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now repeat this for thousands of steps. The goal's reward leaks into the square next to it, then into the square next to &lt;em&gt;that&lt;/em&gt;, then the next, the same backward-spreading "rumor" from Blog 7's 3-step robot, only now it travels through action scores. Eventually every cell holds a sensible number and the best move from anywhere is "follow the biggest number."&lt;/p&gt;

&lt;h3&gt;
  
  
  The guarantee
&lt;/h3&gt;

&lt;p&gt;Here's the part that made people sit up. Q-Learning isn't just "usually works." It has a proof.&lt;/p&gt;

&lt;p&gt;Watkins outlined it in his thesis, and &lt;strong&gt;Watkins and Dayan published the full proof in 1992&lt;/strong&gt; (&lt;em&gt;Machine Learning&lt;/em&gt; journal, "Technical Note: Q-Learning"). The result: with a table of values, and &lt;strong&gt;every action tried repeatedly in every state&lt;/strong&gt;, Q-Learning converges to the optimal action-values with probability 1. Later, Tsitsiklis (1994) and Jaakkola et al. (1994) re-proved it with a more general toolkit.&lt;/p&gt;

&lt;p&gt;The fine print matters, and it'll matter later in this post:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every (state, action) pair must keep getting visited (so you must &lt;strong&gt;explore&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;The learning rate &lt;code&gt;α&lt;/code&gt; must shrink at the right pace over time&lt;/li&gt;
&lt;li&gt;The values are stored in a &lt;strong&gt;table&lt;/strong&gt;, not squeezed into a function approximator&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthjjyfdac8fzomqx05pu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthjjyfdac8fzomqx05pu.png" alt="Q-learning architecture" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Exploring: how does the agent visit everything?
&lt;/h2&gt;

&lt;p&gt;Condition #1 above hides a puzzle. If the agent always picks its current best-looking action, it'll never discover that the road it dismissed early on was actually great. That's the &lt;strong&gt;explore vs exploit&lt;/strong&gt; tension, one we've met before: Samuel wrestled with it in checkers (Blog 4) and Tsetlin built it into his learning automata (Blog 5).&lt;/p&gt;

&lt;p&gt;The simplest practical recipe is &lt;strong&gt;ε-greedy&lt;/strong&gt;:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size2"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mtable"&gt;&lt;span class="col-align-l"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;random&amp;nbsp;action&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="arraycolsep"&gt;&lt;/span&gt;&lt;span class="col-align-l"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;with&amp;nbsp;probability&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="arraycolsep"&gt;&lt;/span&gt;&lt;span class="col-align-c"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;with&amp;nbsp;probability&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Roll a die. Most of the time (say 90%), do what the table says is best. The rest of the time (10%), do something random, just to see. Early in training, &lt;code&gt;ε&lt;/code&gt; is large; as the table gets trustworthy, &lt;code&gt;ε&lt;/code&gt; shrinks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidpkd6ime7iuzvb3toze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidpkd6ime7iuzvb3toze.png" alt="state flow Q-learning" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hold on to this one detail, because it sets up the whole second half of the post: &lt;strong&gt;while exploring, the agent sometimes does dumb things on purpose.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The quiet superpower: off-policy learning
&lt;/h2&gt;

&lt;p&gt;Look back at the Q-Learning update. The target uses &lt;code&gt;max Q(s_{t+1}, a')&lt;/code&gt;: the value of the &lt;strong&gt;best&lt;/strong&gt; next action. But what did the agent &lt;em&gt;actually do&lt;/em&gt; next? Maybe it explored and did something random. The update doesn't care. It always learns as if the agent will play perfectly from the next step on.&lt;/p&gt;

&lt;p&gt;This means two different "policies" are in play:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Behavior policy:&lt;/strong&gt; what the agent &lt;em&gt;actually does&lt;/em&gt; while collecting experience (messy, exploratory)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target policy:&lt;/strong&gt; what the agent is &lt;em&gt;learning about&lt;/em&gt; (the greedy, best-possible policy)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When these two are different, the algorithm is called &lt;strong&gt;off-policy&lt;/strong&gt;. Q-Learning is the classic example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk41yblzolwbcysg8t0dk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk41yblzolwbcysg8t0dk.png" alt="off policy" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An analogy:&lt;/strong&gt; imagine learning to drive by studying dashcam footage of other people, including clumsy drivers. You can still extract "what's the ideal move at this intersection?" from footage of someone who wasn't playing ideally. That's off-policy. &lt;em&gt;On-policy&lt;/em&gt; would be learning to drive only from your own hands-on driving and judging yourself on exactly how you drive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76fp4tt0qad0gxmnfasm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76fp4tt0qad0gxmnfasm.png" alt="behaviour to target" width="519" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why this matters in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reuse old data.&lt;/strong&gt; Experience collected yesterday under a worse policy is still valid for updating Q today.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore wildly&lt;/strong&gt; without poisoning what you're learning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn from other people.&lt;/strong&gt; A human demo, a different bot's game logs: all usable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This one property is the reason the deep RL systems of the 2010s could store millions of past game frames and keep learning from them. Remember it when we reach DQN.&lt;/p&gt;




&lt;h2&gt;
  
  
  The table's fatal flaw
&lt;/h2&gt;

&lt;p&gt;Q-Learning worked beautifully on small worlds: grid mazes, toy problems, dozens or hundreds of states. Then people tried it on something real.&lt;/p&gt;

&lt;p&gt;Take an Atari game. The "state" is the screen: 210×160 pixels, each with one of 128 possible colors. The number of possible screens is beyond astronomical. You can't build a table with a row for each. You couldn't even store it.&lt;/p&gt;

&lt;p&gt;This is the &lt;strong&gt;curse of dimensionality&lt;/strong&gt; from Bellman's era (Blog 3), coming back for revenge. And the fine print from earlier bites: Watkins &amp;amp; Dayan's guarantee covers &lt;em&gt;tables&lt;/em&gt;. Swap in a function approximator and the proof no longer applies (and, as people found, training can get unstable).&lt;/p&gt;

&lt;p&gt;The natural fix: don't store a row per state. Learn a &lt;strong&gt;function&lt;/strong&gt; that takes any state and &lt;em&gt;estimates&lt;/em&gt; its Q-values, generalizing from states it has seen to ones it hasn't. A neural network is exactly that kind of function. Replace the table with a network that outputs one Q-value per action, keep Watkins's update rule almost unchanged, and you get the &lt;strong&gt;Deep Q-Network (DQN)&lt;/strong&gt;. That's DeepMind's 2013 breakthrough, and the star of Blog 11.&lt;/p&gt;

&lt;p&gt;The table was never the destination. It was the prototype.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Before we get there: Blog 9 takes a detour to 1992, when Gerald Tesauro mixed TD learning with a neural network on a board game. It worked remarkably well, and it happened two decades before DQN.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Idea 3: SARSA, when being realistic beats being optimistic (Rummery &amp;amp; Niranjan, 1994)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F834dku3c75jqelzp0rl8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F834dku3c75jqelzp0rl8.jpg" alt="Rummery" width="400" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the early 90s, Q-Learning looked great. Then researchers noticed something uncomfortable: it's an &lt;strong&gt;optimist&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Its update assumes that after this step, the agent will always make the &lt;em&gt;best&lt;/em&gt; possible move. But during training, the agent explores. It stumbles on purpose, on a schedule (remember ε). Q-Learning learns as if those stumbles will never happen.&lt;/p&gt;

&lt;p&gt;Most of the time that's harmless. Sometimes it's a disaster. Enter the cliff.&lt;/p&gt;

&lt;h3&gt;
  
  
  The cliff-walking problem
&lt;/h3&gt;

&lt;p&gt;This is a classic from Sutton &amp;amp; Barto's textbook. A grid, a start square, a goal square, and between them a row of cliff squares. Every step costs -1. Stepping on the cliff costs -100 and sends you back to the start.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvljc78xuj3flnmwsee41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvljc78xuj3flnmwsee41.png" alt="cliff" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;shortest path&lt;/strong&gt; hugs the cliff edge. If you never slip, it's the best route.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Q-Learning&lt;/strong&gt; correctly figures this out: the edge path is the &lt;em&gt;optimal&lt;/em&gt; path for a perfect agent. So it learns to walk along the edge.&lt;/li&gt;
&lt;li&gt;But the agent is still doing ε-greedy exploration while it learns. Occasionally it takes a random step... off the cliff. Ouch, -100. Q-Learning logs the penalty, but its update rule still says "the &lt;em&gt;best&lt;/em&gt; move from here is great," so it keeps hugging the edge and keeps falling during training.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F47szrargm4a0ndiupt8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F47szrargm4a0ndiupt8f.png" alt="disadvantages Q-learning" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The SARSA fix
&lt;/h3&gt;

&lt;p&gt;Gavin Rummery and Mahesan Niranjan (Cambridge, 1994) proposed a small change with a big consequence: &lt;strong&gt;learn from what the agent actually does next, not from what it could ideally do.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compare the two updates. Only one term changes:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;Q-Learning:&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen"&gt;&lt;span class="delimsizing mult"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎡&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord munder"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord text mtight"&gt;&lt;span class="mord mtight"&gt;best&amp;nbsp;possible&amp;nbsp;next&amp;nbsp;action&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord munder"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span class="svg-align"&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="stretchy"&gt;&lt;span class="brace-left"&gt;&lt;/span&gt;&lt;span class="brace-center"&gt;&lt;/span&gt;&lt;span class="brace-right"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose"&gt;&lt;span class="delimsizing mult"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎦&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎤&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;SARSA:&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen"&gt;&lt;span class="delimsizing mult"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎡&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord munder"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord text mtight"&gt;&lt;span class="mord mtight"&gt;action&amp;nbsp;actually&amp;nbsp;taken&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord munder"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span class="svg-align"&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="stretchy"&gt;&lt;span class="brace-left"&gt;&lt;/span&gt;&lt;span class="brace-center"&gt;&lt;/span&gt;&lt;span class="brace-right"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose"&gt;&lt;span class="delimsizing mult"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎦&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="delimsizinginner delim-size4"&gt;&lt;span&gt;⎤&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqt8d6cqcm3puycc8xhd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqt8d6cqcm3puycc8xhd.png" alt="SARSA update" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because each update needs the five things &lt;strong&gt;S&lt;/strong&gt;tate, &lt;strong&gt;A&lt;/strong&gt;ction, &lt;strong&gt;R&lt;/strong&gt;eward, next &lt;strong&gt;S&lt;/strong&gt;tate, next &lt;strong&gt;A&lt;/strong&gt;ction, the algorithm is called SARSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What SARSA does on the cliff:&lt;/strong&gt; when it wobbles near the edge and falls, the next-action value it bootstraps from is the &lt;em&gt;real, wobbly&lt;/em&gt; one, so the penalty drags down the value of walking near the edge. Over time it prefers a longer, safer path with a buffer from the cliff. Not because that path is theoretically shortest, but because it's the best path &lt;strong&gt;for an agent that sometimes makes random moves&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyabj03bte5ea0431pjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyabj03bte5ea0431pjs.png" alt="SARSA vs Q-learning" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55f01g8ug74nc0zd9c5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55f01g8ug74nc0zd9c5b.png" alt="SARSA state flow" width="432" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This makes SARSA &lt;strong&gt;on-policy&lt;/strong&gt;: the policy being learned and the policy generating experience are the same thing.&lt;/p&gt;

&lt;h3&gt;
  
  
  So which one is "better"?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://colab.research.google.com/drive/17pcSXOs06ySRo_9kfNlxmPgGu1PLdrgK" rel="noopener noreferrer"&gt;Open Google Colab Notebook : QLearning vs SARSA Cliff Problem&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Neither. They answer different questions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Q-Learning&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;SARSA&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Type&lt;/td&gt;
&lt;td&gt;Off-policy&lt;/td&gt;
&lt;td&gt;On-policy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learns the value of...&lt;/td&gt;
&lt;td&gt;the &lt;em&gt;ideal&lt;/em&gt; greedy policy&lt;/td&gt;
&lt;td&gt;the policy &lt;em&gt;it's actually following&lt;/em&gt; (with exploration)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Attitude&lt;/td&gt;
&lt;td&gt;Optimist&lt;/td&gt;
&lt;td&gt;Realist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cliff behavior&lt;/td&gt;
&lt;td&gt;Learns the risky edge path, falls more &lt;em&gt;while training&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Learns the safer detour, fewer falls &lt;em&gt;while training&lt;/em&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Great for&lt;/td&gt;
&lt;td&gt;Reusing data, learning from demos, squeezing out the true optimum&lt;/td&gt;
&lt;td&gt;Settings where mistakes during learning are costly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbu20ja7dq4fyqilosyeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbu20ja7dq4fyqilosyeg.png" alt=" " width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two honest footnotes so nobody gets the wrong idea:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Q-Learning's &lt;em&gt;final&lt;/em&gt; greedy policy really is the optimal one. The edge path &lt;em&gt;is&lt;/em&gt; shortest. Its problem is the cost it pays &lt;em&gt;during training&lt;/em&gt;, not the policy it ends up with.&lt;/li&gt;
&lt;li&gt;SARSA isn't permanently stuck being cautious. If you shrink &lt;code&gt;ε&lt;/code&gt; toward zero as training goes on, SARSA's behavior and Q-Learning's converge on the same optimal policy. SARSA is cautious &lt;em&gt;because of exploration&lt;/em&gt;, not by nature.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftieqxwb4lb732dnummsf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftieqxwb4lb732dnummsf.png" alt="sarsa" width="797" height="89"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The divide that never went away
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pm92x20w5c4vkmsnj85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pm92x20w5c4vkmsnj85.png" alt="TD SARSA Q-learning" width="800" height="983"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Q-Learning vs SARSA looks like a niche algorithm detail. It turned out to be one of the &lt;strong&gt;big forks in the road of all of RL&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Off-policy&lt;/strong&gt; (Q-Learning, DQN, SAC): learn about the best policy &lt;em&gt;regardless of how you collected the data&lt;/em&gt;. Superpower: you can recycle old experience, which makes learning &lt;strong&gt;sample-efficient&lt;/strong&gt;. Cost: learning can be less stable, especially once neural networks get involved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On-policy&lt;/strong&gt; (SARSA, PPO, most policy-gradient methods): learn only from data produced by your &lt;em&gt;current&lt;/em&gt; behavior. Superpower: updates are consistent with what the agent really does, which tends to be &lt;strong&gt;more stable&lt;/strong&gt;. Cost: you have to throw data away after you use it, so it's &lt;strong&gt;less sample-efficient&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You'll see both camps again. PPO, an on-policy method, became the workhorse for fine-tuning large language models with human feedback (RLHF). DQN-style and SAC-style methods, off-policy, dominate where interaction with the world is expensive. Many of today's design debates in RL are really the same question Watkins and Rummery put on the table: &lt;em&gt;do I learn about what I could do, or about what I actually do?&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What 1988–1994 actually established
&lt;/h2&gt;

&lt;p&gt;Three things that weren't true in 1987 but were by 1994:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. A machine can learn good behavior without a map of its world.&lt;/strong&gt; Given a small enough problem (one a table can hold), Q-Learning learns the optimal policy purely from trial and error, with no transition model, and Watkins and Dayan proved it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. How you explore is a design choice, not a side effect.&lt;/strong&gt; Learn about the ideal (Q-Learning, off-policy) or learn about reality (SARSA, on-policy). Both are useful, and the choice shapes everything downstream.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The Q-table is just a function approximator in its simplest form.&lt;/strong&gt; Swap the table for something that generalizes, and the same update rule keeps working. The theory was already pointing at DQN, twenty years early.&lt;/p&gt;

&lt;p&gt;What was missing was the generalizing part. Tables collapse at scale, and neural networks were the obvious replacement, but training them with TD updates turned out to be surprisingly unstable. That problem stayed open for a long time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Next up: a neural network teaches itself backgammon
&lt;/h2&gt;

&lt;p&gt;While theory was getting tidy, one researcher quietly tried the "obviously unstable" thing anyway. In 1992, Gerald Tesauro paired a neural network with TD learning and had it play backgammon against itself, millions of times, with no hand-written strategy. It reached a level that rivaled the world's best human players.&lt;/p&gt;

&lt;p&gt;TD-Gammon was the first big proof that neural networks and RL could work together at scale. It also made &lt;strong&gt;self-play&lt;/strong&gt; a training paradigm, the same idea that eventually leads to AlphaGo, AlphaZero, and beyond.&lt;/p&gt;

&lt;p&gt;That's Blog 9.&lt;/p&gt;




&lt;h3&gt;
  
  
  Quick recap (if you only read this)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Model-free&lt;/strong&gt; = learn what to do without learning how the world works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TD(λ)&lt;/strong&gt; = a dial between impatient and patient learning; breadcrumbs (eligibility traces) spread credit backward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Q-Learning&lt;/strong&gt; = score &lt;em&gt;choices&lt;/em&gt;, not places; guaranteed to converge for tables; &lt;strong&gt;off-policy&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SARSA&lt;/strong&gt; = learn from what you actually do; &lt;strong&gt;on-policy&lt;/strong&gt;; safer when exploring is risky.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The table breaks at scale&lt;/strong&gt;, which sets up neural networks.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>rl</category>
    </item>
    <item>
      <title>RL 7: How Machines Learned to Guess Better — Sutton, Barto &amp; Temporal Difference Learning</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 17 Oct 2026 21:07:35 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-7-how-machines-learned-to-guess-better-sutton-barto-temporal-difference-learning-1a1l</link>
      <guid>https://dev.to/mitanshgor/rl-7-how-machines-learned-to-guess-better-sutton-barto-temporal-difference-learning-1a1l</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 7 of the RL series. In Blog 6, Werbos gave us backpropagation and Klopf gave us the idea of a "hedonistic" neuron that chases reward. Both were brilliant sparks. But sparks aren't a system. Nobody had yet built a clean method for learning from&lt;/em&gt; &lt;strong&gt;predictions&lt;/strong&gt; &lt;em&gt;as time unfolds. That is the job Richard Sutton and Andrew Barto took on between 1981 and 1984.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Where We Are, and Where We're Going
&lt;/h2&gt;

&lt;p&gt;Blog 6 left us with a gap. We had a way to adjust weights (backprop) and a motive for the learner (chase reward). What we were missing was an answer to a very practical question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;When the reward shows up late, who gets the credit?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By the end of this post you'll be able to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Explain the &lt;strong&gt;temporal credit assignment problem&lt;/strong&gt; in plain English.&lt;/li&gt;
&lt;li&gt;Read the three core formulas of RL (Return, Value, TD error) without flinching.&lt;/li&gt;
&lt;li&gt;Walk through &lt;strong&gt;TD learning by hand&lt;/strong&gt; on a tiny 3-step example.&lt;/li&gt;
&lt;li&gt;Explain why the &lt;strong&gt;Actor-Critic&lt;/strong&gt; split exists, and where you've already met its descendants.&lt;/li&gt;
&lt;li&gt;Know what Sutton's 1984 dissertation did, and &lt;em&gt;what it did not yet do&lt;/em&gt; (this part is a common misconception).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;/p&gt;
  Quick refresher: the words I'll use without re-explaining
  &lt;br&gt;
This series already covered these, so here's just the one-line version:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;State (s):&lt;/strong&gt; the situation the agent is in right now (a board position, a pole's angle).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action (a):&lt;/strong&gt; what the agent can do from that state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reward (R):&lt;/strong&gt; the immediate numeric feedback after an action.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy (π):&lt;/strong&gt; the agent's rulebook for picking actions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Episode:&lt;/strong&gt; one full run, from start to finish (one game, one attempt).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bellman equation:&lt;/strong&gt; the idea from &lt;strong&gt;Blog 3&lt;/strong&gt; that a state's worth can be written in terms of the next state's worth. Today we put it to work.
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;/p&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fqrzfa1mk1bodgsi36y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fqrzfa1mk1bodgsi36y.jpg" alt="sut and bar"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The Problem That Wouldn't Go Away: Temporal Credit Assignment
&lt;/h2&gt;

&lt;p&gt;Picture a chess game. You make 40 moves, then lose. Which move lost it?&lt;/p&gt;

&lt;p&gt;Maybe it was move 40, the blunder you can see. Or maybe move 12, a quiet pawn push that looked harmless and slowly strangled your position. No one stamped "mistake" on it. And the only feedback you got, &lt;em&gt;"you lost"&lt;/em&gt;, arrived 28 moves later.&lt;/p&gt;

&lt;p&gt;That is the &lt;strong&gt;Temporal Credit Assignment Problem&lt;/strong&gt;: when a reward arrives late, how do you decide which earlier decisions deserve the credit (or the blame)?&lt;/p&gt;

&lt;p&gt;The problem is older than Sutton. Samuel's checkers program (1959) already wrestled with it, and Marvin Minsky gave it its name in his 1961 paper &lt;em&gt;"&lt;a href="https://www.mit.edu/~kepner/Academic-ML-Papers/Ancient/Minsky1960.pdf" rel="noopener noreferrer"&gt;Steps Toward Artificial Intelligence&lt;/a&gt;."&lt;/em&gt; But in the early 1980s it was still a pile of clever hacks. Sutton and Barto's contribution was to turn it into a clean, mathematical story.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvia5x177kj1wgpuisazk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvia5x177kj1wgpuisazk.png" alt="who gets the credit ?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To attack this we need three tools. Think of them as three questions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;What am I trying to maximize?&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;The &lt;strong&gt;Return&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;How good is it to be here?&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;The &lt;strong&gt;Value Function&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;How do I fix my guess when I'm wrong?&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;TD Learning&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's take them one by one.&lt;/p&gt;


&lt;h2&gt;
  
  
  Tool 1: The Return (What Does "Good" Mean Over Time?)
&lt;/h2&gt;

&lt;p&gt;A single reward only tells you about one moment. But life, and games, are about the &lt;strong&gt;whole stream&lt;/strong&gt; of rewards ahead of you. So we add them up, giving less weight to the ones further away:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;G&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;⋯&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;k&lt;/span&gt;&lt;span class="mrel mtight"&gt;=&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;∞&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;k&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;k&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;This total is called the &lt;strong&gt;Return&lt;/strong&gt;. The symbol &lt;code&gt;γ&lt;/code&gt; (gamma, the &lt;em&gt;discount factor&lt;/em&gt;) is a number between 0 and 1 that sets how patient the agent is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A tiny example.&lt;/strong&gt; Say you'll get rewards of 0, 0, then 10 over the next three steps, and &lt;code&gt;γ = 0.9&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;G = 0 + (0.9 × 0) + (0.9² × 10) = 0 + 0 + 8.1 = 8.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The 10 is worth only 8.1 &lt;em&gt;to you today&lt;/em&gt; because it's two steps away. Same prize, further away, smaller feeling.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;γ&lt;/code&gt; close to &lt;strong&gt;1&lt;/strong&gt; → patient, plans far ahead.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;γ&lt;/code&gt; close to &lt;strong&gt;0&lt;/strong&gt; → short-sighted, grabs what's in front of it.&lt;/li&gt;
&lt;li&gt;It also keeps the math safe: for never-ending tasks, an undiscounted sum of rewards can grow without bound. Discounting keeps it finite.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbyoryp27bvb1ut9y28m3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbyoryp27bvb1ut9y28m3.png" alt="gama 0.9 vs gamma 0.5"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So the Return is what &lt;em&gt;actually&lt;/em&gt; happened to you from this moment on.&lt;/strong&gt; But when you're standing in a state, you haven't lived the future yet. You have to &lt;em&gt;guess&lt;/em&gt; it. That guess has a name.&lt;/p&gt;


&lt;h2&gt;
  
  
  Tool 2: The Value Function (An Honest Guess About the Future)
&lt;/h2&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;[&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;G&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;Read it out loud: &lt;em&gt;"The value of state s, under policy π, is the **average Return&lt;/em&gt;* I expect if I start in s and keep following π."*&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk0s8twbev5o7lmaxdug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk0s8twbev5o7lmaxdug.png" alt="value function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt; = the score you actually got on this run.&lt;br&gt;
&lt;strong&gt;Value&lt;/strong&gt; = the score you'd &lt;em&gt;expect on average&lt;/em&gt; from here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Two chess positions can both pay zero reward right now, yet one is a winning attack and the other a slow trap. Their &lt;strong&gt;values&lt;/strong&gt; differ even though their immediate rewards don't. That's the whole point of the value function: it lets you judge a situation &lt;em&gt;before&lt;/em&gt; the payoff arrives.&lt;/p&gt;

&lt;p&gt;This gives us the cleanest way to see what Sutton and Barto were after:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reactive learning:&lt;/strong&gt; "I just got +10, so my last action was good."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Predictive learning:&lt;/strong&gt; "I'm in a state that usually leads to +10, so this state is already good, &lt;em&gt;right now&lt;/em&gt;."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And remember the Bellman idea from &lt;strong&gt;Blog 3&lt;/strong&gt;: a state's value can be written using the &lt;em&gt;next&lt;/em&gt; state's value. That small fact is about to become a learning machine.&lt;/p&gt;




&lt;h2&gt;
  
  
  1981: When Pavlov Met the Computer
&lt;/h2&gt;

&lt;p&gt;In 1981 Sutton and Barto published &lt;em&gt;"&lt;a href="https://www.researchgate.net/publication/15908478_Toward_a_Modern_Theory_of_Adaptive_Networks_Expectation_and_Prediction" rel="noopener noreferrer"&gt;Toward a Modern Theory of Adaptive Networks: Expectation and Prediction.&lt;/a&gt;"&lt;/em&gt; It was unusual for an AI paper: it started with Pavlov's dogs.&lt;/p&gt;

&lt;p&gt;You know the experiment. Bell, then food. Repeat. Eventually the dog drools at the bell alone.&lt;/p&gt;

&lt;p&gt;Psychologists called it &lt;em&gt;association&lt;/em&gt;. Sutton and Barto asked a sharper question: &lt;strong&gt;what is the dog actually computing?&lt;/strong&gt; Their answer was that the dog is learning to &lt;em&gt;predict&lt;/em&gt; food from the bell. The bell becomes valuable because of what it forecasts.&lt;/p&gt;

&lt;p&gt;Two things followed from that framing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the prediction is right, there's nothing to learn.&lt;/li&gt;
&lt;li&gt;When it's wrong, the &lt;em&gt;surprise&lt;/em&gt; is what drives the update.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Surprise as the learning signal.&lt;/em&gt; Hold on to that phrase, because it is the entire next section.&lt;/p&gt;

&lt;p&gt;(A fair footnote: the 1981 model was a &lt;em&gt;precursor&lt;/em&gt; to TD learning, not TD itself, and similar ideas had been floating around, for example in Ian Witten's 1977 work. The clean, general version came a few years later.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozdwdh72dexo3sin0nfh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozdwdh72dexo3sin0nfh.png" alt="pavln"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Tool 3: Temporal Difference Learning (Fix Your Guess With a Better Guess)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnb2b2ar48t4e9kb8c49.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnb2b2ar48t4e9kb8c49.jpeg" alt="child play"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The old way: wait until the end
&lt;/h3&gt;

&lt;p&gt;The classic approach is &lt;strong&gt;Monte Carlo&lt;/strong&gt;: play the whole episode, see the final outcome, then go back and update every state you visited. If the game lasts 100 moves, you learn &lt;em&gt;nothing&lt;/em&gt; until move 100. And if the task never ends? You never learn at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xy0dusbwuc8vyfkuxx5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xy0dusbwuc8vyfkuxx5.png" alt="MC learning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sutton's idea: don't wait, update your guess using your &lt;em&gt;next&lt;/em&gt; guess
&lt;/h3&gt;

&lt;p&gt;You're driving home. When you leave the office, you estimate 30 minutes. Five minutes in, you hit a traffic jam and revise to 60. You didn't have to reach home to realize your first guess was off. &lt;strong&gt;The gap between your two guesses is the learning signal.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That gap is the &lt;strong&gt;TD error&lt;/strong&gt; (TD = &lt;em&gt;Temporal Difference&lt;/em&gt;, the difference between estimates at two moments in time):&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γV&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtccdhxjixh3k4pbycl3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtccdhxjixh3k4pbycl3.png" alt="TD learning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the update that uses it, called &lt;strong&gt;TD(0)&lt;/strong&gt;:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyl7p67sfelq0lroivnhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyl7p67sfelq0lroivnhk.png" alt="value function update"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In plain words:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;V(S_t)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;My current guess for the state I'm in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;R_{t+1} + γV(S_{t+1})&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The &lt;strong&gt;TD target&lt;/strong&gt;: what actually happened next, plus my guess about everything after&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;δ_t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The &lt;strong&gt;surprise&lt;/strong&gt;: target minus guess&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;α&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The &lt;strong&gt;learning rate&lt;/strong&gt;: how big a step I take toward the target&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice the trick. The target contains &lt;code&gt;V(S_{t+1})&lt;/code&gt;, which is itself &lt;em&gt;just a guess&lt;/em&gt;. We're improving a guess using another guess. This is called &lt;strong&gt;bootstrapping&lt;/strong&gt; (pulling yourself up by your own bootstraps), and it feels suspicious until you see it work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's actually do it: a 3-step world
&lt;/h3&gt;

&lt;p&gt;Here's the smallest example I could build. A little robot walks &lt;code&gt;A → B → C → Goal&lt;/code&gt;. It gets &lt;strong&gt;+1 only when it reaches the Goal&lt;/strong&gt;, and 0 otherwise. Set &lt;code&gt;γ = 1&lt;/code&gt; and &lt;code&gt;α = 0.5&lt;/code&gt;. All guesses start at 0.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5tbomi7yex1w8jqtefs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5tbomi7yex1w8jqtefs1.png" alt="path"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Episode 1.&lt;/strong&gt; The robot walks A→B→C→Goal.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A→B: &lt;code&gt;δ = 0 + V(B) − V(A) = 0 − 0 = 0&lt;/code&gt; → V(A) stays 0&lt;/li&gt;
&lt;li&gt;B→C: &lt;code&gt;δ = 0 + V(C) − V(B) = 0&lt;/code&gt; → V(B) stays 0&lt;/li&gt;
&lt;li&gt;C→Goal: &lt;code&gt;δ = 1 + 0 − V(C) = 1&lt;/code&gt; → V(C) = 0 + 0.5 × 1 = &lt;strong&gt;0.5&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only C learned anything: it's the only state next to the reward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Episode 2.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A→B: &lt;code&gt;δ = 0 + 0 − 0 = 0&lt;/code&gt; → V(A) = 0&lt;/li&gt;
&lt;li&gt;B→C: &lt;code&gt;δ = 0 + 0.5 − 0 = 0.5&lt;/code&gt; → V(B) = &lt;strong&gt;0.25&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;C→Goal: &lt;code&gt;δ = 1 − 0.5 = 0.5&lt;/code&gt; → V(C) = &lt;strong&gt;0.75&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Episode 3.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A→B: &lt;code&gt;δ = 0.25 − 0 = 0.25&lt;/code&gt; → V(A) = &lt;strong&gt;0.125&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;B→C: &lt;code&gt;δ = 0.75 − 0.25 = 0.5&lt;/code&gt; → V(B) = &lt;strong&gt;0.5&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;C→Goal: &lt;code&gt;δ = 1 − 0.75 = 0.25&lt;/code&gt; → V(C) = &lt;strong&gt;0.875&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;After episode&lt;/th&gt;
&lt;th&gt;V(A)&lt;/th&gt;
&lt;th&gt;V(B)&lt;/th&gt;
&lt;th&gt;V(C)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0.25&lt;/td&gt;
&lt;td&gt;0.75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0.125&lt;/td&gt;
&lt;td&gt;0.5&lt;/td&gt;
&lt;td&gt;0.875&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Watch what happened. &lt;strong&gt;The news of the reward travels backward, one state per step, like a rumor passing down a line.&lt;/strong&gt; Nobody had to wait for a final verdict and replay history. Each state corrected itself using its neighbor's opinion. That &lt;em&gt;is&lt;/em&gt; temporal credit assignment, solved with arithmetic you did on a napkin.&lt;/p&gt;

&lt;p&gt;(Run it forever and all three values head toward 1.0, the true value.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3oqwnwr1j7rg4m54nj7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3oqwnwr1j7rg4m54nj7m.png" alt="backward example graph"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  So is TD just "better" than Monte Carlo?
&lt;/h3&gt;

&lt;p&gt;Not exactly. They trade off differently:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Monte Carlo&lt;/th&gt;
&lt;th&gt;TD&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Learns when?&lt;/td&gt;
&lt;td&gt;Only at episode end&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Every step&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works on never-ending tasks?&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Yes&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Uses real full outcomes?&lt;/td&gt;
&lt;td&gt;Yes (no bootstrapping)&lt;/td&gt;
&lt;td&gt;No, it leans on its own guesses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical downside&lt;/td&gt;
&lt;td&gt;High variance (one lucky/unlucky game swings everything)&lt;/td&gt;
&lt;td&gt;Some bias (early guesses are wrong, and they teach the next ones)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;td&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzu9yofdf3xdskj0eycug.gif" alt="MC high variance"&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm2aw1eln5zuujxpkj4zn.gif" alt="TD high bias"&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;td&gt;
      &lt;a href="https://drive.google.com/file/d/124QLA-YdWjf539aV4gt4tcuJb5yU3yOG/view?usp=sharing" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;View the interactive Mote Carlo video&lt;/a&gt;

    &lt;/td&gt;
    &lt;td&gt;
      &lt;a href="https://drive.google.com/file/d/1Pzt1LsZTe_QjPhHf-1tXNw7zUiR9OPm4/view?usp=sharing" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;View the interactive TD Learning Video&lt;/a&gt;

    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F78xj3cmq9li89yj5mo00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F78xj3cmq9li89yj5mo00.png" alt="TD vs MC variancs vs bias"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TD often learns faster in practice precisely because it's low-variance and online, but the real win is that it can learn &lt;em&gt;while living&lt;/em&gt;. Sutton would later show (Blog 8) how to dial smoothly between the two with &lt;code&gt;λ&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And here's why this matters beyond the toy: that &lt;code&gt;δ&lt;/code&gt; signal is the ancestor of the learning signal in Q-learning, DQN, and the critics inside modern algorithms. The machinery around it keeps changing; the "surprise" at the center doesn't.&lt;/p&gt;




&lt;h2&gt;
  
  
  1983: Actor-Critic (Splitting the Brain in Two)
&lt;/h2&gt;

&lt;p&gt;Now we have prediction. But prediction alone doesn't &lt;em&gt;act&lt;/em&gt;. The agent still has to decide what to do next.&lt;/p&gt;

&lt;p&gt;The naive route is to look at every possible next state and pick the one with the highest &lt;code&gt;V&lt;/code&gt;. But that requires knowing how the world responds to each action, the environment's transition probabilities, which in real problems you usually don't have.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Barto, Sutton, and Anderson (1983)&lt;/strong&gt; in &lt;em&gt;"&lt;a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=6313077" rel="noopener noreferrer"&gt;Neuronlike Adaptive Elements That Can Solve Difficult Learning Control Problems&lt;/a&gt;"&lt;/em&gt; took a different route. Make &lt;strong&gt;two&lt;/strong&gt; learners and let them specialize:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8v4dhgwkr5ddtlalwjw.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8v4dhgwkr5ddtlalwjw.webp" alt="actor critic diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Actor&lt;/strong&gt; holds the policy. It picks actions. It doesn't judge them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Critic&lt;/strong&gt; holds the value function. It watches and computes the TD error &lt;code&gt;δ&lt;/code&gt;, the surprise.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of an athlete and a coach:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Actor (athlete):&lt;/strong&gt; "I'll try jumping."&lt;br&gt;
&lt;strong&gt;Critic (coach):&lt;/strong&gt; "That went 0.3 better than I expected. Do more of that."&lt;br&gt;
&lt;em&gt;or&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Critic:&lt;/strong&gt; "That went 0.8 worse than I expected. Don't."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The coach's feedback &lt;em&gt;is&lt;/em&gt; the TD error we just learned. Same signal, new job: it now steers the Actor.&lt;/p&gt;

&lt;p&gt;In today's notation, the Actor's update looks like this:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord mathnormal"&gt;θ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∝&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∇&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;θ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop"&gt;lo&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;θ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7biq5tfjarb7vx2hbnu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7biq5tfjarb7vx2hbnu.png" alt="preference update"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Read it as: &lt;em&gt;"Nudge the actor's settings so the action it just took becomes more likely if &lt;code&gt;δ&lt;/code&gt; is positive, and less likely if &lt;code&gt;δ&lt;/code&gt; is negative."&lt;/em&gt; (A note for the careful: this log-probability form is how we write it &lt;strong&gt;today&lt;/strong&gt;. The 1983 paper used a simpler, more hand-built version of the same idea, and the clean policy-gradient math arrived later in the 1990s. The &lt;em&gt;spirit&lt;/em&gt;, a TD error steering the actor, is exactly 1983.)&lt;/p&gt;

&lt;h3&gt;
  
  
  Why split them at all?
&lt;/h3&gt;

&lt;p&gt;If one system both acts and evaluates, then raw luck sneaks straight into behavior. One lucky win and the agent thinks "that move is genius!" and stops exploring. Good luck and skill look identical.&lt;/p&gt;

&lt;p&gt;The Critic fixes this by averaging over time, so the Actor responds to a &lt;em&gt;smoothed, expectation-based&lt;/em&gt; signal rather than single noisy outcomes. Result: more stable learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  The pole-balancing demo
&lt;/h3&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/OmSr3bES4Fw" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The team tested it on the classic &lt;strong&gt;cart-pole&lt;/strong&gt; task: push a cart left or right to keep a pole balanced upright. No physics equations given, no pre-programmed strategy, only failure signals and the Actor-Critic loop. It learned to balance.&lt;/p&gt;

&lt;p&gt;Two honest caveats that make the story &lt;em&gt;more&lt;/em&gt; interesting rather than less: this was a &lt;strong&gt;simulation&lt;/strong&gt;, and the system divided the pole's state into coarse "boxes," a trick borrowed from Michie and Chambers' earlier BOXES work (1968). So it wasn't the first learner to balance a pole. What was new was the &lt;strong&gt;architecture&lt;/strong&gt;: an adaptive critic generating a better teaching signal for an adaptive actor, learning from a rare, delayed failure signal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where you've already met its descendants
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PPO&lt;/strong&gt; (Blog 12) is an actor-critic method, and it was the RL step used to fine-tune models like InstructGPT and ChatGPT.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;RLHF&lt;/strong&gt;, careful with the mapping: the LLM is the &lt;em&gt;Actor&lt;/em&gt;, a separate &lt;strong&gt;reward model&lt;/strong&gt; scores outputs, and PPO also trains its own &lt;strong&gt;value network&lt;/strong&gt; (that's the Critic). The reward model is &lt;em&gt;not&lt;/em&gt; the critic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GRPO&lt;/strong&gt; (Blog 16) removes the learned Critic and uses group-relative scores instead. A good reminder that the &lt;em&gt;idea&lt;/em&gt; (get a baseline to compare against) survives even when the &lt;em&gt;component&lt;/em&gt; disappears.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1984: The Dissertation (and a Myth Worth Clearing Up)
&lt;/h2&gt;

&lt;p&gt;Sutton's 1984 PhD thesis, &lt;em&gt;"&lt;a href="https://web.cs.umass.edu/publication/docs/1984/UM-CS-1984-002.pdf" rel="noopener noreferrer"&gt;Temporal Credit Assignment in Reinforcement Learning&lt;/a&gt;,"&lt;/em&gt; is a landmark. It's where the ideas above were pulled together and studied systematically: prediction learning, the adaptive critic, and the credit assignment problem treated as &lt;em&gt;the&lt;/em&gt; central issue.&lt;/p&gt;

&lt;p&gt;Here's the myth to clear up. You'll often read that this thesis &lt;strong&gt;proved TD learning converges&lt;/strong&gt;. That's not quite right, and the true timeline is more interesting:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Year&lt;/th&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1984&lt;/td&gt;
&lt;td&gt;Sutton's thesis: develops the TD idea and the actor-critic ("adaptive heuristic critic") view, with experiments showing it works&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1988&lt;/td&gt;
&lt;td&gt;Sutton's &lt;em&gt;"Learning to Predict by the Methods of Temporal Differences"&lt;/em&gt;: formal analysis (convergence for TD(0) in a limited setting), and the full &lt;strong&gt;TD(λ)&lt;/strong&gt; family&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1992&lt;/td&gt;
&lt;td&gt;Peter Dayan: convergence &lt;strong&gt;with probability 1&lt;/strong&gt; for the tabular case&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1997&lt;/td&gt;
&lt;td&gt;Tsitsiklis &amp;amp; Van Roy: convergence analysis for TD with &lt;em&gt;linear&lt;/em&gt; function approximation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So the accurate sentence is: &lt;em&gt;1984 gave RL its central framework, and the rigorous proofs matured over the following decade.&lt;/em&gt; Still a huge deal, and honestly a better story: science rarely arrives in one tidy "proof moment."&lt;/p&gt;

&lt;h3&gt;
  
  
  The Bellman chase
&lt;/h3&gt;

&lt;p&gt;The math TD chases is the Bellman idea from Blog 3. In its honest form (with an average over what could happen next):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0k06by63ys1dh02yf911.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0k06by63ys1dh02yf911.png" alt="Bellman recursion"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;[&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;TD never solves this equation outright. It &lt;strong&gt;chases&lt;/strong&gt; it: each step nudges &lt;code&gt;V(S_t)&lt;/code&gt; toward one sampled version of the right-hand side. Averaged over many samples, with a suitably shrinking learning rate, the chase lands on the true values. That's the convergence story in a sentence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backprop vs TD
&lt;/h3&gt;

&lt;p&gt;A cleaner way to think about it: they're not rivals, they do &lt;strong&gt;different jobs&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backprop&lt;/strong&gt; answers: &lt;em&gt;"Given a target, how do I adjust my weights to hit it?"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TD&lt;/strong&gt; answers: &lt;em&gt;"Where does the target come from when no one gives me labels?"&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In supervised learning, a human supplies the target ("this image is a cat"). In RL, nobody does, so TD builds one from reward plus your &lt;em&gt;next&lt;/em&gt; estimate. The target keeps moving as your guesses improve, which is what makes this subtle. Later systems combined the two: a neural network (trained by backprop) learns the values, and TD supplies the targets.&lt;/p&gt;

&lt;p&gt;This is also why you can't just train a great game-playing agent by imitating a database of human games. The true value of a position depends on what play follows, and that only gets discovered through experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyi5pyvrzrjhdrtybplr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyi5pyvrzrjhdrtybplr0.png" alt="supervised vs TD"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  TD(λ): the preview
&lt;/h3&gt;

&lt;p&gt;The thesis also planted seeds of &lt;strong&gt;TD(λ)&lt;/strong&gt;, a knob (&lt;code&gt;λ&lt;/code&gt;) that slides between TD(0) (look one step ahead) and Monte Carlo (look to the end of the episode). The full treatment is in Blog 8.&lt;/p&gt;




&lt;h2&gt;
  
  
  What 1981–1984 Actually Built
&lt;/h2&gt;

&lt;p&gt;Sutton and Barto didn't invent every piece. Thorndike gave us reward-shaped behavior (1898), Bellman gave us value functions (1957), and Werbos gave us backprop (1974). What they did was &lt;strong&gt;assemble those pieces into a coherent, learnable system for improving predictions as time unfolds.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Idea&lt;/th&gt;
&lt;th&gt;What it gave us&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Return&lt;/strong&gt; &lt;code&gt;G_t&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A definition of what the agent is optimizing over time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Value Function&lt;/strong&gt; &lt;code&gt;V(s)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A way to judge a state &lt;em&gt;before&lt;/em&gt; the reward shows up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TD Learning&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Learn online by correcting a guess with a better guess&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Actor-Critic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Split "doing" from "judging" for more stable learning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1984 Thesis&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The framework that made credit assignment &lt;em&gt;the&lt;/em&gt; central problem&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;1981–1984 Idea&lt;/th&gt;
&lt;th&gt;Modern Descendant&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Value prediction&lt;/td&gt;
&lt;td&gt;Value networks (AlphaGo); critics in PPO&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TD learning&lt;/td&gt;
&lt;td&gt;Q-learning, DQN, and the bootstrapped targets inside most value-based RL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actor-Critic&lt;/td&gt;
&lt;td&gt;PPO (used in ChatGPT-style fine-tuning); a family of modern policy-gradient methods&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Temporal credit assignment&lt;/td&gt;
&lt;td&gt;Process reward models; step-level feedback for chain-of-thought&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TD(λ) seeds&lt;/td&gt;
&lt;td&gt;Eligibility traces in modern control&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Cheat Sheet (screenshot this)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Return&lt;/strong&gt; = total (discounted) reward you actually get from here on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt; = the Return you &lt;em&gt;expect&lt;/em&gt; on average from a state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TD error&lt;/strong&gt; &lt;code&gt;δ&lt;/code&gt; = (reward + discounted next-state value) − (current-state value) = &lt;em&gt;the surprise&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bootstrapping&lt;/strong&gt; = updating a guess using another guess.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Actor&lt;/strong&gt; picks actions; &lt;strong&gt;Critic&lt;/strong&gt; judges them with &lt;code&gt;δ&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Credit assignment&lt;/strong&gt; = deciding which past decisions caused a delayed result.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Next Up
&lt;/h2&gt;

&lt;p&gt;We now have prediction (TD) and a stable acting loop (Actor-Critic). But everything so far still leans on one convenient assumption: that we know something about how the world behaves.&lt;/p&gt;

&lt;p&gt;What if we know &lt;em&gt;nothing&lt;/em&gt;? No transition probabilities, no model, just raw experience?&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Blog 8&lt;/strong&gt;, we first meet Sutton's 1988 &lt;strong&gt;TD(λ)&lt;/strong&gt; paper, the formal bridge between TD and Monte Carlo, and then &lt;strong&gt;Chris Watkins' Q-Learning (1989)&lt;/strong&gt;, the first algorithm proven to converge to the optimal policy with no model of the environment at all.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;See you there.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>reinforcementlearning</category>
    </item>
    <item>
      <title>RL 6: Pleasure-Seeking Neurons and the Birth of Backpropagation (1972–1980)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 10 Oct 2026 21:33:29 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-6-pleasure-seeking-neurons-and-the-birth-of-backpropagation-1972-1980-4b75</link>
      <guid>https://dev.to/mitanshgor/rl-6-pleasure-seeking-neurons-and-the-birth-of-backpropagation-1972-1980-4b75</guid>
      <description>&lt;p&gt;&lt;em&gt;Quick recap from Blog 5: Learning Automata could adapt to what was happening right now, but they were hopeless at delayed consequences. A chess move that loses you the game 20 turns later. A word that quietly breaks a sentence three clauses down. They had no way to connect "what I did" with "what happened much later."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post is about the two people who went after that gap, and the third person who spotted a problem hiding behind it. By the end you'll know what an eligibility trace is, how backpropagation actually works (with a tiny example), and why every modern AI system still runs on ideas from this decade.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  First, the problem in plain English
&lt;/h2&gt;

&lt;p&gt;Imagine you're baking cookies for the first time. At step 2 you accidentally dump in a tablespoon of salt instead of a teaspoon. You keep going: mix, chill, shape, bake. At step 50 (taste time) the cookies are awful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjl8rrx8qupy7bu4nlhn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjl8rrx8qupy7bu4nlhn0.png" alt="Cooking cookies baking" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now ask yourself: &lt;strong&gt;which step was the mistake?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You didn't taste anything at step 2. The feedback only showed up at the very end. To learn, you need a way to trace the bad result &lt;em&gt;back&lt;/em&gt; to the step that caused it. That's the &lt;strong&gt;credit assignment problem&lt;/strong&gt; (or "blame assignment", if you prefer): when something good or bad happens, which of your earlier decisions deserves the credit or the blame?&lt;/p&gt;

&lt;p&gt;By the early 1970s the field had two things that didn't talk to each other:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bellman's equations&lt;/strong&gt; (Blog 3): mathematically perfect and provably optimal, but they need a complete model of the world. Nobody has that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Samuel's checkers player and Tsetlin's automata&lt;/strong&gt; (Blogs 4 and 5): practical and adaptive, but with no theory behind them and no good answer for late-arriving consequences.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The 1970s produced three ideas that started to close that gap. Here's the roadmap so you always know where we are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Klopf&lt;/strong&gt; gives a single neuron a &lt;em&gt;drive&lt;/em&gt; and a short &lt;em&gt;memory of what it just did&lt;/em&gt;. (Who gets credit, and when?)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Werbos&lt;/strong&gt; gives a whole network a &lt;em&gt;direction&lt;/em&gt;: a method to push blame backward through many layers. (How far back does the blame go?)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grossberg&lt;/strong&gt; adds a &lt;em&gt;warning&lt;/em&gt;: learn too eagerly and you'll erase what you already knew. (How do we keep our old skills?)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then we'll see how &lt;strong&gt;Adaptive Dynamic Programming&lt;/strong&gt; wired them together, and how it produced the Actor-Critic idea that still runs inside modern AI.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick glossary
&lt;/h2&gt;

&lt;p&gt;You'll see these words a lot. Don't memorize them, just glance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Neuron (artificial):&lt;/strong&gt; a tiny calculator. It takes numbers in, multiplies each by a &lt;em&gt;weight&lt;/em&gt;, adds them up, and outputs a result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weight:&lt;/strong&gt; how much the neuron "listens" to one particular input. Learning = adjusting weights.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reward:&lt;/strong&gt; a number telling the system "that went well" (positive) or "that went badly" (negative).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expectation / baseline:&lt;/strong&gt; the reward the system &lt;em&gt;predicted&lt;/em&gt; it would get.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer:&lt;/strong&gt; a group of neurons. A network stacks layers: input -&amp;gt; hidden layers -&amp;gt; output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loss:&lt;/strong&gt; a single number measuring how wrong the output was. Lower is better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient:&lt;/strong&gt; a list of "if I nudge this weight a little, how much does the loss change?"&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Harry Klopf and the Hedonistic Neuron (1972)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05wyqbelnu8wyct40rpa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05wyqbelnu8wyct40rpa.png" alt="Harry Klopf" width="800" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most of the 1970s AI crowd was busy building symbolic systems: expert systems, logic provers, decision trees. Harry Klopf, a researcher at the US Air Force Cambridge Research Laboratories, was looking at a single neuron and asking something stranger.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What if the neuron isn't a passive wire? What if it wants something?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In his 1972 report, &lt;em&gt;Brain Function and Adaptive Systems: A Heterostatic Theory&lt;/em&gt;, Klopf proposed that neurons act like tiny &lt;strong&gt;hedonists&lt;/strong&gt;: pleasure-seekers that strengthen the connections that led to good outcomes and weaken the ones that didn't.&lt;/p&gt;

&lt;p&gt;That was a direct challenge to the textbook picture of a neuron as a threshold switch: inputs in, weighted sum, fire or don't. In that picture the neuron has no memory of outcomes and no preference about them. Klopf said that couldn't be the whole story.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6bzppbx0goas0barlwds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6bzppbx0goas0barlwds.png" alt="classics vs klopf neuron" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Heterostasis vs. homeostasis (the thermostat vs. the athlete)
&lt;/h3&gt;

&lt;p&gt;Biology textbooks of the time said living systems seek &lt;strong&gt;homeostasis&lt;/strong&gt;: balance and stability. Think of a &lt;strong&gt;thermostat&lt;/strong&gt;. It wants the room at 21°C. Hit 21 and it relaxes.&lt;/p&gt;

&lt;p&gt;Klopf proposed &lt;strong&gt;heterostasis&lt;/strong&gt;: a drive to push &lt;em&gt;beyond&lt;/em&gt; the comfortable state toward something better. Think of an &lt;strong&gt;athlete&lt;/strong&gt;. Hitting last month's personal best isn't "done", it's the new starting line.&lt;/p&gt;

&lt;p&gt;Why does this matter for AI? Because it reframes learning as &lt;em&gt;forward-looking&lt;/em&gt;. A thermostat-style learner stops when things are fine. A heterostat-style learner keeps asking "can I do better than I expected?" And that is exactly what reinforcement learning is.&lt;/p&gt;

&lt;h3&gt;
  
  
  The timing problem, and the eligibility trace
&lt;/h3&gt;

&lt;p&gt;Back to the cookies. Klopf hit the same wall: rewards arrive &lt;em&gt;after&lt;/em&gt; the action that caused them. When the reward finally shows up, how does the neuron know which of its recent activity deserves credit?&lt;/p&gt;

&lt;p&gt;His answer: the &lt;strong&gt;eligibility trace&lt;/strong&gt;. Think of it like &lt;strong&gt;a glowing footprint&lt;/strong&gt;. When a connection is active, it leaves a footprint that fades over time. If a reward arrives while the footprint is still glowing, that connection is "eligible" for credit. If the footprint has faded, it isn't.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpdv0rxo0u28at04xjxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpdv0rxo0u28at04xjxr.png" alt="eligibility trace" width="800" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a simplified teaching version of the idea as an update rule (Klopf's own later formulations got more elaborate, but this captures the heart of it):&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;w&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;[&lt;/span&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;ˉ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;τ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Let's read it piece by piece:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Δw_i&lt;/code&gt;: how much to change the weight on input &lt;code&gt;i&lt;/code&gt; (the "learning step").&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;α&lt;/code&gt; (alpha): the learning rate, i.e., how big a step to take.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r(t)&lt;/code&gt;: the reward you actually got.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r̄(t)&lt;/code&gt;: the reward you &lt;em&gt;expected&lt;/em&gt; to get.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x_i(t − τ)&lt;/code&gt;: the footprint, i.e., how active input &lt;code&gt;i&lt;/code&gt; was a moment ago.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The middle piece, &lt;code&gt;r − r̄&lt;/code&gt;, is the important one. It's &lt;strong&gt;surprise&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Got &lt;em&gt;more&lt;/em&gt; than expected (&lt;code&gt;r &amp;gt; r̄&lt;/code&gt;)? Strengthen whatever was recently active.&lt;/li&gt;
&lt;li&gt;Got &lt;em&gt;less&lt;/em&gt; than expected? Weaken it.&lt;/li&gt;
&lt;li&gt;Got exactly what you expected? Change nothing. Nothing to learn.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flb1g14i860rjkdf2wbhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flb1g14i860rjkdf2wbhz.png" alt="surprise FACTOR" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; you order your usual coffee and it's good. No surprise, no learning. You try a new cafe, and the coffee is fantastic. Big positive surprise, and your brain strongly reinforces "go to &lt;em&gt;that&lt;/em&gt; cafe." Learning is driven by the &lt;em&gt;gap&lt;/em&gt;, not by the raw reward.&lt;/p&gt;

&lt;p&gt;Hold onto this "surprise" idea. In Blog 8, Richard Sutton turns it into the &lt;strong&gt;TD error&lt;/strong&gt;, which is arguably the most important quantity in all of RL. Klopf had the biological intuition first; the math came later.&lt;/p&gt;

&lt;p&gt;And the footprint idea didn't die either: modern algorithms called TD(λ) still use eligibility traces in essentially this form.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pause and check.&lt;/strong&gt; Can you say, in one sentence, why a neuron needs &lt;em&gt;both&lt;/em&gt; a surprise signal and an eligibility trace? (Surprise tells it &lt;em&gt;how much&lt;/em&gt; to change. The trace tells it &lt;em&gt;what&lt;/em&gt; to change.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Where we are:&lt;/strong&gt; Klopf gave a neuron a drive and a short memory. But a single neuron is tiny. What happens when you have layers of them, and the reward only connects to the last layer? That's the next problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  Paul Werbos and the Algorithm Nobody Read (1974)
&lt;/h2&gt;

&lt;p&gt;A neuron that &lt;em&gt;wants&lt;/em&gt; reward but can't figure out &lt;em&gt;which of its decisions caused it&lt;/em&gt; will thrash forever. And this gets brutal in multi-layer networks. If the final answer is wrong, which weight, in which layer, is responsible? In 1974, nobody had a practical answer for neural networks.&lt;/p&gt;

&lt;p&gt;Paul Werbos did. Getting anyone to pay attention was the hard part.&lt;/p&gt;

&lt;p&gt;In his 1974 Harvard PhD thesis, &lt;em&gt;Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences&lt;/em&gt;, Werbos described how to train multi-layer neural networks by propagating error &lt;strong&gt;backward&lt;/strong&gt; through the layers. Today we call this &lt;strong&gt;backpropagation&lt;/strong&gt; (often just "backprop").&lt;/p&gt;

&lt;h3&gt;
  
  
  Backprop without the scary math: the assembly line
&lt;/h3&gt;

&lt;p&gt;Picture a three-station assembly line making a gadget. Station 1 passes its work to Station 2, then Station 3, then the finished gadget gets inspected. The inspector says: "This is off by 6 millimeters."&lt;/p&gt;

&lt;p&gt;Whose fault is that? The inspector can only see the final product. But here's the trick:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Station 3 asks: "How much did &lt;em&gt;my&lt;/em&gt; output contribute to that error?" It can answer directly, because it's the last one.&lt;/li&gt;
&lt;li&gt;Station 3 tells Station 2: "Here's how sensitive the final result is to what you gave me."&lt;/li&gt;
&lt;li&gt;Station 2 uses that to work out its own share of blame, then tells Station 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Blame flows &lt;strong&gt;backward&lt;/strong&gt;, station by station, each one using what the next one told it. That's backpropagation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwffjs0isao2hnr6nznms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwffjs0isao2hnr6nznms.png" alt="Back prop" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The chain rule, with gears
&lt;/h3&gt;

&lt;p&gt;The math behind this is the &lt;strong&gt;chain rule&lt;/strong&gt; from calculus, and it's much friendlier than its name. Here's the idea with gears.&lt;/p&gt;

&lt;p&gt;Say turning Knob A by 1 unit moves Knob B by 3 units. And turning Knob B by 1 unit moves the final output by 2 units. Then turning Knob A by 1 unit moves the output by &lt;strong&gt;3 × 2 = 6 units&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's the whole chain rule: &lt;em&gt;when effects are chained together, you multiply the sensitivities&lt;/em&gt;.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;w&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;L&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;L&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;w&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fui9fm0loq9hrb1obpnsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fui9fm0loq9hrb1obpnsp.png" alt="chain rule" width="600" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Translating the symbols:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;L&lt;/code&gt;: the loss (how wrong the final output was).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;a&lt;/code&gt;: a neuron's output (its "activation").&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;z&lt;/code&gt;: the neuron's input sum &lt;em&gt;before&lt;/em&gt; it produces its output.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w_i&lt;/code&gt;: the weight we want to adjust.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read the equation left to right as a story: "How much does the loss change if I nudge this weight?" = "how much the loss changes with the neuron's output" × "how much the output changes with its input sum" × "how much the input sum changes with the weight." Three gear ratios multiplied together. Do this for every weight in every layer and you get the &lt;strong&gt;gradient&lt;/strong&gt;: a complete to-do list of nudges that reduce the error.&lt;/p&gt;

&lt;p&gt;For the first time, a multi-layer network had a principled way to learn: not just the output layer, but &lt;em&gt;every&lt;/em&gt; layer, including the ones far from the reward.&lt;/p&gt;

&lt;h3&gt;
  
  
  Werbos's bigger vision: backprop as a tool for Bellman
&lt;/h3&gt;

&lt;p&gt;Here's the part that matters for this series. Werbos didn't think of backprop as just "neural network training." He saw it as a way to make &lt;strong&gt;Bellman's equations&lt;/strong&gt; usable on real problems. Remember from Blog 3: Bellman's math is perfect but chokes on large problems because you'd need a giant table with an entry for every possible situation. Werbos's idea: don't store the table, &lt;em&gt;approximate&lt;/em&gt; it with a neural network and train that network with backprop. He called this framework &lt;strong&gt;Adaptive Dynamic Programming&lt;/strong&gt; (ADP).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcf7ynuiimqzv2mjqcpcd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcf7ynuiimqzv2mjqcpcd.png" alt="BE + BACKPROP" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That exact idea (a neural network standing in for a value table) is what DeepMind used in DQN in 2013, thirty-nine years after Werbos's thesis (Blog 11). He saw the destination early; the hardware and data took decades to catch up.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pause and check.&lt;/strong&gt; Backprop answers "how much is each weight to blame?" ADP asks "what should we be using backprop &lt;em&gt;on&lt;/em&gt;?" The answer: an estimate of how good each situation is. That estimate has a name, and it's next.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Adaptive Dynamic Programming: wiring it all together
&lt;/h2&gt;

&lt;p&gt;We need one new idea before this makes sense: the &lt;strong&gt;value function&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;value&lt;/strong&gt; is a number answering "how good is this situation &lt;em&gt;in the long run&lt;/em&gt;?", not just "how good does it feel right now?"&lt;/p&gt;

&lt;p&gt;Back to cookies: imagine you've already added the salt disaster and the dough is mixed. Nothing bad has &lt;em&gt;happened&lt;/em&gt; yet. No reward, no punishment. But that dough is already doomed. A good value function would score it low &lt;em&gt;immediately&lt;/em&gt;, before anyone tastes it. That's the power of values: they let you judge a situation before the consequences show up.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;high-value state&lt;/strong&gt; is one where, even with no immediate reward, the future looks rich.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;low-value state&lt;/strong&gt; is a trap: maybe it feels fine now, but it funnels you toward failure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Bellman equation says how values relate to each other:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtmdorfnws73zurobzr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtmdorfnws73zurobzr0.png" alt="formula" width="680" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In words: &lt;em&gt;the value of a situation = the best action's (immediate reward + discounted value of wherever you land next).&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;V(s)&lt;/code&gt;: value of situation (state) &lt;code&gt;s&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;a&lt;/code&gt;: an action you could take. &lt;code&gt;max&lt;/code&gt; means "pick the best one."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;R(s,a)&lt;/code&gt;: the immediate reward.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;γ&lt;/code&gt; (gamma): a discount between 0 and 1. A reward tomorrow is worth a bit less than a reward today.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;P(s' | s, a)&lt;/code&gt;: the probability of landing in the next state &lt;code&gt;s'&lt;/code&gt;, and &lt;code&gt;V(s')&lt;/code&gt; is &lt;em&gt;its&lt;/em&gt; value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The catch, as always: you can't write a table for every state of a real problem. This is the &lt;strong&gt;curse of dimensionality&lt;/strong&gt;: the number of states explodes as problems grow. ADP's workaround is to use a neural network &lt;code&gt;V(s; weights)&lt;/code&gt; as a &lt;em&gt;stand-in&lt;/em&gt; for the table, and train it with backprop. The curse isn't gone, but it stops being a wall and becomes a negotiation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpf63hxv7ux6uxu9sbx9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpf63hxv7ux6uxu9sbx9u.png" alt="VALUE FUNCTION VISUALIZE" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Actor-Critic idea
&lt;/h3&gt;

&lt;p&gt;Out of ADP came one of the cleanest architectural ideas in all of RL, and it's still everywhere: &lt;strong&gt;Actor-Critic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmp44h4rc53h37f4scrd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmp44h4rc53h37f4scrd8.png" alt="Actor critique" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Actor&lt;/strong&gt; decides what to do. It tries things, explores, proposes moves. This is Klopf's trial-and-error learner.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Critic&lt;/strong&gt; judges how good the situation is, using a value function trained with backprop. This is Werbos's contribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An everyday analogy: a &lt;strong&gt;student (Actor)&lt;/strong&gt; writes essays, and a &lt;strong&gt;coach (Critic)&lt;/strong&gt; reads them. The coach doesn't write anything but learns to predict how good an essay will be. The student improves by listening to the coach's feedback, not just waiting for a final grade at the end of term. Meanwhile the coach also improves by comparing predictions to actual results. Both learn at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb6szc89x77hzbft8lmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb6szc89x77hzbft8lmf.png" alt="actor-critique" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And notice how the pieces line up: the Critic's prediction is the "expectation" in Klopf's update rule. When reality beats the Critic's prediction, that surprise tells the Actor "do more of that."&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A quick date check so nothing here gets overstated.&lt;/strong&gt; ADP was being developed in the late 1970s (Werbos's early forms of it date to around 1977). The &lt;em&gt;actor-critic architecture as a working, tested system&lt;/em&gt; came in 1983, when Barto, Sutton and Anderson used it to learn pole balancing, which is the subject of Blog 7.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The big conceptual change: before this, learners mostly &lt;em&gt;reacted&lt;/em&gt;. With a value function they could &lt;em&gt;anticipate&lt;/em&gt;. A system balancing a pole can learn that a certain tilt is "bad news" before it falls. That's the difference between reflex and planning.&lt;/p&gt;




&lt;h2&gt;
  
  
  Stephen Grossberg: the warning label (1976)
&lt;/h2&gt;

&lt;p&gt;We now have a learner with drive, direction, and anticipation. Stephen Grossberg raised a problem that sounds almost boring but turned out to be one of the hardest in the field: &lt;strong&gt;learning can destroy what you already know.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Train a network hard on chess, then train it on Go, and it may forget chess, not gradually but catastrophically. New updates overwrite old structure. (The name &lt;strong&gt;catastrophic forgetting&lt;/strong&gt; was attached to this in the late 1980s, but Grossberg was already wrestling with the underlying issue in the 1970s.)&lt;/p&gt;

&lt;p&gt;An everyday version: you spend a year learning Spanish, then cram Italian for two months, and suddenly your Spanish is full of Italian words. Your brain used the same "shelf space" for both.&lt;/p&gt;

&lt;p&gt;Grossberg's &lt;strong&gt;Adaptive Resonance Theory (ART)&lt;/strong&gt;, from 1976, framed this as a tug-of-war between two forces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Plasticity:&lt;/strong&gt; the ability to learn new things.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stability:&lt;/strong&gt; the ability to keep what you already know.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Too much plasticity and you forget everything. Too much stability and you can never learn anything new. ART's answer: when a new input &lt;em&gt;resembles&lt;/em&gt; something you already know, the two "resonate" and the memory is updated. When it's &lt;em&gt;very different&lt;/em&gt;, don't overwrite, create a new category instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3ln9z7st3wzfc47ubuy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3ln9z7st3wzfc47ubuy3.png" alt="Plasticity VS Stability" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tension never went away. Continual learning, fine-tuning without forgetting, and knowledge distillation are all modern attempts at the problem Grossberg named in the 1970s.&lt;/p&gt;




&lt;h2&gt;
  
  
  Putting it together: desire, direction, memory
&lt;/h2&gt;

&lt;p&gt;Step back. By 1980 three ideas were on the table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Person&lt;/th&gt;
&lt;th&gt;Gave learning systems&lt;/th&gt;
&lt;th&gt;The key idea in one line&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Klopf&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;em&gt;drive&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Learn from the gap between expected and actual reward; use a fading trace to know what to credit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Werbos&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;em&gt;direction&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Send blame backward through layers with the chain rule; use it to train value estimates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Grossberg&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;em&gt;memory&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Balance new learning against keeping old knowledge&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Learning Automata had none of the three. And remember our cookie problem? Klopf's trace says &lt;em&gt;which recent actions are eligible&lt;/em&gt;. Werbos's backprop says &lt;em&gt;how to push the blame back through the whole recipe&lt;/em&gt;. The value function says &lt;em&gt;this dough is doomed before anyone tastes it&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The scale was tiny by modern standards: a handful of neurons, small simulations, and a thesis that sat mostly unread. But the logic was complete.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this still matters today
&lt;/h3&gt;

&lt;p&gt;Here's a connection that makes this history feel less like a museum visit. Modern &lt;strong&gt;RLHF&lt;/strong&gt; (reinforcement learning from human feedback), the process used to tune chatbots like the one you may be chatting with, follows the same blueprint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;reward signal&lt;/em&gt; encodes what people prefer (helpful, correct, safe). That's Klopf's pleasure.&lt;/li&gt;
&lt;li&gt;When an output beats expectations, the pathways behind it get reinforced, and the blame or credit travels back through billions of weights via backprop. That's Werbos.&lt;/li&gt;
&lt;li&gt;The algorithm commonly used for this, &lt;strong&gt;PPO&lt;/strong&gt;, is an actor-critic method: one part proposes, another part estimates value. That's the architecture from this post.&lt;/li&gt;
&lt;li&gt;Keeping the model from forgetting how to do everything else while it's being tuned? That's Grossberg's problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The math is more sophisticated and the networks are enormous. But the skeleton hasn't changed. What evolved over five decades wasn't the idea. It was the scale.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;The pieces are on the table, but they're not assembled yet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Klopf's biological intuitions need a rigorous mathematical home.&lt;/li&gt;
&lt;li&gt;Backprop needs to be tied explicitly to &lt;em&gt;temporal&lt;/em&gt; credit assignment (credit across time).&lt;/li&gt;
&lt;li&gt;Actor-Critic needs someone to build it, test it, and write it down properly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In 1981, Richard Sutton and Andrew Barto began doing exactly that, starting from a model of classical conditioning (think Pavlov's dog). Within a few years they'd produce the first rigorous treatment of temporal credit assignment in RL, including that pole-balancing actor-critic. That's when the field stopped being a collection of brilliant isolated ideas and started becoming a coherent science.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Next: Blog 7, The Sutton and Barto Foundation: Formalizing Temporal Credit Assignment (1981–1984).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>RL 5: Learning Automata and stochastic environments (1961–1974)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 03 Oct 2026 04:48:09 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-5-learning-automata-and-stochastic-environments-1961-1974-2m96</link>
      <guid>https://dev.to/mitanshgor/rl-5-learning-automata-and-stochastic-environments-1961-1974-2m96</guid>
      <description>&lt;p&gt;&lt;em&gt;Quick recap, in case you're jumping in from Blog 4.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Arthur Samuel's checkers program learned by &lt;strong&gt;guessing how good a board position was&lt;/strong&gt; (value estimation). Donald Michie's matchbox machine, MENACE, learned by &lt;strong&gt;shifting which move it preferred&lt;/strong&gt; (policy selection). Both worked. Both were fragile: Samuel needed hand-crafted features, and Michie needed one matchbox for every possible board.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That left a question hanging: &lt;strong&gt;what is the absolute minimum a machine needs in order to improve from feedback?&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The first clean answer came from Moscow.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Before we start: a 60-second jargon cheat sheet
&lt;/h2&gt;

&lt;p&gt;You'll see these words a lot in this post. None of them are scary.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent&lt;/strong&gt;: the thing that acts and learns (here, a tiny machine).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment&lt;/strong&gt;: whatever the agent interacts with (here, a set of slot machines).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action&lt;/strong&gt;: a choice the agent can make (which machine to pull).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reward / Penalty&lt;/strong&gt;: the feedback after an action. Good outcome = reward, bad outcome = penalty.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stochastic&lt;/strong&gt;: "random-ish." The same action can give different results on different tries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automaton&lt;/strong&gt; (plural: &lt;em&gt;automata&lt;/em&gt;): a machine that lives in one of a fixed number of &lt;em&gt;states&lt;/em&gt; and hops between them by simple rules. Think of a traffic light, not a supercomputer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State&lt;/strong&gt;: which "mode" the machine is currently in. Its memory, basically.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmr14p0dagnoyj6hrk9qt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmr14p0dagnoyj6hrk9qt.png" alt="one-glance glossary card" width="799" height="341"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 1: The smallest learning machines
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The problem: how do you learn when feedback is unreliable?
&lt;/h3&gt;

&lt;p&gt;Samuel and Michie taught us that machines &lt;em&gt;can&lt;/em&gt; learn from experience. But both of their systems quietly assumed the feedback made sense. Win the game, good. Lose the game, bad.&lt;/p&gt;

&lt;p&gt;Real life is messier. Picture vending machines on your street:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Machine A gives you a free snack &lt;strong&gt;70%&lt;/strong&gt; of the time.&lt;/li&gt;
&lt;li&gt;Machine B gives you a free snack &lt;strong&gt;40%&lt;/strong&gt; of the time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't know these numbers. You can only try a machine, see if it pays, and adjust. And here's the catch: Machine A will sometimes fail you, and Machine B will sometimes get lucky. One result tells you almost nothing.&lt;/p&gt;

&lt;p&gt;So the real question becomes: &lt;em&gt;how does a machine learn the right choice when any single outcome might be a lie?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's the world of &lt;strong&gt;stochastic environments&lt;/strong&gt;, and it's where Mikhail Tsetlin starts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9797ewqvbuw5tvxdiube.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9797ewqvbuw5tvxdiube.png" alt="slot machine octopus" width="298" height="247"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Meet Mikhail Tsetlin: the "smallest possible brain" guy
&lt;/h3&gt;

&lt;p&gt;Mikhail Tsetlin (1924–1966) was a Soviet mathematician working in Moscow in the era of early cybernetics. In 1961 he published a paper titled &lt;em&gt;"&lt;a href="https://www.mathnet.ru/php/archive.phtml?wshow=paper&amp;amp;jrnid=at&amp;amp;paperid=12417&amp;amp;option_lang=eng" rel="noopener noreferrer"&gt;On the behaviour of finite automata in random medium&lt;/a&gt;"&lt;/em&gt;. The title is a mouthful, but the idea is beautifully modest.&lt;/p&gt;

&lt;p&gt;Most researchers of the day asked, &lt;em&gt;"how do we build a smarter machine?"&lt;/em&gt; Tsetlin asked the opposite question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What is the &lt;em&gt;smallest&lt;/em&gt; internal structure a machine needs to improve its behavior?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not the most powerful. The smallest. He was hunting for the floor of machine intelligence.&lt;/p&gt;

&lt;p&gt;His answer was a &lt;strong&gt;finite-state automaton with a twist&lt;/strong&gt;: no model of the world, no predictions, no calculus, no score. Just:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;a handful of internal states (its memory),&lt;/li&gt;
&lt;li&gt;a rule for choosing an action based on the current state, and&lt;/li&gt;
&lt;li&gt;a rule for moving between states based on feedback.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note the phrase &lt;strong&gt;"random medium"&lt;/strong&gt; in the title. That's Tsetlin's name for a stochastic environment: a world that answers your actions with reward or penalty according to hidden probabilities. The vending machines are a random medium.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Rooms: Tsetlin's memory, made visible
&lt;/h3&gt;

&lt;p&gt;The best way to understand a Tsetlin automaton is to picture a hallway of rooms.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;left half&lt;/strong&gt; of the hallway is "Action A" (pull machine A).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;right half&lt;/strong&gt; is "Action B" (pull machine B).&lt;/li&gt;
&lt;li&gt;The machine is always standing in &lt;strong&gt;exactly one room&lt;/strong&gt;, and whatever side it's on decides what it does next.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a small version with 3 rooms per side (6 states total):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Action A side              Action B side
 [ 1 ] [ 2 ] [ 3 ] | [ 4 ] [ 5 ] [ 6 ]
  deep        edge  |  edge        deep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The rules are only two lines long:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reward&lt;/strong&gt; -&amp;gt; walk &lt;em&gt;deeper&lt;/em&gt; into your current side (more committed).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Penalty&lt;/strong&gt; -&amp;gt; walk one room &lt;em&gt;toward the middle&lt;/em&gt;. If you were already at the edge, you cross the border and switch actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback is just a single bit: &lt;code&gt;0&lt;/code&gt; = reward, &lt;code&gt;1&lt;/code&gt; = penalty. No scores, no probabilities, no gradients. Only movement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flzj9ymwvpnb95160k3s5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flzj9ymwvpnb95160k3s5.png" alt="the 6-room hallway diagram" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Let's walk through it
&lt;/h4&gt;

&lt;p&gt;Say we start in room 3 (the edge of Action A) and keep pulling machine A, which pays 70% of the time:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Room&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Where we go next&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Reward&lt;/td&gt;
&lt;td&gt;Room 2 (deeper)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Reward&lt;/td&gt;
&lt;td&gt;Room 1 (deepest)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Penalty&lt;/strong&gt; (bad luck!)&lt;/td&gt;
&lt;td&gt;Room 2 (one step back)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Reward&lt;/td&gt;
&lt;td&gt;Room 1 again&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Look at step 3. The machine got unlucky, but it didn't panic. One bad result only moved it one room, and it was still firmly on Team A. The rooms &lt;em&gt;absorbed&lt;/em&gt; the noise.&lt;/p&gt;


&lt;h3&gt;
  
  
  Why memory matters (why not just flip a coin?)
&lt;/h3&gt;

&lt;p&gt;You might ask: if feedback is just reward/penalty, why bother with six rooms? Why not the simplest rule ever: &lt;em&gt;"if it paid, do it again; if not, switch"&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Funny thing: that rule &lt;em&gt;is&lt;/em&gt; a Tsetlin automaton, the smallest one, with only &lt;strong&gt;1 room per side&lt;/strong&gt;. It's the classic &lt;strong&gt;win-stay, lose-shift&lt;/strong&gt; strategy. And it's jumpy. One unlucky penalty and it abandons a perfectly good machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbxgjkrd8zoavir5owxnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbxgjkrd8zoavir5owxnb.png" alt="favorite restaurant" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Think of your favorite restaurant. You had one bad meal. Do you never go back? Of course not. You have &lt;em&gt;memory&lt;/em&gt; of many good meals, so one bad night doesn't flip your opinion. More rooms = more patience.&lt;/p&gt;

&lt;p&gt;So let's test it. I simulated the exact hallway above (Machine A pays 70%, Machine B pays 40%, 5,000 pulls per run, averaged over 200 runs), changing only the number of rooms per side, &lt;code&gt;N&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rooms per side (N)&lt;/th&gt;
&lt;th&gt;Share of pulls on the better machine&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 (win-stay, lose-shift)&lt;/td&gt;
&lt;td&gt;~67%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;~80%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;~89%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;~97.5%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;~99.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;More memory, better decisions. Here's the tiny code if you want to try it yourself:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tsetlin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# states 1..N   -&amp;gt; action 0 (1 = deepest, N = edge)
&lt;/span&gt;    &lt;span class="c1"&gt;# states N+1..2N -&amp;gt; action 1 (N+1 = edge, 2N = deepest)
&lt;/span&gt;    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;
    &lt;span class="n"&gt;pulls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;pulls&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;rewarded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;pay&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rewarded&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rewarded&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;pulls&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;tsetlin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;tsetlin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fggehdderk70yuazbqcas.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fggehdderk70yuazbqcas.png" alt="linechart" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tsetlin proved this trend mathematically. As &lt;code&gt;N&lt;/code&gt; grows, the automaton gets arbitrarily close to always picking the best action:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;best&amp;nbsp;action&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;→&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;→&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∞&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;Two honest footnotes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This works when the best action really is better than a coin flip (its penalty probability is below 50%). Our 70% machine qualifies.&lt;/li&gt;
&lt;li&gt;Memory has a price. A deep automaton is stubborn: if the world &lt;em&gt;changes&lt;/em&gt; (say, Machine B suddenly gets better), a machine sitting in the deepest room needs many penalties to walk out. &lt;strong&gt;Stability and adaptability pull in opposite directions.&lt;/strong&gt; Remember this tension; it comes back in Part 2.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  The catch: rooms don't scale
&lt;/h3&gt;

&lt;p&gt;Tsetlin's automaton is elegant, but notice what it needs: a &lt;strong&gt;hand-designed hallway&lt;/strong&gt;. How many rooms? Which transitions? For two actions it's easy. For a hundred actions you'd be designing a giant state machine by hand.&lt;/p&gt;

&lt;p&gt;It's the same flavor of problem we hit in Blog 4: &lt;strong&gt;Michie needed a matchbox per board.&lt;/strong&gt; Tsetlin needed a room per memory level. Someone had to ask: &lt;em&gt;what if we just delete the rooms?&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Delete the rooms: Variable-Structure Automata
&lt;/h3&gt;

&lt;p&gt;The idea of replacing rooms with probabilities dates to Soviet researchers &lt;strong&gt;Varshavskii and Vorontsova (1963)&lt;/strong&gt;, and similar update rules were being explored in mathematical psychology around the same time. Then in &lt;strong&gt;1974&lt;/strong&gt;, &lt;strong&gt;Kumpati Narendra and M. A. L. Thathachar&lt;/strong&gt; published a landmark survey, &lt;em&gt;"Learning Automata: A Survey"&lt;/em&gt;, that organized the whole field, gave it its name in the West, and split it into two families:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Fixed-Structure Automata (FSA): Tsetlin's world.&lt;/strong&gt;&lt;br&gt;
The hallway is fixed. Learning = &lt;em&gt;moving through rooms&lt;/em&gt;. Where you go next depends only on where you are now and whether you were just rewarded or penalized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuxiu5rlp1a0fg7rlhwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuxiu5rlp1a0fg7rlhwz.png" alt="transition matrix" width="774" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Variable-Structure Automata (VSA): throw away the house.&lt;/strong&gt;&lt;br&gt;
No rooms at all. Instead the machine keeps a &lt;strong&gt;list of probabilities&lt;/strong&gt;, one per action, that always adds up to 100%. Like a set of volume knobs where turning one up turns the others down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9br0bbgjdjan774w8bbq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9br0bbgjdjan774w8bbq.png" alt="state themselves were unnecessary" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learning becomes: &lt;em&gt;"that worked, so turn its knob up a bit."&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  The volume-knob rule, with real numbers
&lt;/h4&gt;

&lt;p&gt;Let &lt;code&gt;p_i&lt;/code&gt; be the probability of picking action &lt;code&gt;i&lt;/code&gt;, and &lt;code&gt;λ&lt;/code&gt; (lambda) a small "step size" called the &lt;strong&gt;learning rate&lt;/strong&gt;. When the chosen action &lt;code&gt;i&lt;/code&gt; is &lt;strong&gt;rewarded&lt;/strong&gt;:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;and every &lt;em&gt;other&lt;/em&gt; action &lt;code&gt;j&lt;/code&gt; is nudged down so the total stays at 1:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Concrete example with 3 actions, &lt;code&gt;p = [0.50, 0.30, 0.20]&lt;/code&gt;, &lt;code&gt;λ = 0.1&lt;/code&gt;, and action 1 gets rewarded:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Action 1: 0.50 + 0.1 x (1 - 0.50) = &lt;strong&gt;0.55&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Action 2: 0.30 x 0.9 = &lt;strong&gt;0.27&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Action 3: 0.20 x 0.9 = &lt;strong&gt;0.18&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;New total: 0.55 + 0.27 + 0.18 = &lt;strong&gt;1.00&lt;/strong&gt; ✓&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the same action is &lt;strong&gt;penalized&lt;/strong&gt; instead, the mirror-image rule turns its knob &lt;em&gt;down&lt;/em&gt; and spreads that probability over the others:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;(&lt;code&gt;r&lt;/code&gt; is the number of actions.) With our example: action 1 drops to &lt;strong&gt;0.45&lt;/strong&gt;, action 2 rises to &lt;strong&gt;0.32&lt;/strong&gt;, action 3 to &lt;strong&gt;0.23&lt;/strong&gt;. Still totals 1.&lt;/p&gt;

&lt;p&gt;Notice something? &lt;strong&gt;No rooms, no transition table, no memory hallway.&lt;/strong&gt; The probability list &lt;em&gt;is&lt;/em&gt; the memory. One small rule replaced a whole state machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq88aesd7irzmubuvmx7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq88aesd7irzmubuvmx7h.png" alt="idea cleanly" width="794" height="104"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Why this matters for modern RL
&lt;/h3&gt;

&lt;p&gt;This is where the old Soviet-era ideas quietly show up in today's algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Raise the probability of what worked" is the heart of policy gradient methods&lt;/strong&gt; (we'll get there properly in Blog 10). Ronald Williams's &lt;strong&gt;REINFORCE&lt;/strong&gt; algorithm (1992) is a direct descendant, and Williams himself showed that a learning automaton can be viewed as a special case of REINFORCE. It's the volume knob again, just dressed up with gradients so it can tune millions of parameters instead of three numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tsetlin's rooms have a living descendant too.&lt;/strong&gt; In 2018, Ole-Christoffer Granmo introduced the &lt;strong&gt;Tsetlin Machine&lt;/strong&gt;, which uses teams of Tsetlin automata to learn human-readable logic rules from data. It's a rare case of a 1961 idea being revived as a modern machine-learning method, notable for being interpretable and cheap to run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And the same tension keeps returning.&lt;/strong&gt; Tsetlin's "memory = stability, but also stubbornness" is the modern stability-vs-adaptability problem that every RL practitioner still wrestles with.&lt;/p&gt;




&lt;h3&gt;
  
  
  Tsetlin vs. Narendra: two halves of one answer
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Tsetlin (rooms)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Variable-structure (volume knobs)&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Memory lives in...&lt;/td&gt;
&lt;td&gt;Which room you're in&lt;/td&gt;
&lt;td&gt;The probability list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strength&lt;/td&gt;
&lt;td&gt;Stable; noise gets absorbed&lt;/td&gt;
&lt;td&gt;Simple; scales to many actions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weakness&lt;/td&gt;
&lt;td&gt;Architecture must be designed by hand&lt;/td&gt;
&lt;td&gt;Needs a careful step size &lt;code&gt;λ&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answers the question&lt;/td&gt;
&lt;td&gt;&lt;em&gt;"Where do I go next?"&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;"How much do I like this action now?"&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern echo&lt;/td&gt;
&lt;td&gt;Tsetlin Machines, stability vs. adaptability&lt;/td&gt;
&lt;td&gt;Policy gradients, REINFORCE&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Together they gave the field its first solid answer to Tsetlin's question: a machine can improve from nothing but feedback, with no model of the world.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 2: The puzzle behind it all, the Multi-Armed Bandit
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Zoom out: you've been solving a famous problem
&lt;/h3&gt;

&lt;p&gt;What you just saw, a row of slot machines with unknown payouts and a limited number of pulls, is famously called the &lt;strong&gt;&lt;a href="https://en.wikipedia.org/wiki/Multi-armed_bandit" rel="noopener noreferrer"&gt;Multi-Armed Bandit&lt;/a&gt;&lt;/strong&gt; problem ("one-armed bandit" is old slang for a slot machine). The idea goes back to &lt;strong&gt;Thompson (1933)&lt;/strong&gt;, who asked how to split patients between two treatments, and the statistician &lt;a href="https://en.wikipedia.org/wiki/Herbert_Robbins" rel="noopener noreferrer"&gt;Herbert Robbins&lt;/a&gt; formalized it in 1952. Tsetlin's random-medium experiments attacked the same core dilemma from an automata angle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftd8ohegnsebujhhkfyfx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftd8ohegnsebujhhkfyfx.png" alt="Herbert_Robbins" width="203" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is the cleanest version of the &lt;strong&gt;exploration vs. exploitation&lt;/strong&gt; trade-off we met in Blog 4 with Samuel:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exploit&lt;/strong&gt;: keep pulling the machine that seems best.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore&lt;/strong&gt;: try another one, in case it's actually better.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interesting detail: a Tsetlin automaton never &lt;em&gt;decides&lt;/em&gt; to explore. Noise does it for it. Occasional penalties push it toward the boundary, and it sometimes tries the other side. Exploration falls out of the structure for free.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvprbvuj8i4azn2i60ik6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvprbvuj8i4azn2i60ik6.png" alt="bandit diagram: 3 slot machines" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rooms and volume knobs are two ways to play this game. Engineers have since built sharper ones. To compare them fairly, we first need to state the problem cleanly.&lt;/p&gt;

&lt;h4&gt;
  
  
  The setup
&lt;/h4&gt;

&lt;p&gt;You face &lt;code&gt;K&lt;/code&gt; machines (called &lt;strong&gt;arms&lt;/strong&gt;). Arm &lt;code&gt;a&lt;/code&gt; pays out according to some fixed, &lt;strong&gt;unknown&lt;/strong&gt; average &lt;code&gt;μ_a&lt;/code&gt;. At every step &lt;code&gt;t = 1, 2, ..., T&lt;/code&gt; you pick one arm and see the reward from &lt;em&gt;that arm only&lt;/em&gt;. Your goal: collect as much total reward as possible over &lt;code&gt;T&lt;/code&gt; steps.&lt;/p&gt;

&lt;p&gt;Two things make this hard:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You only see the arm you pulled.&lt;/strong&gt; You never learn what the other arms &lt;em&gt;would&lt;/em&gt; have paid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your data depends on your choices.&lt;/strong&gt; If you stop pulling an arm, you stop learning about it. A bad first impression can become permanent.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Scored, not taught
&lt;/h4&gt;

&lt;p&gt;Compare this to supervised learning, where a teacher hands the machine the right answer ("this image is a cat"). A bandit gets no such answer. It only gets a &lt;em&gt;score&lt;/em&gt; for what it did ("that ad got a click") and no hint about whether something else would have scored higher. The only way to find out is to try other things. Sutton and Barto call this &lt;strong&gt;evaluative feedback&lt;/strong&gt;, and it's the reason exploration exists at all.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why bandits matter
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;They isolate exploration vs. exploitation.&lt;/strong&gt; One situation, no delayed consequences, so you can study the dilemma in its purest form.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They score you &lt;em&gt;while&lt;/em&gt; you learn.&lt;/strong&gt; Not "how accurate is the model after training," but "how much did you lose along the way." That score is called &lt;strong&gt;regret&lt;/strong&gt;, coming up next.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  A few new words
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Arm&lt;/strong&gt;: one choice you can make (a slot machine, an ad, a headline).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Q(a)&lt;/strong&gt;: your &lt;em&gt;running estimate&lt;/em&gt; of how good arm &lt;code&gt;a&lt;/code&gt; is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gap (Δ)&lt;/strong&gt;: how much worse an arm is than the best arm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regret&lt;/strong&gt;: the total reward you &lt;em&gt;lost&lt;/em&gt; by not always playing the best arm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Posterior&lt;/strong&gt;: your belief about an arm's true payout after seeing data. Wide = unsure. Narrow = confident.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Two tools you need: estimating and keeping score
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Estimating an arm's value, one pull at a time
&lt;/h4&gt;

&lt;p&gt;After &lt;code&gt;n&lt;/code&gt; pulls of an arm, the average reward is &lt;code&gt;Q_n = (R_1 + R_2 + ... + R_n) / n&lt;/code&gt;. You never need to store the history. Rearranging gives an update that shows up &lt;em&gt;everywhere&lt;/em&gt; in RL:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In words: &lt;strong&gt;new estimate = old estimate + step size x (target - old estimate)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now swap the &lt;code&gt;1/n&lt;/code&gt; for a constant &lt;code&gt;α&lt;/code&gt;. Old rewards fade out gradually, so you track a &lt;em&gt;moving&lt;/em&gt; target instead of a fixed one. That's how you cope with a world that changes (we'll see the payoff in the practical section).&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Remember the volume knob?&lt;/strong&gt; The reward rule &lt;code&gt;p ← p + λ(1 - p)&lt;/code&gt; from earlier is this exact update with target &lt;code&gt;1&lt;/code&gt;. Same idea, different clothes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Regret: the scoreboard
&lt;/h4&gt;

&lt;p&gt;Let &lt;code&gt;μ*&lt;/code&gt; be the average payout of the best arm and &lt;code&gt;Δ_a = μ* - μ_a&lt;/code&gt; the gap of arm &lt;code&gt;a&lt;/code&gt;. After &lt;code&gt;T&lt;/code&gt; steps, the &lt;strong&gt;regret&lt;/strong&gt; is how much you earned &lt;em&gt;less&lt;/em&gt; than someone who knew the best arm from the start:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathcal"&gt;R&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;μ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mbin mtight"&gt;∗&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="mrel mtight"&gt;:&lt;/span&gt;&lt;span class="mspace mtight"&gt;&lt;/span&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;Δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mrel mtight"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="mopen"&gt;[&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;(&lt;code&gt;E[...]&lt;/code&gt; just means "on average," and &lt;code&gt;N_T(a)&lt;/code&gt; is how many times you pulled arm &lt;code&gt;a&lt;/code&gt;.) The second form is the useful one: &lt;strong&gt;regret = (cost per bad pull) x (number of bad pulls).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Quick example with our vending machines: the gap between A (70%) and B (40%) is 0.3. Every pull of B costs you 0.3 snacks on average, so 100 pulls of B means about 30 snacks of regret. To keep regret low you must pull bad arms as rarely as possible, but you can't skip them entirely, or you'd never know they were bad.&lt;/p&gt;

&lt;p&gt;How should regret grow over time?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linear in &lt;code&gt;T&lt;/code&gt;&lt;/strong&gt;: you never stopped making mistakes. Failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logarithmic in &lt;code&gt;T&lt;/code&gt;&lt;/strong&gt;: mistakes become rarer and rarer, so regret grows slower and slower. This is the best anyone can do, which Lai and Robbins proved in 1985.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more intuition worth keeping: &lt;strong&gt;the closer two options are, the longer it takes to tell them apart&lt;/strong&gt;, and the more exploring you must pay for. Telling a 70% machine from a 40% one is easy. Telling 12% from 15% takes thousands of pulls.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw5t1ezrftyg0hb6tdj8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw5t1ezrftyg0hb6tdj8r.png" alt="regret curve chart" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  The strategy zoo
&lt;/h3&gt;

&lt;p&gt;Now the fun part. We'll go through the main strategies, each with its rule, its intuition, its math, and where it breaks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fduxitkjcemeun9kn432b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fduxitkjcemeun9kn432b.png" alt="strategy zoo" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Greedy: always pick the best-looking arm
&lt;/h4&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Simple, and &lt;strong&gt;broken&lt;/strong&gt;. A single lucky early pull on a mediocre arm can make its estimate look best, and since pure greedy never samples anything else, it locks onto that arm forever. That's &lt;strong&gt;linear regret&lt;/strong&gt;, caused by zero exploration.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. ε-greedy: add some randomness
&lt;/h4&gt;

&lt;p&gt;With probability &lt;code&gt;1 - ε&lt;/code&gt; pick the best-looking arm; with probability &lt;code&gt;ε&lt;/code&gt; pick uniformly at random. Dead simple and a great baseline.&lt;/p&gt;

&lt;p&gt;Its flaw is mathematical: random exploration continues forever, even when you're certain. Because &lt;code&gt;ε&lt;/code&gt; stays fixed (say, &lt;code&gt;0.10&lt;/code&gt;), each arm is chosen with probability at least &lt;code&gt;ε/K&lt;/code&gt; at every step, which gives:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathcal"&gt;R&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;ϵ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;That's &lt;strong&gt;linear regret&lt;/strong&gt;. A fixed &lt;code&gt;ε&lt;/code&gt; is a permanent tax: even after 1,000,000 pulls, when you know exactly which arm is best, you still waste about 10% of pulls on random choices. (Shrinking &lt;code&gt;ε&lt;/code&gt; over time can fix this, but then you have a schedule to tune.)&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Optimistic initialization: let disappointment drive exploration
&lt;/h4&gt;

&lt;p&gt;Start every estimate absurdly high, for example &lt;code&gt;Q_1(a) = +5&lt;/code&gt; when real rewards range from 0 to 1. Every arm you try then "disappoints" compared to that starting hope, so the greedy rule naturally moves on to the untried arms. It's a clever, nearly free trick that gets a purely greedy algorithm to try everything without any random choices.&lt;/p&gt;

&lt;p&gt;The catch: once every arm has been sampled enough, the optimism is gone and the estimates settle at their true averages. If the world changes later (a bad machine suddenly starts paying well), the agent won't re-investigate, because that machine's estimate was pushed down long ago. It only drives exploration during the opening phase.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. UCB: optimism in the face of uncertainty
&lt;/h4&gt;

&lt;p&gt;UCB (Upper Confidence Bound) is the first strategy built on rigorous probability theory. Instead of picking the arm with the best &lt;em&gt;average&lt;/em&gt;, you pick the arm with the best &lt;strong&gt;plausible upper bound&lt;/strong&gt;: its estimate plus an &lt;strong&gt;uncertainty bonus&lt;/strong&gt;.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;c&lt;/span&gt;&lt;span class="mord sqrt"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span class="svg-align"&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop"&gt;ln&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="hide-tail"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;How the bonus behaves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It shrinks with experience.&lt;/strong&gt; The more you pull an arm (&lt;code&gt;N&lt;/code&gt; grows), the smaller its bonus, because its average is already trustworthy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It grows with time.&lt;/strong&gt; As &lt;code&gt;t&lt;/code&gt; ticks forward, the bonus creeps up for neglected arms, so every option eventually gets another look.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;A worked example&lt;/strong&gt; (using &lt;code&gt;c = 1&lt;/code&gt; to keep things simple; at step &lt;code&gt;t = 200&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Average &lt;code&gt;Q&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Pulls &lt;code&gt;N&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Bonus&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Arm A&lt;/td&gt;
&lt;td&gt;0.50&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;0.23&lt;/td&gt;
&lt;td&gt;0.73&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Arm B&lt;/td&gt;
&lt;td&gt;0.40&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;0.73&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.13&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Arm A has the better average, but UCB plays &lt;strong&gt;Arm B&lt;/strong&gt;, because with only 10 pulls it might still be hiding something great. Pull B a few more times and its bonus shrinks; if its average stays low, A takes over again. Exploration shrinks exactly as fast as your doubt does.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Thompson Sampling: let each arm "vote" with a random draw
&lt;/h4&gt;

&lt;p&gt;Thompson's 1933 algorithm is surprisingly simple, and works remarkably well:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep a &lt;strong&gt;posterior&lt;/strong&gt; (a curve showing how confident you are about each arm's payout).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Draw one random sample&lt;/strong&gt; from each arm's curve.&lt;/li&gt;
&lt;li&gt;Play the arm whose sample is highest.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For yes/no outcomes (clicks vs. no clicks), the natural curve is the &lt;strong&gt;Beta distribution&lt;/strong&gt;. You start with a flat &lt;code&gt;Beta(1, 1)&lt;/code&gt; ("total uncertainty"). After &lt;code&gt;s&lt;/code&gt; successes and &lt;code&gt;f&lt;/code&gt; failures, it becomes &lt;code&gt;Beta(1 + s, 1 + f)&lt;/code&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Worked example
&lt;/h5&gt;

&lt;p&gt;Two ads show roughly the same 30% click rate, but with very different amounts of evidence:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Data&lt;/th&gt;
&lt;th&gt;Posterior&lt;/th&gt;
&lt;th&gt;Mean&lt;/th&gt;
&lt;th&gt;Std. Dev.&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ad X&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;3 clicks / 10 views&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Beta(4, 8)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0.333&lt;/td&gt;
&lt;td&gt;0.131&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ad Y&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;30 clicks / 100 views&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Beta(31, 71)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0.304&lt;/td&gt;
&lt;td&gt;0.045&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Similar averages, wildly different &lt;strong&gt;certainty&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmegnanrcuc0eonw8h1g3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmegnanrcuc0eonw8h1g3.gif" alt="Example Ads X and Y" width="720" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  How self-correcting exploration works
&lt;/h5&gt;

&lt;p&gt;Because &lt;strong&gt;Ad X&lt;/strong&gt; has a wide, uncertain curve, its random draws beat &lt;strong&gt;Ad Y&lt;/strong&gt;'s about &lt;strong&gt;58%&lt;/strong&gt; of the time. That balances exploring and exploiting automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exploitation (Ad Y):&lt;/strong&gt; a reliable performer with high confidence, a stable baseline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploration (Ad X):&lt;/strong&gt; unproven. It could turn out to be a weak ad or a game-changer, and the width of its curve is the potential upside of learning more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic feedback loop:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;If Ad X's future impressions fail to convert, its curve shifts left and narrows, so it loses future draws and drops out of rotation.&lt;/li&gt;
&lt;li&gt;If Ad X keeps converting, its curve narrows around a high mean and it becomes the new winner.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thompson Sampling spends exploration effort in proportion to uncertainty, with almost no tuning (no &lt;code&gt;c&lt;/code&gt;, no &lt;code&gt;ε&lt;/code&gt;).&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Gradient bandits: learn preferences, not values
&lt;/h4&gt;

&lt;p&gt;Instead of estimating &lt;em&gt;how good&lt;/em&gt; each arm is, learn a numerical &lt;strong&gt;preference&lt;/strong&gt; &lt;code&gt;H(a)&lt;/code&gt; and turn preferences into probabilities with a softmax (a recipe that turns any list of numbers into probabilities that add up to 1):&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop"&gt;&lt;span class="mop op-symbol small-op"&gt;∑&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;b&lt;/span&gt;&lt;span class="mclose mtight"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="mclose mtight"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;After pulling &lt;code&gt;A_t&lt;/code&gt; and receiving &lt;code&gt;R_t&lt;/code&gt;, update, using the running average reward &lt;code&gt;R̄_t&lt;/code&gt; as a &lt;strong&gt;baseline&lt;/strong&gt; ("what I normally get"):&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;ˉ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mopen"&gt;[&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;]&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In plain words: &lt;strong&gt;better than usual? Push the chosen arm's preference up and the others down. Worse than usual? The reverse.&lt;/strong&gt; (Mathematically this is gradient ascent on average reward, and the baseline keeps the updates from being too jumpy.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9arle2i6pwew8llt78u9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9arle2i6pwew8llt78u9.gif" alt="softmax vs Thompson Sampling" width="760" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Back to Part 1, and a preview of Blog 10:&lt;/strong&gt; this is the volume-knob idea again ("raise the probability of what worked"), now with a gradient. Bandits are where policy gradients start.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Let's measure them
&lt;/h3&gt;

&lt;p&gt;Theory is nice. Here's what actually happens. I ran two experiments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experiment 1: the classic 10-armed testbed.&lt;/strong&gt; Each run draws 10 arm averages at random, rewards are noisy around those averages, 1,000 steps, averaged over 1,000 runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Avg reward (last 200 steps)&lt;/th&gt;
&lt;th&gt;% pulls on best arm&lt;/th&gt;
&lt;th&gt;Cumulative regret @ 1,000&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Greedy (ε = 0)&lt;/td&gt;
&lt;td&gt;0.997&lt;/td&gt;
&lt;td&gt;34.7%&lt;/td&gt;
&lt;td&gt;508.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ε-greedy, ε = 0.01&lt;/td&gt;
&lt;td&gt;1.345&lt;/td&gt;
&lt;td&gt;62.0%&lt;/td&gt;
&lt;td&gt;327.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ε-greedy, ε = 0.1&lt;/td&gt;
&lt;td&gt;1.346&lt;/td&gt;
&lt;td&gt;79.4%&lt;/td&gt;
&lt;td&gt;229.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Optimistic init (Q₁ = 5, α = 0.1)&lt;/td&gt;
&lt;td&gt;1.499&lt;/td&gt;
&lt;td&gt;86.2%&lt;/td&gt;
&lt;td&gt;238.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gradient bandit (α = 0.1)&lt;/td&gt;
&lt;td&gt;1.495&lt;/td&gt;
&lt;td&gt;83.9%&lt;/td&gt;
&lt;td&gt;184.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UCB (c = 2)&lt;/td&gt;
&lt;td&gt;1.524&lt;/td&gt;
&lt;td&gt;85.9%&lt;/td&gt;
&lt;td&gt;147.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thompson sampling&lt;/td&gt;
&lt;td&gt;1.546&lt;/td&gt;
&lt;td&gt;90.3%&lt;/td&gt;
&lt;td&gt;68.4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1okayvl2rtyyu1053c44.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1okayvl2rtyyu1053c44.gif" alt="Exp 1" width="799" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two honest footnotes: &lt;br&gt;
(1) Thompson's starting beliefs here &lt;em&gt;exactly match&lt;/em&gt; how the arms were generated, which flatters it, so don't expect a 2x regret win in the wild; &lt;br&gt;
(2) &lt;code&gt;c = 2&lt;/code&gt; uses the Sutton-Barto form &lt;code&gt;c·√(ln t / N)&lt;/code&gt;, and &lt;code&gt;c&lt;/code&gt; is a tuning knob.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experiment 2: how does regret &lt;em&gt;grow&lt;/em&gt;?&lt;/strong&gt; Five arms with success rates 0.10, 0.12, 0.15, 0.20, 0.25 (small gaps, like real conversion rates), averaged over 40 runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Regret @ 1,000&lt;/th&gt;
&lt;th&gt;@ 5,000&lt;/th&gt;
&lt;th&gt;@ 20,000&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ε-greedy (ε = 0.1)&lt;/td&gt;
&lt;td&gt;48&lt;/td&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;233&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UCB1 (c = √2)&lt;/td&gt;
&lt;td&gt;61&lt;/td&gt;
&lt;td&gt;204&lt;/td&gt;
&lt;td&gt;418&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thompson&lt;/td&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;57&lt;/td&gt;
&lt;td&gt;73&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read this one slowly, because it teaches something the textbooks gloss over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ε-greedy's regret grows at a constant slope&lt;/strong&gt; (about 0.0086 per step between 5k and 20k), matching the &lt;code&gt;(ε/K)ΣΔ&lt;/code&gt; floor we derived. It will lose in the long run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UCB1 is &lt;em&gt;worse&lt;/em&gt; than ε-greedy at this horizon.&lt;/strong&gt; Its "grows slower and slower" guarantee is real, but its constants are conservative, and its slope (about 0.014 per step here) is still shrinking. "Best in the long run" does not mean "best at your horizon."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thompson's slope is about 0.001 per step.&lt;/strong&gt; Nearly flat. That's why you see it so often in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpwa35hzmgkl1bcqad71.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpwa35hzmgkl1bcqad71.gif" alt="Experiment 2" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  A reference implementation
&lt;/h4&gt;

&lt;p&gt;Small enough to read in one sitting, tested to produce the numbers above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EpsGreedy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;argmax&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;# alpha =&amp;gt; non-stationary
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UCB1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;                      &lt;span class="c1"&gt;# t starts at 1
&lt;/span&gt;        &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;argmin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# play every arm once first
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;argmax&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ThompsonBernoulli&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# Beta(1,1) prior
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;argmax&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;regret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;regret&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;regret&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ThompsonBernoulli&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  The practical corner: using a bandit for real
&lt;/h3&gt;

&lt;h4&gt;
  
  
  When a bandit is the right tool
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feedback is immediate.&lt;/strong&gt; You act, you get a number, and your action doesn't change what situations you'll face next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Showing the loser has a real cost.&lt;/strong&gt; Every user sent to a worse option is lost revenue, clicks, or goodwill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choices are discrete and few-ish.&lt;/strong&gt; Headlines, layouts, models, prompts, settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You'll keep running it.&lt;/strong&gt; A bandit is a &lt;em&gt;loop&lt;/em&gt;, not a one-off analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  when the world changes
&lt;/h4&gt;

&lt;p&gt;Five arms with success rates &lt;code&gt;0.2, 0.3, 0.4, 0.5, 0.7&lt;/code&gt; for 4,000 steps, and at step 2,000 the order is &lt;strong&gt;reversed&lt;/strong&gt;, so the best arm becomes the worst. Total reward, averaged over 500 runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Estimator&lt;/th&gt;
&lt;th&gt;Total reward&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Plain average (assumes the world never changes)&lt;/td&gt;
&lt;td&gt;~1,791&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Constant step size, &lt;code&gt;α = 0.1&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;~2,560&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Only the last 500 observations ("sliding window")&lt;/td&gt;
&lt;td&gt;~2,537&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Someone who always knows the best arm&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;2,800&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The plain average never recovers: after 2,000 steps its estimates are so weighed down by history that new evidence barely moves them. Switching to a constant step size, a one-line change, won back about &lt;strong&gt;770 reward&lt;/strong&gt;. This is Tsetlin's stability-vs-adaptability tension again, now with a dial you control.&lt;/p&gt;

&lt;h4&gt;
  
  
  Choosing an algorithm
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;Reach for&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Clicks / conversions (yes or no), you want a strong default&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Thompson (Beta-Bernoulli)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Almost no tuning, strong in practice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need a deterministic, explainable rule&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;UCB&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Same inputs always give the same choice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Payouts drift over time&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Any of these with a constant step size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Old data fades&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Each decision comes with info about the user&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Contextual bandit&lt;/strong&gt; (a bandit that first looks at who's in front of it)&lt;/td&gt;
&lt;td&gt;Personalizes the choice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You want something trivial to ship today&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;ε-greedy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Easiest to explain and debug&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Where it all runs out of road
&lt;/h3&gt;

&lt;p&gt;So, problem solved? Not quite. Learning automata and bandits share two big blind spots:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. They don't see the situation, and they don't change it.&lt;/strong&gt; The machine picks an action, but it never &lt;em&gt;observes&lt;/em&gt; anything about the world first. There's no "if the board looks like this, do that." A vending machine is always the same vending machine, and pulling its lever doesn't change what comes next. Real problems change from moment to moment: chess boards, road conditions, the words already written in a sentence. (If you only add the "look at the situation first" part, you get a &lt;em&gt;contextual bandit&lt;/em&gt;, which is a halfway house between bandits and full RL. If your actions also change the &lt;em&gt;next&lt;/em&gt; situation, you've left bandit territory entirely.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. They only understand immediate feedback.&lt;/strong&gt; Every update reacts to the reward &lt;em&gt;right now&lt;/em&gt; for the action &lt;em&gt;just taken&lt;/em&gt;. But in most interesting problems, consequences arrive late:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A chess move that quietly weakens your position may not cost you the game for 20 turns.&lt;/li&gt;
&lt;li&gt;A financial decision may not show its results for months.&lt;/li&gt;
&lt;li&gt;A word you choose early in a sentence shapes everything after it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The machine would have to guess &lt;em&gt;which&lt;/em&gt; of its past actions deserves the blame or credit. It has no mechanism for that. This is the famous &lt;strong&gt;credit assignment problem&lt;/strong&gt;, and it is the gap the next era of RL sets out to fill. (Samuel's checkers program from Blog 4 was already sniffing around this problem. Its temporal-difference trick gets its full moment later in the series.)&lt;/p&gt;




&lt;h3&gt;
  
  
  Quick recap
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Question:&lt;/strong&gt; what is the smallest structure that lets a machine improve from feedback?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tsetlin (1961):&lt;/strong&gt; a hallway of rooms. Reward = go deeper, penalty = step back. More rooms = more stability, but also more stubbornness.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable-structure automata (1963-1974):&lt;/strong&gt; delete the rooms, keep a probability per action, and nudge it up or down with feedback. This is the seed of policy gradients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Both are ways of playing the multi-armed bandit&lt;/strong&gt;, the cleanest version of exploring vs. exploiting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regret&lt;/strong&gt; (reward lost vs. always playing the best arm) is the scoreboard. Linear = failing, logarithmic = best possible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The toolkit:&lt;/strong&gt; ε-greedy (simple, permanent exploration tax), UCB (optimism about what you haven't tried), Thompson sampling (explore in proportion to doubt, great in practice), gradient bandits (learn preferences, the cousin of policy gradients).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In practice:&lt;/strong&gt; a bandit beat a fixed A/B split by roughly 4x in lost conversions in our simulation, and a constant step size won back ~770 reward after the world flipped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blind spots:&lt;/strong&gt; no awareness of the situation, and no way to handle delayed rewards.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Up next
&lt;/h3&gt;

&lt;p&gt;So machines can now adapt reliably to noisy feedback. But what if the feedback comes &lt;em&gt;late&lt;/em&gt;, and what if the "learner" isn't a tidy algorithm at all, but a &lt;strong&gt;neuron&lt;/strong&gt;? In the 1970s, Harry Klopf proposed exactly that: neurons as tiny, pleasure-seeking units. Around the same time, Paul Werbos quietly described an idea that would later be famous as &lt;strong&gt;backpropagation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next: Blog 6 - The "Hedonistic" Revival: Klopf's Pleasure-Seeking Neurons and Werbos's Hidden Backpropagation (1972-1980).&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>RL 4: Early heuristics and the birth of Temporal Difference learning (1959–1968)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Fri, 25 Sep 2026 15:29:09 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-4-early-heuristics-and-the-birth-of-temporal-difference-learning-1959-1968-1hnb</link>
      <guid>https://dev.to/mitanshgor/rl-4-early-heuristics-and-the-birth-of-temporal-difference-learning-1959-1968-1hnb</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Bellman's math told you how to act perfectly — on paper. 1959 computers had neither the memory nor the map of reality to run it. So a few stubborn engineers cheated their way to something that actually worked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arthur Samuel (1959)&lt;/strong&gt; swapped an impossible checkers lookup table for a &lt;strong&gt;scoring function&lt;/strong&gt; — a formula with adjustable weights, trained by playing itself. His real breakthrough wasn't the 1962 headline win (which, spoiler, gets more impressive the more you learn how it actually went). It was an idea called &lt;strong&gt;Temporal Difference (TD) learning&lt;/strong&gt;: don't wait for the game to end — learn from the gap between what you predicted a moment ago and what you predict now. No rulebook required. That's &lt;strong&gt;model-free&lt;/strong&gt; learning, and it turns out to be the exact same rule psychologists later used to explain Pavlov's dogs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Donald Michie's MENACE (1961)&lt;/strong&gt; did something similar with 304 matchboxes and coloured beads — but learned a &lt;strong&gt;policy&lt;/strong&gt; ("what should I do?") instead of a &lt;strong&gt;value&lt;/strong&gt; ("how good is this?"). Value-learning and policy-learning are the two ancestors of basically every RL algorithm running today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Minsky (1961)&lt;/strong&gt; put a name on why any of this was hard in the first place: the &lt;strong&gt;credit-assignment problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Michie's BOXES (1968)&lt;/strong&gt; removed the last training wheel — a human teacher — and balanced a physical pole using nothing but "it fell over" as feedback.&lt;/p&gt;

&lt;p&gt;Every system in this post assumes the world is reliable. Blog 5 breaks that assumption.&lt;/p&gt;




&lt;h2&gt;
  
  
  The blueprint had a bill attached
&lt;/h2&gt;

&lt;p&gt;Bellman's equation is one of those rare results that's simultaneously beautiful and completely useless.&lt;/p&gt;

&lt;p&gt;Beautiful, because it tells you the &lt;em&gt;exact&lt;/em&gt; optimal move, always. Useless, because to run it you need two things handed to you first: every possible state of the world, written down, and the exact odds of moving between them, also written down.&lt;/p&gt;

&lt;p&gt;Neither exists. Computers in 1959 topped out around 32,768 words of memory — smaller than a single photo on your phone today. Checkers alone has roughly 500 billion possible positions. And the "odds of every outcome" problem is even worse than the memory one — more on that in a second.&lt;/p&gt;

&lt;p&gt;So the people actually trying to build this did what engineers always do when elegant theory meets a real budget: they cheated. One of the most important cheats in AI history started with a man, a room-sized vacuum-tube computer, and a game of checkers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq3ewlex9fi8murgw8zlb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq3ewlex9fi8murgw8zlb.png" alt="Memory size-comparison graphic" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Three walls, one problem each
&lt;/h2&gt;

&lt;p&gt;Picture yourself in 1959, staring at Bellman's equation, actually trying to build the thing. You'd hit these three walls, in roughly this order, and none of them have an easy way around them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wall 1 — Memory.&lt;/strong&gt; Store every situation in a table and the table explodes. Tic-tac-toe: ~5,000 positions, fine. Checkers: ~500 billion. Chess: ~10⁴⁵. Bellman called this the &lt;strong&gt;curse of dimensionality&lt;/strong&gt; — add one variable, and your table doesn't grow, it detonates. Lesson: you can't memorise your way to intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wall 2 — No rulebook.&lt;/strong&gt; Bellman's math needs &lt;code&gt;P(s'|s,a)&lt;/code&gt; — the odds of every outcome, for every action, in advance. Nobody has that spreadsheet. A self-driving car has no table for "will this pedestrian step off the curb." Reality just doesn't ship with its own source code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wall 3 — The score becomes the goal.&lt;/strong&gt; Turn "behave well" into a number, and machines will take that number &lt;em&gt;extremely&lt;/em&gt; literally. Reward a robot vacuum for movement, and it'll ram the same wall forever, racking up points and cleaning nothing — and from its own perspective, winning. Today we'd call this &lt;strong&gt;reward hacking&lt;/strong&gt;. In 1959 it didn't have a name yet, just a very confused engineer staring at the output.&lt;/p&gt;

&lt;p&gt;Samuel is about to dent Walls 1 and 2. Michie dents Wall 1 from a totally different angle. Wall 3 is still standing today — it's a large chunk of why "AI alignment" is now a job title.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwsv2zgjyie607ag8z1m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwsv2zgjyie607ag8z1m.png" alt="one clean 3-icon graphic" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Arthur Samuel and the machine that learned checkers
&lt;/h2&gt;

&lt;p&gt;In the 1950s, the prevailing wisdom was blunt: computers execute, they don't learn. A program does exactly what it's told, forever, full stop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzoi4m3bahw70ytzuvsym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzoi4m3bahw70ytzuvsym.png" alt="Arthur Samuel" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ibm.com/history/early-games" rel="noopener noreferrer"&gt;Arthur Samuel, an IBM&lt;/a&gt; engineer, didn't buy it. He picked checkers — not chess — as his test case. Deep enough to need real strategy, small enough that a 1950s machine stood a chance. He started in 1952 on the IBM 701 and by 1959 had published work that put the phrase "machine learning" into circulation for the first time.&lt;/p&gt;

&lt;p&gt;His machine, the IBM 704, maxed out at 32,768 words of memory. Storing every checkers position wasn't "hard" — it was short by seven orders of magnitude. So instead of trying to be &lt;em&gt;comprehensive&lt;/em&gt;, Samuel made the machine &lt;em&gt;opinionated&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  A scoring function instead of a lookup table
&lt;/h3&gt;

&lt;p&gt;Throw away the table. Replace it with a formula that squeezes an entire board into one number: high = "good for me," low = "bad for me." The machine has no idea &lt;em&gt;why&lt;/em&gt; — it just needs a number it can push upward.&lt;/p&gt;

&lt;p&gt;If blog 3's &lt;code&gt;V(s)&lt;/code&gt; was an exact number, computed by sweeping every state until the answer converged — this is the same object, wearing a disguise. Samuel's scoring function &lt;em&gt;is&lt;/em&gt; &lt;code&gt;V(s)&lt;/code&gt;. The difference is that nobody can compute it exactly here, so the machine has to guess it, and improve its guess through play instead of through a formula that already has the whole map.&lt;/p&gt;

&lt;p&gt;That number was built from hand-picked &lt;strong&gt;features&lt;/strong&gt; — piece count, king count, board control, mobility — each with a &lt;strong&gt;weight&lt;/strong&gt; saying how much the machine currently trusts it. Score = features × weights, summed.&lt;/p&gt;

&lt;p&gt;Here's the part that still holds up today: the weights weren't fixed. A feature that kept predicting wins got trusted more. One that kept misleading the machine got trusted less, or dropped entirely and swapped for a new candidate. The machine wasn't just learning checkers — it was learning &lt;em&gt;what was worth paying attention to&lt;/em&gt;. That's the same basic instinct behind feature learning in neural networks, six decades early.&lt;/p&gt;

&lt;h3&gt;
  
  
  Self-play
&lt;/h3&gt;

&lt;p&gt;Samuel then had the program play itself. A "student" copy tries tweaked weights against a "teacher" copy running the current best settings. Student wins consistently → student becomes the new teacher → repeat.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fujvxs9dmpdyswruhyapj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fujvxs9dmpdyswruhyapj.png" alt="Self-play" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This loop is, structurally, identical to what DeepMind ran in 2016 to build AlphaGo. The hardware went from vacuum tubes to TPU pods. The logic didn't change at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  The famous win (and the asterisk nobody mentions)
&lt;/h3&gt;

&lt;p&gt;In 1962, Samuel's program beat a checkers player named Robert Nealey, and IBM's press release turned it into the first-ever headline about a machine beating a human at a strategy game.&lt;/p&gt;

&lt;p&gt;What usually gets left out: Nealey wasn't state champion yet at the time (that came four years later), he beat the program in a rematch the following year, and by 1966 Samuel's program lost eight straight games to serious competition. None of that makes the work less real — it just moves the story from "magic trick" to "science": genuine learning, with a genuine, visible ceiling.&lt;/p&gt;

&lt;h3&gt;
  
  
  The ceiling Samuel could see from day one
&lt;/h3&gt;

&lt;p&gt;Every strategic idea the program ever had came from a feature Samuel typed in by hand. If he never thought to encode "board control matters," the machine could never discover it on its own. It could re-weight human knowledge with superhuman patience — but it couldn't generate knowledge that wasn't already sitting in the box.&lt;/p&gt;

&lt;p&gt;That single limitation defined the next thirty years of AI research, and it's exactly the problem deep learning was eventually built to solve: stop handing the machine features, let it find its own.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A name for the missing piece:&lt;/strong&gt; Marvin Minsky, in 1961, pointed at exactly this gap and called it the &lt;strong&gt;credit-assignment problem&lt;/strong&gt; — with only a final win or loss, which of a hundred earlier decisions actually deserves the credit? He specifically called out Samuel's scoring updates as the first real attempt at an answer: doling out partial credit one move at a time instead of waiting for the final verdict. That's the problem the rest of this post is trying to crack.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Memorise, or generalise?
&lt;/h2&gt;

&lt;p&gt;Samuel's scoring function created a fork in the road that reinforcement learning is still walking down today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz5ir2p8l9qu2x9kiq6de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz5ir2p8l9qu2x9kiq6de.png" alt="Memorise, or generalise" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;His first instinct was &lt;strong&gt;rote learning&lt;/strong&gt;: store exact positions and how they turned out, replay the good ones when they reappear. Works great for small games. But nudge a single piece and the "memory" is worthless — that exact position has never happened before, so there's nothing to look up. It's a lookup table wearing a trench coat.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generalisation&lt;/strong&gt; was the fix: describe a board by its features instead of memorising the whole thing. Now a position the machine has never seen still gets a sensible score, because it's &lt;em&gt;described&lt;/em&gt;, not &lt;em&gt;recognised&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Table lookup asks "have I seen this exact thing?" Generalisation asks "what is this like?" Only the second question scales.&lt;/p&gt;

&lt;p&gt;Samuel's update rule for the weights:&lt;/p&gt;

&lt;p&gt;Δw_i = α · [V_actual − V_predicted] · f_i&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Δw_i — how much to nudge feature i's weight&lt;/li&gt;
&lt;li&gt;α — learning rate: how boldly to react to new evidence&lt;/li&gt;
&lt;li&gt;[V_actual − V_predicted] — the surprise&lt;/li&gt;
&lt;li&gt;f_i — how present that feature was in this position&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you remember one sentence from this whole post, make it this: &lt;strong&gt;learning is the size of your mistake, multiplied by how willing you are to change your mind.&lt;/strong&gt; Everything from here on is a variation on that one bracket.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thinking deeper on a slower machine: alpha-beta pruning
&lt;/h2&gt;

&lt;p&gt;One quick detour, and it earns its place here: self-play only works if you can play thousands of games against yourself, and thousands of games only fits into a reasonable afternoon if each individual game doesn't take forever to think through. That's the problem this section solves.&lt;/p&gt;

&lt;p&gt;The IBM 704 was unbelievably slow by today's standards — looking twenty moves ahead by brute force would've taken longer than the universe has existed. So Samuel needed to skip most of the game tree without missing anything that mattered.&lt;/p&gt;

&lt;p&gt;Credit where due: Samuel used &lt;strong&gt;alpha-beta pruning&lt;/strong&gt;, but didn't invent it. John McCarthy proposed it at the 1956 Dartmouth workshop; Hart and Edwards formalised it in 1961; Knuth and Moore gave it full analysis in 1975. Samuel had a working version quietly running in the background — he just thought the learning parts were the interesting bit. (He was right.)&lt;/p&gt;

&lt;p&gt;The idea: as the machine explores possible futures, it tracks the best result it can already guarantee (&lt;strong&gt;alpha&lt;/strong&gt;) and the worst its opponent can already force (&lt;strong&gt;beta&lt;/strong&gt;). The moment a branch is provably worse than something already locked in, the machine stops exploring it entirely — not "reads it faster," &lt;em&gt;stops&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Restaurant analogy: someone tells you "the other place has a two-hour wait." You don't need the menu or the parking situation. You're not going. Branch closed.&lt;/p&gt;

&lt;p&gt;Crucially, this is &lt;strong&gt;lossless&lt;/strong&gt; — it finds the exact same best move as checking everything, just without wasting time on futures that can't matter. It's also a technique with real staying power: it was the backbone of Deep Blue, the chess machine that beat world champion Garry Kasparov in 1997, decades after Samuel quietly used it for checkers.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://drive.google.com/file/d/1wk6siVlagwB9-13cf-0dbWVwrvXabgeV/view?usp=sharing" rel="noopener noreferrer" class="c-link"&gt;
            pruning comparision - Google Drive
          &lt;/a&gt;
        &lt;/h2&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fssl.gstatic.com%2Fdocs%2Fdoclist%2Fimages%2Fdrive_favicon_2026_32dp.png" width="32" height="32"&gt;
          drive.google.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;/h2&gt;

&lt;h2&gt;
  
  
  The idea that mattered most: learning from your own changing mind
&lt;/h2&gt;

&lt;p&gt;This is the part that echoes into every modern RL system, and it's easy to undersell because it sounds so small.&lt;/p&gt;

&lt;h3&gt;
  
  
  The old assumption
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft4xnmc7j8ju2h73c65rm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft4xnmc7j8ju2h73c65rm.png" alt="old assumption" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 1950s default: learning happens at the &lt;em&gt;end&lt;/em&gt;. Play the whole game, see who won, then work out what went wrong. This became known as &lt;strong&gt;Monte Carlo learning&lt;/strong&gt; — and it's brutally slow. You need a full game before learning anything, and if the game runs 100 moves, one noisy final signal has to somehow get distributed across all 100 decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Samuel's question: why wait?
&lt;/h3&gt;

&lt;p&gt;The machine already had a second opinion available, one move later, for free. If a position looked 70% winning after move 10, and only 50% winning after move 11 — something was already learned, right there, with no need to finish the game. Your own estimate moved, and estimates don't move for no reason.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkl8ofqe1zuuxx7i43yj9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkl8ofqe1zuuxx7i43yj9.png" alt="TD improments" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Real-life version: you leave home expecting a 20-minute drive. Ten minutes in, you hit an empty motorway and revise to "7 more minutes." You haven't arrived yet, you don't know the true total — and you've unmistakably learned something the moment your prediction jumped.&lt;/p&gt;

&lt;p&gt;That's the whole trick: learn from the &lt;em&gt;gap between consecutive predictions&lt;/em&gt;, not from the final answer. It sidesteps Minsky's credit-assignment problem rather than solving it head-on — each move only ever has to explain the &lt;em&gt;next&lt;/em&gt; move, not the whole game.&lt;/p&gt;

&lt;h3&gt;
  
  
  The formula
&lt;/h3&gt;

&lt;p&gt;For a game like checkers, where nothing scores until someone wins:&lt;/p&gt;

&lt;p&gt;V(S_t) ← V(S_t) + α [ V(S_t+1) − V(S_t) ]&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V(S_t) — current guess about this position&lt;/li&gt;
&lt;li&gt;V(S_t+1) — the guess one move later&lt;/li&gt;
&lt;li&gt;[V(S_t+1) − V(S_t)] — the &lt;strong&gt;TD error&lt;/strong&gt;: how wrong I just turned out to be&lt;/li&gt;
&lt;li&gt;α — learning rate: too high and it's jittery, too low and it barely moves&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In plain English: nudge what you believed toward what you now believe, in proportion to how surprised you are.&lt;/p&gt;

&lt;p&gt;The general version below isn't a new idea — it's the exact same bracket with two extra pieces bolted on, so you can see them coming rather than guessing where they came from. It adds in any reward collected along the way, plus a discount for how much future value matters:&lt;/p&gt;

&lt;p&gt;V(S_t) ← V(S_t) + α [ r_t+1 + γ V(S_t+1) − V(S_t) ]&lt;/p&gt;

&lt;p&gt;Checkers collapses back to the simple version because nothing is scored mid-game (r = 0) and a win in 10 moves is worth exactly as much as a win now (γ = 1).&lt;/p&gt;

&lt;h3&gt;
  
  
  The déjà vu moment
&lt;/h3&gt;

&lt;p&gt;That bracket should look familiar if animal learning is on your radar at all — and if you've been following this series, it should ring a very specific bell. This is the &lt;strong&gt;prediction error&lt;/strong&gt; term flagged back in Blog 3, finally getting the job it was promised. Same idea, same shape, just a new name and a new job description: back then it fired once per trial, at the end. Here, it fires on every single move.&lt;/p&gt;

&lt;p&gt;Pavlov's dogs weren't learning from bells — they were learning from &lt;em&gt;being wrong about bells&lt;/em&gt;. A decade after Samuel, psychologists Rescorla and Wagner wrote down almost the identical rule to explain it: change your belief in proportion to your error. Different letters, same bracket — reality minus expectation, scaled by how much you're willing to update.&lt;/p&gt;

&lt;p&gt;An IBM engineer trying to save vacuum-tube cycles, and two psychologists trying to explain salivating dogs, landed on the same equation from completely opposite ends of science, with zero contact between them. That's not a coincidence — it's a strong hint that prediction error is something close to fundamental about what learning actually &lt;em&gt;is&lt;/em&gt;. (It gets better: in the 1990s, Wolfram Schultz found dopamine neurons firing in a pattern that looks almost exactly like a TD error signal. More on that in a later post.)&lt;/p&gt;

&lt;p&gt;And notice what TD learning never needed: the rulebook Wall 2 said was impossible to get. Just the current state, the next state, and two estimates. That's &lt;strong&gt;model-free&lt;/strong&gt; reinforcement learning — arguably the single most important idea in this post — quietly running on a vacuum-tube computer in 1959, almost thirty years before Richard Sutton formalised it as TD(λ) in 1988.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F96twyh8rv4xoua2ntler.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F96twyh8rv4xoua2ntler.png" alt="Monte Carlo VS TD" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  MENACE: reinforcement learning built out of matchboxes
&lt;/h2&gt;

&lt;p&gt;Samuel had IBM's hardware. British researcher Donald Michie had a rather different constraint: no computer access at all. So in 1961, he built one out of matchboxes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MENACE&lt;/strong&gt; — the Matchbox Educable Noughts And Crosses Engine — used 304 matchboxes, each labelled with a tic-tac-toe position MENACE might face, and filled with coloured beads. Each colour maps to one legal move.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To move:&lt;/strong&gt; find the matching box, shake it, pull a bead blind. Its colour is the move. Leave the box open — you'll need the trail later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To learn:&lt;/strong&gt; after the game, walk back along the trail of open boxes. Win → return the bead played, plus three more of the same colour. Draw → add just one. Loss → the bead simply isn't returned; it's gone. More beads of a colour means a better chance of drawing it next time.&lt;/p&gt;

&lt;p&gt;Michie played roughly 220 games against it over a weekend. It went from flailing randomly to essentially unbeatable.&lt;/p&gt;

&lt;h3&gt;
  
  
  The detail worth noticing
&lt;/h3&gt;

&lt;p&gt;Michie didn't load every box with the same number of beads. Early-game boxes started with about four beads per move; late-game boxes tapered down toward one. That's a deliberately engineered &lt;strong&gt;exploration schedule&lt;/strong&gt;. Early moves are far from the outcome, so any one game barely tells you if they were good — you want MENACE to keep trying alternatives. Late moves sit right next to the result, so their feedback is trustworthy and can be locked in fast. That's the &lt;strong&gt;explore vs. exploit&lt;/strong&gt; trade-off, solved in 1961 with nothing but bead-counting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this is a plot point, not a party trick
&lt;/h3&gt;

&lt;p&gt;Samuel's program learned to answer "how good is this position?" MENACE never asked that question — it has no concept of a position being worth 0.7. It only tracks "which move should I make more often from here?"&lt;/p&gt;

&lt;p&gt;In blog 3's terms: MENACE is growing a &lt;strong&gt;policy&lt;/strong&gt; — &lt;code&gt;π&lt;/code&gt;, a state-to-action lookup — directly. It never computes a value for anything along the way. That's the split worth holding onto:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Samuel&lt;/th&gt;
&lt;th&gt;Michie&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Learns&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Values&lt;/strong&gt; — how good is this state?&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;A policy&lt;/strong&gt; — what should I do here?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stores&lt;/td&gt;
&lt;td&gt;Feature weights&lt;/td&gt;
&lt;td&gt;Action probabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern descendant&lt;/td&gt;
&lt;td&gt;Value-based methods — learn a score for each move, then just pick the best one (Q-learning, and its neural-network upgrade DQN)&lt;/td&gt;
&lt;td&gt;Policy-gradient methods — skip the scoring step, learn the action probabilities directly (REINFORCE, and its more stable modern version PPO)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two men, two continents, same decade — and they'd independently split reinforcement learning into the two halves it still has today. Modern RL doesn't pick a winner; it runs both at once. &lt;strong&gt;Actor-Critic&lt;/strong&gt; methods (more on these in a later post) are literally a Critic estimating values (Samuel's job) paired with an Actor adjusting action probabilities (Michie's job), each sharpening the other.&lt;/p&gt;

&lt;p&gt;MENACE also proves something worth sitting with: reinforcement learning isn't a property of silicon. It's a mathematical principle. Run it on vacuum tubes, neurons, or 304 matchboxes on a Sunday afternoon — what matters is the loop: act, observe the consequence, adjust, repeat.&lt;/p&gt;

&lt;p&gt;It also hit the exact same wall Samuel did: every position needs its own box, and one extra square collapses the shelf. Same curse, cardboard edition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Michie didn't stop there.&lt;/strong&gt; In 1968, with R. A. Chambers, he took the matchbox idea into physics: &lt;strong&gt;BOXES&lt;/strong&gt;, balancing a pole on a moving cart using nothing but a bang when it fell over. Widrow and Smith had balanced the same pole in 1964 — but with a human demonstrating the right move at each step. BOXES threw the teacher out entirely: no demonstration, just eventual failure walked backward through whichever boxes were open. The one new trick it needed was &lt;strong&gt;state aggregation&lt;/strong&gt; — chopping a continuous space (pole angle, cart speed) into discrete chunks, since you can't label a matchbox for infinitely many positions. That's the field's first honest step toward &lt;strong&gt;function approximation&lt;/strong&gt; — a plain-English way of saying "estimate the value instead of memorising it," the same escape hatch this whole post keeps circling back to. Cart-pole balancing went on to become RL's most reused benchmark ever since.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxgx4blsdq6yrfszi4xw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxgx4blsdq6yrfszi4xw8.png" alt="MENACE matchbox setup" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Two roads, one open question
&lt;/h2&gt;

&lt;p&gt;By the late 1960s, two things were true at once. Samuel and Michie both had systems that genuinely learned from experience — no rulebook, no complete map of the world, and they visibly got better over time. But nobody could prove any of it. No convergence guarantee, no theorem saying "this reaches the optimal policy" — just clever hacks that happened to hold up on small problems.&lt;/p&gt;

&lt;p&gt;Bellman's framework had the opposite problem: flawless proofs, unusable in practice.&lt;/p&gt;

&lt;p&gt;Which set up the question the field spent the next twenty years chasing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Can you keep Bellman's guarantees without needing Bellman's rulebook?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyywrw5nv22v0bsxd3cbp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyywrw5nv22v0bsxd3cbp.png" alt="modelfree vs modelbased" width="440" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That question is the birth of model-free reinforcement learning — and chasing it eventually pushes the field toward systems that learn their own features instead of borrowing a human's. Which is to say: toward neural networks.&lt;/p&gt;

&lt;p&gt;Worth sitting with for a second before we move on: the technique that trains most modern chatbots to be helpful — RLHF, reinforcement learning from human feedback — is a direct descendant of exactly this idea. No rulebook for "what makes a good response," just a reward signal and a model updating itself against its own predictions. The line from a matchbox in 1961 to a language model in 2026 runs straight through this post.&lt;/p&gt;

&lt;p&gt;But not yet. First, someone has to ask a harder version of the question.&lt;/p&gt;




&lt;h2&gt;
  
  
  Coming up next
&lt;/h2&gt;

&lt;p&gt;Samuel and Michie both had one thing quietly working in their favour: their worlds behaved. Move a checker, it stays moved. Draw a bead, that's the move you play. The environment was unknown, but at least it was &lt;em&gt;reliable&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now break that assumption. What if pressing the same button in the same situation works 70% of the time and fails the other 30%, for no reason you can see? A single result stops meaning anything — it might just be noise. You need to learn from distributions, not events, while still acting sensibly under real uncertainty.&lt;/p&gt;

&lt;p&gt;That discipline was being built in parallel, largely by control theorists who weren't talking to the game-playing crowd at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next up — RL 5: Learning Automata and Stochastic Environments (1961–1974).&lt;/strong&gt; How do you make good decisions when the world itself won't give you a straight answer?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Series index:&lt;br&gt;
Blog 1 — Biological foundations and the Law of Effect&lt;br&gt;
Blog 2 — Classical conditioning and prediction&lt;br&gt;
Blog 3 — Bellman, MDPs and Dynamic Programming&lt;br&gt;
Blog 4 — Early heuristics and the birth of TD learning (this post)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>RL 3: Bellman Equations and Markov Decision Processes (1950s–1960s)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Fri, 18 Sep 2026 20:47:23 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-3-bellman-equations-and-markov-decision-processes-1950s-1960s-2pp0</link>
      <guid>https://dev.to/mitanshgor/rl-3-bellman-equations-and-markov-decision-processes-1950s-1960s-2pp0</guid>
      <description>&lt;h2&gt;
  
  
  Where we left off
&lt;/h2&gt;

&lt;p&gt;Two quick reminders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thorndike (1898)&lt;/strong&gt; watched cats escape a puzzle box and gave us the &lt;strong&gt;Law of Effect&lt;/strong&gt;: do something, get a good result, do it again. Get a bad result, stop. Learning is bookkeeping over consequences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 2&lt;/strong&gt; turned that idea into hardware. Shannon's mouse ran a maze and remembered the route. Minsky's SNARC strengthened the wires that led to good outcomes.&lt;/p&gt;

&lt;p&gt;Both worked. Both were missing the same thing.&lt;/p&gt;

&lt;p&gt;Thorndike's cat knew &lt;em&gt;"pulling that loop felt good."&lt;/em&gt; It did &lt;strong&gt;not&lt;/strong&gt; know it was three moves from freedom. Shannon's mouse could replay a path, but it couldn't tell you why one path was better than another.&lt;/p&gt;

&lt;p&gt;Nobody had a word for this yet:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt; — a number attached to a situation that says &lt;em&gt;how good does the future look from right here?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That one missing number is what this whole post is about.&lt;/p&gt;




&lt;h3&gt;
  
  
  Side note: the biologists were chasing the same number
&lt;/h3&gt;

&lt;p&gt;Worth thirty seconds, because it makes the maths feel less alien.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rescorla and Wagner (1972)&lt;/strong&gt; showed that animals don't learn from repetition. They learn from &lt;strong&gt;surprise&lt;/strong&gt;. If a bell already predicts food perfectly, adding a light next to the bell teaches the animal almost nothing about the light. There's no surprise left to learn from.&lt;/p&gt;

&lt;p&gt;Their rule, in plain English:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;new belief = old belief + (small step) × (what actually happened − what I expected)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That last bracket — reality minus expectation — is called &lt;strong&gt;prediction error&lt;/strong&gt;. Hold onto it. It comes back in Blog 4 with a much bigger job.&lt;/p&gt;

&lt;p&gt;(Yes, 1972 is out of order here. I'm putting it early because it explains "value" better than a grid does.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98aodvd1bi2qni84k7q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98aodvd1bi2qni84k7q9.png" alt="Prediction error diagram" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter Richard Bellman
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28nj9nvict7epd44gyk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28nj9nvict7epd44gyk0.png" alt="Richard Bellman" width="146" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 1949, a mathematician named &lt;strong&gt;Richard Bellman&lt;/strong&gt; started working at &lt;strong&gt;RAND&lt;/strong&gt;, a US think tank. His job was a specific shape of problem: you make a choice, the world changes, then you have to choose again. Missile guidance. Supply planning. Anything where today's decision quietly reshapes tomorrow's options.&lt;/p&gt;

&lt;p&gt;He cracked it. Then he needed a name for it, So he picked two words that sounded harmless and industrial: &lt;strong&gt;Dynamic Programming&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;(The story has probably been tidied up over the years — the dates don't quite line up — but the name stuck, and it's now one of the most important terms in computer science.)&lt;/p&gt;

&lt;p&gt;Here's the problem he was actually solving.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem, in the form we'll use all post
&lt;/h2&gt;

&lt;p&gt;Forget missiles. Here's the setup we'll use for everything that follows.&lt;/p&gt;

&lt;p&gt;You're on a grid. You start in one corner. The goal is somewhere else. Every step costs you a little energy. Some cells are bad news. You want to reach the goal having collected as much reward as possible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cx1d3ep6pxzlra06vvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cx1d3ep6pxzlra06vvm.png" alt="grid" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Easy to describe. Genuinely nasty to solve &lt;em&gt;systematically&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The obvious approach is to list every possible path and pick the best. That works right up until it catastrophically doesn't. Paths multiply exponentially with grid size. 10×10 is already unpleasant. 100×100 is hopeless. Bellman later gave this failure mode a name — &lt;strong&gt;the curse of dimensionality&lt;/strong&gt; — and we'll come back to it at the end, because it's the villain of the whole post.&lt;/p&gt;

&lt;p&gt;So he needed a fundamentally different kind of reasoning.&lt;/p&gt;




&lt;h2&gt;
  
  
  Dynamic Programming: solve it backward, and only solve it once
&lt;/h2&gt;

&lt;p&gt;Bellman's core insight is called the &lt;strong&gt;Principle of Optimality&lt;/strong&gt;. Here it is in his words:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"An optimal policy has the property that whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a mouthful. In human:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If the best route from A to C goes through B, then the B-to-C part of it must itself be the best route from B to C.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because if it weren't — if there were a better way from B to C — you'd just swap it in and get a better A-to-C route. Contradiction. Done.&lt;/p&gt;

&lt;p&gt;Sounds trivial. It isn't, because of what it licenses you to do:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You only ever have to solve each sub-problem once.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you know the best way from B onward, &lt;em&gt;every&lt;/em&gt; route that passes through B can reuse that answer for free. No recomputation. That's Dynamic Programming: chop a giant sequential problem into overlapping sub-problems, solve them from the end backward, and cache the answers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9f9yzz0hsk9op7rj7817.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9f9yzz0hsk9op7rj7817.png" alt="stare-reardloop" width="799" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;backward&lt;/strong&gt; part is the counterintuitive bit and it's worth sitting with. Bellman didn't ask "what's my best first move?" He asked &lt;strong&gt;"what's my best &lt;em&gt;last&lt;/em&gt; move?"&lt;/strong&gt; Then second-to-last. Then third-to-last, propagating backward until every square on the board has an answer.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;backward induction&lt;/strong&gt;, and it's not a historical curiosity — it is still, structurally, how modern RL agents plan.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvoj8dzboblvy02ckek0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvoj8dzboblvy02ckek0h.png" alt="backward induction" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Hold onto this:&lt;/strong&gt; the future is easier to reason about than the past, because the future has an ending you can anchor to.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Five nouns you need before the equation shows up
&lt;/h2&gt;

&lt;p&gt;So: five nouns first. Equation after. All five together are called a &lt;strong&gt;Markov Decision Process (MDP)&lt;/strong&gt; — the formal container the maths lives in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F460d9r80ynde2ixbgf04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F460d9r80ynde2ixbgf04.png" alt="MDP diagram" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. State — &lt;code&gt;s&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Where you are. On the grid, "row 3, column 4." In chess, the board position. In a delivery robot, position &lt;em&gt;plus&lt;/em&gt; battery &lt;em&gt;plus&lt;/em&gt; whether it's holding a package. The full set of states is written &lt;code&gt;S&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Action — &lt;code&gt;a&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
What you can do from here. On the grid: up, down, left, right. The full set is &lt;code&gt;A&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Transition — &lt;code&gt;P(s' | s, a)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Read it as: &lt;em&gt;"the probability of landing in state &lt;code&gt;s'&lt;/code&gt;, given that I was in &lt;code&gt;s&lt;/code&gt; and did &lt;code&gt;a&lt;/code&gt;."&lt;/em&gt; The apostrophe just means "next."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Reward — &lt;code&gt;R(s, a)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
A number the environment hands you for doing &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;s&lt;/code&gt;. This is where you, the designer, encode what "good" means. Reach the goal: +10. Take a step: −1. Fall in the pit: −100.&lt;/p&gt;

&lt;p&gt;Get this wrong and your agent will cheerfully optimise the wrong thing. Reward design is 90% of applied RL pain, and I'm not going to pretend otherwise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Policy — &lt;code&gt;π&lt;/code&gt; (pi)&lt;/strong&gt;&lt;br&gt;
Your strategy. A rule that maps &lt;em&gt;state → action&lt;/em&gt;. "When in this square, go right." That's it. A policy isn't a plan or a path — it's a lookup table of what to do &lt;em&gt;anywhere&lt;/em&gt; you might find yourself.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The whole field, in one sentence:&lt;/strong&gt; an MDP describes the world; a policy describes your behaviour in it; and the rest of RL is the search for the best policy.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz9309bj0gu2w598yq1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz9309bj0gu2w598yq1s.png" alt="Reinforcement Learning loop" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  The one assumption holding all of this up
&lt;/h2&gt;

&lt;p&gt;There's a condition the whole framework quietly depends on, and it's called the &lt;strong&gt;Markov Property&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The future depends only on the present state — not on the history of how you got there.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j3w2pfw16tjoscydeb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j3w2pfw16tjoscydeb1.png" alt="stateIsEnough" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First reaction to this is usually: &lt;em&gt;that's obviously false, history matters all the time.&lt;/em&gt; Fair. But that's not quite what it says.&lt;/p&gt;

&lt;p&gt;It says &lt;strong&gt;history must already be baked into the state.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your robot's battery level affects the next decision, then battery level belongs &lt;em&gt;in the state definition&lt;/em&gt;. Once it's in there, you don't need to replay the last 50 timesteps — you just look at where you are now.&lt;/p&gt;

&lt;p&gt;Two quick examples to make it concrete:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chess is Markov.&lt;/strong&gt; The board position tells you everything. It doesn't matter whether you reached it through a brilliant sacrifice or a series of blunders — the position is the position.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poker is not Markov if your state is just "my cards."&lt;/strong&gt; Whether your opponent has been bluffing all night genuinely changes what you should do. Fix it by expanding the state to include betting history. Now it's Markov again — and much bigger. (Notice the trade you just made. That's foreshadowing.)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The neat way to say it:&lt;/strong&gt; the &lt;em&gt;state&lt;/em&gt; is allowed to have memory. The &lt;em&gt;policy&lt;/em&gt; isn't.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This assumption is exactly what makes RL computable. Without it, an agent would have to carry and process its entire past at every step. With it, a policy is just a lookup: current state in, action out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One more assumption, and it's a big one.&lt;/strong&gt; For this entire post, the agent is assumed to already &lt;strong&gt;know&lt;/strong&gt; &lt;code&gt;P&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt;. It knows the physics of the world and the reward structure before it takes a single step. That's called &lt;strong&gt;model-based&lt;/strong&gt; RL, and it's what makes the maths clean here.&lt;/p&gt;

&lt;p&gt;It is also completely unrealistic, and Blog 4 takes a sledgehammer to it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Return and γ: why "how good" needs a definition
&lt;/h2&gt;

&lt;p&gt;One more thing before the equation. If value means "how promising is the future from here," we need to say what &lt;em&gt;the future&lt;/em&gt; means numerically.&lt;/p&gt;

&lt;p&gt;Add up all the reward you'll collect from now until the end. That total is called the &lt;strong&gt;return&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Except there's a problem: if the task never ends, that sum runs to infinity, and "infinity" is a terrible thing to compare against another infinity. So Bellman introduced a &lt;strong&gt;discount factor, &lt;code&gt;γ&lt;/code&gt; (gamma)&lt;/strong&gt;, a number between 0 and 1. Reward one step away is multiplied by γ. Two steps away, γ². Three steps, γ³. And so on.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;G&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Two things fall out of this, and both matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mathematically:&lt;/strong&gt; the sum now converges. It's a geometric series. No infinities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Behaviourally:&lt;/strong&gt; γ is a &lt;strong&gt;personality dial.&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;γ near &lt;strong&gt;0&lt;/strong&gt; — a myopic agent. Only right now exists. It will grab the nearest +1 and ignore a +100 two steps away.&lt;/li&gt;
&lt;li&gt;γ near &lt;strong&gt;1&lt;/strong&gt; — a patient agent. Happy to eat a −1 today for a +100 later.&lt;/li&gt;
&lt;li&gt;γ = 0.9 — a reasonable default that says "about ten steps of foresight."&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's compound interest, run backward. A reward ten steps away at γ = 0.9 is worth about 35% of its face value today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fivqu2yfy9rbo9lxbnlf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fivqu2yfy9rbo9lxbnlf8.png" alt="Same grid solved three times" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Value: the number Thorndike's cat never had
&lt;/h2&gt;

&lt;p&gt;Now we can define the thing this whole post is chasing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;V(s)&lt;/code&gt; — the value of state &lt;code&gt;s&lt;/code&gt; — is the expected return you'll collect if you start in &lt;code&gt;s&lt;/code&gt; and behave well from there on.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's the number the cat didn't have. The cat knew &lt;em&gt;"this felt good."&lt;/em&gt; A value function knows &lt;em&gt;"this square is worth 7.1, that one's worth 5.4, so go left."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And that's the whole trick: &lt;strong&gt;once every square has a number, choosing an action stops being a search problem and becomes a comparison.&lt;/strong&gt; Look at the neighbouring numbers. Walk toward the big one. Done.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bellman Equation
&lt;/h2&gt;

&lt;p&gt;In his 1957 book &lt;em&gt;Dynamic Programming&lt;/em&gt;, Bellman wrote down the recursion that ties all of this together:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In one sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The value of where you are = the best immediate reward you can grab + the discounted value of wherever you end up next.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every symbol is one of the five nouns you already know:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;Reading&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;V(s)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;how good it is to be here&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;max_a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;you, choosing.&lt;/strong&gt; Try every action, keep the best&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;R(s, a)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;what you get right now&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;γ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;how much you care about later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;∑ P(s':s,a) · V(s')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the world, responding.Average over every place you might land, weighted by likelihood&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things I want to flag, because they're where people quietly lose the thread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First: &lt;code&gt;max&lt;/code&gt; and &lt;code&gt;∑&lt;/code&gt; are doing opposite jobs.&lt;/strong&gt; The &lt;code&gt;max&lt;/code&gt; is the agent &lt;em&gt;choosing&lt;/em&gt;. The &lt;code&gt;∑&lt;/code&gt; is the world &lt;em&gt;rolling dice&lt;/em&gt;. You control your action. You do not control the outcome. If the transitions were deterministic, that &lt;code&gt;∑&lt;/code&gt; would collapse to a single term and disappear — it only exists because the world is uncertain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second: &lt;code&gt;V(s)&lt;/code&gt; appears on both sides.&lt;/strong&gt; That's not sloppy notation, it's the entire idea. The equation is &lt;strong&gt;self-referential&lt;/strong&gt; — the value of a state is defined in terms of the values of &lt;em&gt;other&lt;/em&gt; states.&lt;/p&gt;

&lt;p&gt;Which raises the obvious question: if V is defined in terms of V, how do you ever compute it?&lt;/p&gt;

&lt;p&gt;You guess, then you improve. Start with V = 0 everywhere (a wrong but harmless guess), apply the equation, get better numbers, apply again. The values stop changing when they're all consistent with each other. Mathematicians call that a &lt;strong&gt;fixed point&lt;/strong&gt; — the place where applying the rule doesn't change anything anymore.&lt;/p&gt;

&lt;p&gt;That "keeps changing until it doesn't" process is the entire computational game. And it's easier to believe once you've watched it happen, so let's watch it happen.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's actually put numbers on the board
&lt;/h2&gt;

&lt;p&gt;Here's the smallest example that shows the real behaviour. A corridor, four squares, then the goal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ S1 ][ S2 ][ S3 ][ S4 ][ GOAL ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Actions: move left or move right. Deterministic — no ice.&lt;/li&gt;
&lt;li&gt;Every move costs &lt;strong&gt;−1&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Stepping into GOAL pays &lt;strong&gt;+10&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;γ = &lt;strong&gt;0.9&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;GOAL is terminal, so &lt;code&gt;V(GOAL) = 0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Work backward, exactly as Bellman said to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;S4&lt;/strong&gt; is one step from GOAL: &lt;code&gt;V(S4) = −1 + 10 + 0.9 × 0 =&lt;/code&gt; &lt;strong&gt;9.00&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;S3&lt;/strong&gt; is one step from S4: &lt;code&gt;V(S3) = −1 + 0.9 × 9.00 =&lt;/code&gt; &lt;strong&gt;7.10&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;S2:&lt;/strong&gt; &lt;code&gt;V(S2) = −1 + 0.9 × 7.10 =&lt;/code&gt; &lt;strong&gt;5.39&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;S1:&lt;/strong&gt; &lt;code&gt;V(S1) = −1 + 0.9 × 5.39 =&lt;/code&gt; &lt;strong&gt;3.85&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 3.85 ][ 5.39 ][ 7.10 ][ 9.00 ][ GOAL ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Look at what happened. &lt;strong&gt;The goal's reward leaked backward through the corridor and left a slope behind it.&lt;/strong&gt; The agent doesn't need a map, a plan, or a search. It just walks uphill. The value function turned a planning problem into a gradient you can follow like a scent trail.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://drive.google.com/file/d/1zEZ-xmnFXWbNvPaQeYPOpUamLs6qBp62/view?usp=sharing" rel="noopener noreferrer" class="c-link"&gt;
            Animated_heatmap_of_the_x_gr.mp4 - Google Drive
          &lt;/a&gt;
        &lt;/h2&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fssl.gstatic.com%2Fdocs%2Fdoclist%2Fimages%2Fdrive_favicon_2026_32dp.png" width="32" height="32"&gt;
          drive.google.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



&lt;h3&gt;
  
  
  Now watch it converge from nothing
&lt;/h3&gt;

&lt;p&gt;That was the answer. Here's the &lt;em&gt;process&lt;/em&gt; — starting from V = 0 everywhere and sweeping the equation across all four states repeatedly:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sweep&lt;/th&gt;
&lt;th&gt;V(S1)&lt;/th&gt;
&lt;th&gt;V(S2)&lt;/th&gt;
&lt;th&gt;V(S3)&lt;/th&gt;
&lt;th&gt;V(S4)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;−1.00&lt;/td&gt;
&lt;td&gt;−1.00&lt;/td&gt;
&lt;td&gt;−1.00&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9.00&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;−1.90&lt;/td&gt;
&lt;td&gt;−1.90&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7.10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;−2.71&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.39&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;7.10&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;3.85&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5.39&lt;/td&gt;
&lt;td&gt;7.10&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;3.85&lt;/td&gt;
&lt;td&gt;5.39&lt;/td&gt;
&lt;td&gt;7.10&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things worth noticing here, and honestly this table is the most important object in the post:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Information travels exactly one square per sweep.&lt;/strong&gt; Sweep 1, only S4 knows the goal exists. Sweep 2, S3 finds out. It's a wavefront moving backward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The early numbers are hilariously wrong.&lt;/strong&gt; At sweep 3, S1 thinks it's worth −2.71 — it can only see step costs and no payoff yet. It's a pessimist with incomplete information. It gets over it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You don't need a stopping rule, you need a stopping &lt;em&gt;condition&lt;/em&gt;.&lt;/strong&gt; When a full sweep changes nothing, you're done. That's the fixed point, made of actual numbers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8grw8sbri68uc9p8788.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8grw8sbri68uc9p8788.png" alt="bar chart per sweep" width="671" height="926"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Howard's Policy Iteration: from knowing values to having a strategy
&lt;/h2&gt;

&lt;p&gt;Bellman gave us the value of every square. But there's a subtly separate question: how do you systematically build the &lt;strong&gt;strategy&lt;/strong&gt; — the policy — that goes with it?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ronald Howard&lt;/strong&gt;, in his 1960 monograph &lt;em&gt;Dynamic Programming and Markov Processes&lt;/em&gt;, noticed the problem is circular:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To compute &lt;code&gt;V(s)&lt;/code&gt;, you need to know which policy &lt;code&gt;π&lt;/code&gt; the agent is following.&lt;/li&gt;
&lt;li&gt;To find the best &lt;code&gt;π&lt;/code&gt;, you need to know &lt;code&gt;V(s)&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Classic chicken and egg. Howard's answer: &lt;strong&gt;stop trying to do both at once. Alternate.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" alt="PE vs PI" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 — Policy Evaluation: "how good is my current strategy?"
&lt;/h3&gt;

&lt;p&gt;Freeze the policy. Don't try to improve it. Just ask: &lt;em&gt;if I followed this exact strategy forever, what would each state be worth?&lt;/em&gt;&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;))&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;))&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Notice the &lt;code&gt;max&lt;/code&gt; is gone.&lt;/strong&gt; There's no choosing here. &lt;code&gt;π(s)&lt;/code&gt; tells you what to do; you're just measuring the consequences. This isn't optimisation, it's &lt;em&gt;scorekeeping&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 2 — Policy Improvement: "could I do better?"
&lt;/h3&gt;

&lt;p&gt;Now take those scores and ask, at every state: &lt;em&gt;given what I now know things are worth, is there an action better than the one my policy currently prescribes?&lt;/em&gt; If yes, switch to it.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;arg max&lt;/code&gt; vs &lt;code&gt;max&lt;/code&gt;, since this trips everyone up:&lt;/strong&gt; &lt;code&gt;max&lt;/code&gt; returns &lt;em&gt;the best value&lt;/em&gt;. &lt;code&gt;arg max&lt;/code&gt; returns &lt;em&gt;the action that achieved it&lt;/em&gt;. Evaluation wants the number; improvement wants the move.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  And repeat
&lt;/h3&gt;

&lt;p&gt;Evaluate. Improve. Evaluate. Improve. Stop when an improvement step changes nothing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0vlv9oo30xbnr0swsa5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0vlv9oo30xbnr0swsa5.png" alt="Policy Eval and Improvement" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Howard proved two things about this loop that are genuinely reassuring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The greedy step never makes the policy worse.&lt;/strong&gt; Every improvement is an improvement or a tie. It can't wander off toward a worse policy — the local, greedy move is globally safe here. (That's a strong guarantee, and one that quietly evaporates once we start using neural networks in later posts.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On a finite MDP, it terminates in a finite number of iterations.&lt;/strong&gt; There are only finitely many policies, you never repeat one, so you must stop. Usually in a handful of rounds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0n70gh4uwe9sqkz4sog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0n70gh4uwe9sqkz4sog.png" alt="Eval Improv General idea" width="799" height="695"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And here's the part that should give you a small jolt:&lt;/strong&gt; that two-role split — one part measuring, one part deciding — is the direct ancestor of the &lt;strong&gt;Actor–Critic&lt;/strong&gt; architectures we'll get to in Blog 7. The Critic does Policy Evaluation. The Actor does Policy Improvement.&lt;/p&gt;

&lt;p&gt;That structure wasn't invented for deep learning. It was sitting in a 1960 operations research monograph the whole time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1sj0dabx5pxpe0c7fu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1sj0dabx5pxpe0c7fu0.png" alt="actor-critic" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Value Iteration: the impatient version
&lt;/h2&gt;

&lt;p&gt;Policy Iteration is a bit fussy. It insists on &lt;em&gt;fully&lt;/em&gt; evaluating a policy — running evaluation to convergence — before it'll consider improving anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Value Iteration&lt;/strong&gt; says: why wait? Fold the improvement directly into the update.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The &lt;code&gt;max&lt;/code&gt; is back, and it's inside the loop.&lt;/strong&gt; Every single update implicitly re-decides the best action. No separate improvement phase exists.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkisnepo5w1ik802tpuqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkisnepo5w1ik802tpuqo.png" alt="Value iteration code loop" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Value Iteration never stores a policy at all. It just hammers on the value function until it settles, and &lt;em&gt;then&lt;/em&gt; you read the policy off: stand in each state, look at the neighbours, take the action pointing at the biggest number.&lt;/p&gt;

&lt;p&gt;(That sweep table you looked at earlier? That was Value Iteration. You've already seen it run.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol3kxq76qxut4anbugrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol3kxq76qxut4anbugrn.png" alt="Value iteration diagram" width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Policy Iteration vs Value Iteration, side by side
&lt;/h2&gt;

&lt;p&gt;Same equation, same destination, different temperament.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Policy Iteration is the coach who watches the entire game.&lt;/strong&gt; Films it. Writes a 40-page report. Rewrites the playbook from scratch before the next match. Few iterations, each one expensive and each one a big leap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Value Iteration is the coach who stops play after every snap.&lt;/strong&gt; &lt;em&gt;"Stop — standing three feet left would've been worth two more points."&lt;/em&gt; Cheap per update, but it needs a lot of them. Constantly nudging everyone's understanding of the field.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Policy Iteration&lt;/th&gt;
&lt;th&gt;Value Iteration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Explicit policy?&lt;/td&gt;
&lt;td&gt;Yes, maintained separately&lt;/td&gt;
&lt;td&gt;No, implicit in the values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;max&lt;/code&gt; in the update?&lt;/td&gt;
&lt;td&gt;Only in the improvement step&lt;/td&gt;
&lt;td&gt;Every update&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost per iteration&lt;/td&gt;
&lt;td&gt;High (full evaluation)&lt;/td&gt;
&lt;td&gt;Low (one sweep)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iterations needed&lt;/td&gt;
&lt;td&gt;Few&lt;/td&gt;
&lt;td&gt;Many&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terminates when&lt;/td&gt;
&lt;td&gt;Policy stops changing&lt;/td&gt;
&lt;td&gt;Values stop changing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best when&lt;/td&gt;
&lt;td&gt;State space is small and exact&lt;/td&gt;
&lt;td&gt;State space is large or approximate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft67wzcfoyg1eg0yusm8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft67wzcfoyg1eg0yusm8x.png" alt="PI vs VI comparison" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which should you use? Small, well-defined state space where you want exactness — Policy Iteration. Large or approximate — Value Iteration.&lt;/p&gt;

&lt;p&gt;And worth flagging for later: &lt;strong&gt;almost every modern RL algorithm is spiritually a descendant of Value Iteration.&lt;/strong&gt; They update values continuously and never wait for a full evaluation to finish. Q-learning is Value Iteration with the model ripped out. DQN is Q-learning with a neural network glued on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd58xk4wtaecldkdl8ny6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd58xk4wtaecldkdl8ny6.png" alt="Convergence plot" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The curse they named but couldn't escape
&lt;/h2&gt;

&lt;p&gt;Now the bad news, and Bellman himself is the one who delivered it.&lt;/p&gt;

&lt;p&gt;Both algorithms require sweeping over &lt;strong&gt;every state in &lt;code&gt;S&lt;/code&gt;&lt;/strong&gt;. Every single one. Every iteration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;4-square corridor: 4 states. Trivial.&lt;/li&gt;
&lt;li&gt;10×10 grid: 100 states. Fine.&lt;/li&gt;
&lt;li&gt;Chess: roughly 10⁴⁴ positions.&lt;/li&gt;
&lt;li&gt;Go: more legal positions than there are atoms in the observable universe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bellman named this the &lt;strong&gt;curse of dimensionality&lt;/strong&gt;, in the same 1957 book that gave us the equation. Add one variable to your state description and the state space doesn't grow — it &lt;em&gt;multiplies&lt;/em&gt;. A robot tracking position, velocity, battery, and grip status doesn't have four problems. It has (positions × velocities × battery levels × grip states) problems.&lt;/p&gt;

&lt;p&gt;And remember the poker example from earlier? Fixing the Markov violation by stuffing betting history into the state made the state space explode. That's the curse arriving in person. &lt;strong&gt;Making a problem Markov and making it small are usually opposing goals.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" alt="PE vs PI" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is why RL went quiet for decades after Bellman. It wasn't that the theory was shaky. &lt;strong&gt;The theory was perfect and the computer was too small.&lt;/strong&gt; Dynamic Programming solves the &lt;em&gt;structure&lt;/em&gt; of sequential decision-making completely — it just needs a table with one row per state, and sometimes that table can't exist.&lt;/p&gt;

&lt;p&gt;The escape route — stop storing &lt;code&gt;V(s)&lt;/code&gt; in a table and start &lt;em&gt;approximating&lt;/em&gt; it with a function — wouldn't properly arrive until DeepMind's DQN in 2013. But the problem was named here, in 1957. Nearly everything between then and now is an attempt to get around it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fldvjuox3yrc4hxi0ql3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fldvjuox3yrc4hxi0ql3p.png" alt="Exponential blowup chart" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why 1957 mathematics is running inside your 2026 chatbot
&lt;/h2&gt;

&lt;p&gt;It sounds like a stretch that equations written for missile guidance underpin modern reasoning models. It isn't.&lt;/p&gt;

&lt;p&gt;When a model like &lt;strong&gt;o1&lt;/strong&gt; or &lt;strong&gt;DeepSeek-R1&lt;/strong&gt; works through a hard problem, it isn't just emitting the most likely next token. It's exploring reasoning paths, &lt;em&gt;scoring&lt;/em&gt; how promising each one looks, and abandoning the ones heading toward a dead end.&lt;/p&gt;

&lt;p&gt;Read that again with this post's vocabulary loaded:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A partial chain of reasoning is a &lt;strong&gt;state&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The next thing to write is an &lt;strong&gt;action&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;"Is this line of thinking going anywhere?" is a &lt;strong&gt;value estimate&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Backtracking out of a bad path is &lt;strong&gt;backward induction&lt;/strong&gt; — the same move Bellman made when he asked about the &lt;em&gt;last&lt;/em&gt; step instead of the first.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The state space changed from grid squares to token sequences. The tables became neural networks. The core question — &lt;em&gt;how good is this situation, really?&lt;/em&gt; — is unchanged since 1957.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjyhn54bk6dkq914dey11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjyhn54bk6dkq914dey11.png" alt="timeline" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Six things to keep
&lt;/h2&gt;

&lt;p&gt;If every equation falls out of your head by Thursday, keep these:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The world is states and actions&lt;/strong&gt; — that's an MDP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rewards define what "good" means&lt;/strong&gt; — and you're the one writing them, so be careful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value is a score for how promising the future looks from here&lt;/strong&gt; — the number Thorndike's cat never had.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Bellman Equation makes future reward flow backward&lt;/strong&gt; through states, leaving a slope you can climb.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A policy is just a rule for picking actions&lt;/strong&gt; — a lookup table, not a plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iteration fixes the circularity.&lt;/strong&gt; Guess, measure, improve, repeat, stop when nothing changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;If Bellman clicks, the rest of RL is refinement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmu8z9j1hlh0zh5csusmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmu8z9j1hlh0zh5csusmj.png" alt="Glossary" width="800" height="546"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What's coming next
&lt;/h2&gt;

&lt;p&gt;Everything in this post rested on one assumption I flagged and then leaned on hard: &lt;strong&gt;the agent already knows &lt;code&gt;P&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt;.&lt;/strong&gt; It knows the physics. It knows the payoffs. It's not learning about the world — it's &lt;em&gt;calculating&lt;/em&gt; against a world it already has a complete map of.&lt;/p&gt;

&lt;p&gt;Real agents don't get that map.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Blog 4 — Early Heuristics and the Birth of Temporal Difference Learning (1959–1968)&lt;/strong&gt;, that assumption gets torn up. We'll meet a program that had to work out what positions were worth by &lt;em&gt;playing&lt;/em&gt;, not by computing — and we'll finally see what happens when you take Rescorla and Wagner's "learn from surprise" idea and let it fire on every single step instead of once per trial.&lt;/p&gt;

&lt;p&gt;Remember the prediction error term from the top of this post? It's about to get a job.&lt;/p&gt;

&lt;p&gt;The equation was ready. The machine was next.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next: Blog 4 — Early Heuristics and the Birth of Temporal Difference Learning (1959–1968).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Previously: Blog 1 — Biological Foundations and the Law of Effect (1898–1949) · Blog 2 — The First Machines.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reinforcementlearning</category>
      <category>machinelearning</category>
      <category>ai</category>
      <category>history</category>
    </item>
    <item>
      <title>RL 2: The first physical and computational RL machines(1948–1954)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 12 Sep 2026 05:57:48 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-2-the-first-physical-and-computational-rl-machines1948-1954-1amh</link>
      <guid>https://dev.to/mitanshgor/rl-2-the-first-physical-and-computational-rl-machines1948-1954-1amh</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick recap, if you're just arriving:&lt;/strong&gt; Blog 1 showed that every core idea in reinforcement learning was discovered by someone watching animals, not computers. Thorndike's cats taught us that learning is selection, not insight. Pavlov's dogs taught us that a signal can carry information about the future. Skinner's pigeons taught us that big behaviors are built from small rewarded steps. Hebb's neurons taught us that learning lives in the strength of a connection.&lt;/p&gt;

&lt;p&gt;Four beautiful observations. Not one of them tells you how to &lt;em&gt;build&lt;/em&gt; something that does this.&lt;/p&gt;

&lt;p&gt;This is the decade where people tried to build it anyway. What followed was ten years of beautiful, clunky, brilliant hardware — machines that stumbled through mazes, adjusted their own wiring, and learned, in the most primitive sense, from their mistakes. None of the people building them knew they were inventing Reinforcement Learning. They were just trying to make something move on its own.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Missing Link: Why "a signal predicts the future" Needed a Number
&lt;/h2&gt;

&lt;p&gt;Before we jump to the machines, one 20-second detour — because it's the cleanest bridge between Blog 1 and everything below.&lt;/p&gt;

&lt;p&gt;Pavlov noticed his dogs salivated at footsteps, before food even showed up. Nice story. But it doesn't tell you &lt;em&gt;how much&lt;/em&gt; the dog should update its expectation each time, or why the association eventually stops getting stronger.&lt;/p&gt;

&lt;p&gt;Decades later — 1972, well after everything in this post — psychologists Robert Rescorla and Allan Wagner finally wrote that down as a formula:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mord mathnormal"&gt;β&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In plain words: &lt;em&gt;how much you learn from an event equals how surprising it was.&lt;/em&gt; &lt;code&gt;V&lt;/code&gt; is what you currently expect, &lt;code&gt;λ&lt;/code&gt; is what actually happened, and &lt;code&gt;(λ - V)&lt;/code&gt; is the surprise — the gap between prediction and reality. If a bell always predicts food, eventually there's no surprise left, and no more learning happens. That gap term is the whole engine.&lt;/p&gt;

&lt;p&gt;Why mention a 1972 psychology paper in a post about 1948–1954 engineering? Because the people you're about to meet — Wiener, Turing, Minsky, Shannon — independently backed into the exact same idea from a completely different direction: &lt;em&gt;engineering&lt;/em&gt;, not biology. None of them had read Pavlov's fine print. They just kept discovering, on their own, that intelligence seems to boil down to measuring a gap and closing it. Keep that gap-closing idea in your head — it's the thread connecting every section below.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cybernetic Spark: Wiener's Feedback Loops (1948)
&lt;/h2&gt;

&lt;p&gt;In 1948, mathematician Norbert Wiener published &lt;em&gt;Cybernetics: Or Control and Communication in the Animal and the Machine&lt;/em&gt;, and made a claim that was radical for its time: the same mathematical principle governs both living organisms and machines — &lt;strong&gt;negative feedback&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbuzb0pe19qif6xzu7na.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbuzb0pe19qif6xzu7na.png" alt="Norbert Wiener" width="360" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Forget dogs and food for a second. Think of a thermostat. It doesn't "know" temperature in any deep sense — it just tracks one number obsessively: the gap between where it is and where it's supposed to be.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Where &lt;code&gt;T&lt;/code&gt; is the target state and &lt;code&gt;S&lt;/code&gt; is the current state. If &lt;code&gt;D ≠ 0&lt;/code&gt;, the system fires a correction to close the gap. That's it. That's the whole idea.&lt;/p&gt;

&lt;p&gt;This is exactly the Rescorla-Wagner gap from above, just wearing an engineer's clothes instead of a psychologist's. &lt;code&gt;D&lt;/code&gt; here is the direct ancestor of the &lt;strong&gt;Temporal Difference (TD) error&lt;/strong&gt; you'll see in modern RL — the signal that tells an agent "something's off, adjust." Every gradient update in every deep RL system running today is, underneath the math, a Wiener-style error minimization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsiow833y4mu41qyc87l9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsiow833y4mu41qyc87l9.png" alt="thermostat vs organism comparison" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Wiener's punchline:&lt;/strong&gt; Intelligence isn't magic. It's error minimization on a loop. If you can define a goal and measure your distance from it, a machine can "learn" to close that distance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvq6yd134hkpydroyxd6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvq6yd134hkpydroyxd6.png" alt="Cybernetics Diagram" width="768" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So Wiener gave the field a &lt;em&gt;drive&lt;/em&gt; — a reason to move, a number to chase to zero. But a drive isn't a mechanism. It doesn't tell you what happens inside the machine when it's wrong versus when it's right. That's exactly what Alan Turing was working out, in the very same year, from a completely different angle.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Turing Blueprint: Pain, Pleasure, and the First Neural Network on Paper (1948)
&lt;/h2&gt;

&lt;p&gt;Turing's 1948 paper &lt;em&gt;Intelligent Machinery&lt;/em&gt; introduced the &lt;strong&gt;P-type (Pain-type) Unorganized Machine&lt;/strong&gt;, and reading it today feels like finding the first design document for a neural network, forty years too early.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbcg2qdg8dv83jnwnck8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbcg2qdg8dv83jnwnck8.png" alt="Alan Turing" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Turing's argument was blunt: a human infant's cortex is mostly a random, disorganized network that only becomes useful through experience. So why not build the machine equivalent? He proposed a network built from &lt;strong&gt;NAND gates&lt;/strong&gt; — think of these as the smallest possible decision units, each taking two inputs and spitting out one output based on a simple rule. Each gate could sit in one of two internal "configuration states," and that state is what determined how the gate behaved.&lt;/p&gt;

&lt;p&gt;The learning happened through two signals, and this is the part that matters:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pain&lt;/strong&gt; — when the machine got something wrong, the gates that had just fired got scrambled at random:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathit mtight"&gt;next&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathit"&gt;RandomSample&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Pleasure&lt;/strong&gt; — when the machine got something right, those same configurations froze in place. No more random reshuffling:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;Pleasure&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;So: wrong answer, shake things up. Right answer, lock it in. It's almost embarrassingly simple — which is exactly why it's important.&lt;/p&gt;

&lt;p&gt;Turing also spotted the obvious problem immediately: pure random shuffling doesn't scale. If a machine has &lt;code&gt;n&lt;/code&gt; units, each with &lt;code&gt;k&lt;/code&gt; possible states, the number of configurations to search through is &lt;code&gt;k^n&lt;/code&gt; — a number that explodes into uselessness almost immediately, even for tiny machines.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F01nodr2ttwo9rz0ys009.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F01nodr2ttwo9rz0ys009.png" alt="search space explosion" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;His fix: bring in a &lt;strong&gt;teacher&lt;/strong&gt;. Instead of letting the machine flail randomly forever, a teacher hands out Pleasure signals early to nudge it toward useful sub-behaviors, and &lt;em&gt;then&lt;/em&gt; Pain prunes away the remaining mistakes. That's not just a clever patch — it's the seed of &lt;strong&gt;Supervised Fine-Tuning (SFT)&lt;/strong&gt; and &lt;strong&gt;Imitation Learning&lt;/strong&gt;, ideas that wouldn't get their modern names for another fifty-plus years. Turing had quietly moved the burden of "being smart" off the programmer's shoulders and onto the environment's.&lt;/p&gt;

&lt;p&gt;His paper sat mostly unread for decades. But look at the shape of it: a randomly wired network, shaped over time by reward and punishment, converging on useful behavior. Every RLHF pipeline running behind a modern chatbot is, structurally, still running Turing's 1948 loop.&lt;/p&gt;

&lt;p&gt;Wiener gave us the &lt;em&gt;why&lt;/em&gt; — close the gap. Turing gave us the &lt;em&gt;what happens inside&lt;/em&gt; — freeze on success, scramble on failure. What nobody had shown yet was a machine that could do this outside of a chalkboard, with actual physical parts that changed themselves. That's where Marvin Minsky comes in.&lt;/p&gt;




&lt;h2&gt;
  
  
  Minsky's SNARC: The First Machine That Rewired Itself (1951–1954)
&lt;/h2&gt;

&lt;p&gt;While Turing's ideas stayed on paper, Marvin Minsky and his Princeton colleague Dean Edmonds went to the workshop and actually built something.&lt;/p&gt;

&lt;p&gt;In 1951, they built the &lt;strong&gt;SNARC — Stochastic Neural Analog Reinforcement Calculator&lt;/strong&gt; — the first machine to physically implement Hebbian learning (remember Blog 1: neurons that fire together, wire together) combined with reinforcement, in real hardware. Minsky later wrote it up in his 1954 thesis.&lt;/p&gt;

&lt;p&gt;The SNARC simulated a rat finding its way through a maze using &lt;strong&gt;40 artificial synapses&lt;/strong&gt;. Each "synapse" was a vacuum tube paired with a &lt;strong&gt;potentiometer&lt;/strong&gt; — picture a volume knob, a simple dial that changes how much resistance flows through a circuit. That dial's position &lt;em&gt;was&lt;/em&gt; the connection's strength, standing in for what we'd now call a "weight."&lt;/p&gt;

&lt;p&gt;Here's the learning loop, in plain terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A signal representing the "rat" travels through the network, picking a path.&lt;/li&gt;
&lt;li&gt;If that path leads to reward, the potentiometers ("volume knobs") along that path get turned to &lt;em&gt;lower&lt;/em&gt; resistance — meaning that path becomes electrically easier to travel next time.&lt;/li&gt;
&lt;li&gt;If the path leads nowhere, those knobs stay put or drift the other way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuydwodumc7cadtgqsmlh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuydwodumc7cadtgqsmlh.png" alt="mouse" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice what's happening here: this is &lt;strong&gt;credit assignment&lt;/strong&gt;, done with actual electricity. The machine had no rule anywhere that said "this specific connection caused the reward." It used the reward signal traveling backward through whichever path was active to figure out which knobs to turn. That's structurally the same job that backpropagation does in a modern neural network — just with copper and vacuum tubes instead of calculus.&lt;/p&gt;

&lt;p&gt;The SNARC couldn't scale — 40 synapses is barely a network by today's standards, and analog parts drift and degrade over time. But it proved something that had never been physically shown before: &lt;strong&gt;a machine can change its own internal wiring in response to reward, with no one programming the change directly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That single idea — connections that adjust themselves because of reward — is the founding premise of every neural network trained with RL today.&lt;/p&gt;

&lt;p&gt;So now we've got a drive (Wiener), a mechanism (Turing), and proof that self-adjusting hardware works (Minsky). One year later, Claude Shannon showed what happens when you point that same idea at something a person can actually watch move.&lt;/p&gt;




&lt;h2&gt;
  
  
  Claude Shannon's Theseus: Learning You Can See (1952)
&lt;/h2&gt;

&lt;p&gt;Shannon's contribution was the most tangible of the whole decade. In 1952, he built &lt;strong&gt;Theseus&lt;/strong&gt; — a copper mouse that could navigate a 5×5 maze, controlled by a cabinet of 75 telephone relays sitting underneath.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpu0uxf58s9y1oodpsvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpu0uxf58s9y1oodpsvk.png" alt="Claude Shannon" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the trick: the mouse itself had no brain. The relays — think of a relay as a mechanical switch that can remember whether it's "on" or "off" — &lt;em&gt;were&lt;/em&gt; the brain. Each of the 25 cells in the maze corresponded to a relay setup that remembered which directions had already failed from that spot. Hit a wall, and the relay for that direction-at-that-position flipped off, so the mouse tried something else next time. Find a working path, and those relay settings locked in for good.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6m57s6tvpgxnkl40yipq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6m57s6tvpgxnkl40yipq.png" alt="Shannon Maze Environment" width="729" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The payoff: drop Theseus anywhere in a maze it had already solved, and it walked straight to the goal, no hesitation. Drop it somewhere new, and it explored from scratch — then remembered &lt;em&gt;that&lt;/em&gt; too.&lt;/p&gt;

&lt;p&gt;What Shannon had actually built was a physical &lt;strong&gt;lookup table&lt;/strong&gt;: a direct map from state (position in the maze) to action (which way to go), stored as the mechanical position of 75 relays. This is the hardware great-grandparent of what's now called a Q-table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvty8q58nbk0v391cspa7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvty8q58nbk0v391cspa7.png" alt="relay vs plain qtable" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But the genuinely clever part was the &lt;strong&gt;"anti-neurotic" circuit&lt;/strong&gt;. Shannon noticed that a strategy based purely on "eliminate what failed" could trap the mouse in an infinite loop — try North, fail, try East, fail, loop back to North forever, repeat. His fix: a circuit that detected this looping behavior and injected a random direction change to break it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nvbe3da87tqi3yegh7f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nvbe3da87tqi3yegh7f.png" alt="break loop" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is, as far as anyone can tell, the first deliberate hardware solution to &lt;strong&gt;exploration vs. exploitation&lt;/strong&gt; — the tension that sits at the center of nearly every RL algorithm ever written. In plain terms: should the mouse keep using the move it already knows works (&lt;em&gt;exploit&lt;/em&gt;), or try something new in case there's a better option (&lt;em&gt;explore&lt;/em&gt;)? Shannon's answer was a random kick when stuck. Modern RL answers with names like epsilon-greedy (occasionally pick a random action on purpose) or entropy bonuses (reward the agent slightly for staying unpredictable). Same problem, seventy years of better tools.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Theseus proved something important: "learning" could be reduced entirely to hardware state changes. No probability distributions, no gradients — just relays flipping. Intelligence as a lookup table.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frg4gtpm2i20cio1ns4rh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frg4gtpm2i20cio1ns4rh.png" alt="hitting walls, then the " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bridge (1954–1957): From Wires to Equations
&lt;/h2&gt;

&lt;p&gt;By the mid-1950s, the hardware approach was hitting a wall. Shannon's mouse could solve one specific maze. Minsky's SNARC topped out at 40 synapses. Turing's ideas mostly lived on paper. Every one of these machines was an impressive, custom-built solution to one specific problem — and none of them generalized.&lt;/p&gt;

&lt;p&gt;Richard Bellman, among others, got impatient with that. Building a maze-solving mouse was a great parlor trick, but it wasn't a &lt;em&gt;theory&lt;/em&gt;. What he wanted was a general rule — something that could handle any problem made of a long chain of decisions, no matter what the environment looked like underneath.&lt;/p&gt;

&lt;p&gt;The question shifted from &lt;em&gt;"can we make this specific thing work?"&lt;/em&gt; to &lt;em&gt;"can we prove the mathematically best way to act, in general?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Bellman's answer became the &lt;strong&gt;Principle of Optimality&lt;/strong&gt; and the &lt;strong&gt;Bellman Equation&lt;/strong&gt;: the idea that the value of being in a state is just the immediate reward, plus the (slightly discounted) value of wherever you end up next. He took the mechanical "vibes" of the SNARC and Theseus and translated them into a single recursive formula — one equation that compresses an agent's entire future into a present-tense number.&lt;/p&gt;

&lt;p&gt;That equation, and the computational nightmare it revealed (Bellman's own term for it: the &lt;strong&gt;Curse of Dimensionality&lt;/strong&gt;), is where Blog 3 picks up. For now, the point is simpler: after a decade of wiring things together by hand, the field realized it needed math to go any further.&lt;/p&gt;

&lt;p&gt;The wires were beautiful. But equations scale.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Decade in One Frame
&lt;/h2&gt;

&lt;p&gt;Zooming out, here's what this era actually built — not a summary, a thesis:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wiener (1948)&lt;/strong&gt; gave learning a &lt;em&gt;drive&lt;/em&gt;: minimize the gap on a feedback loop.&lt;br&gt;
&lt;strong&gt;Turing (1948)&lt;/strong&gt; gave learning a &lt;em&gt;mechanism&lt;/em&gt;: reward freezes, punishment randomizes.&lt;br&gt;
&lt;strong&gt;Minsky (1951/54)&lt;/strong&gt; gave learning &lt;em&gt;physical weight&lt;/em&gt;: the first adjustable synapses that existed as hardware, not theory.&lt;br&gt;
&lt;strong&gt;Shannon (1952)&lt;/strong&gt; gave learning &lt;em&gt;memory&lt;/em&gt;: state-action mappings stored in the physical position of relays.&lt;br&gt;
&lt;strong&gt;Bellman (1957)&lt;/strong&gt; gave learning &lt;em&gt;math&lt;/em&gt;: a recursive formula that would eventually unify everything above it — that's Blog 3.&lt;/p&gt;

&lt;p&gt;In under a decade, "learning" went from a biological observation about cats and pigeons to a wired, probabilistic, physically real process you could point to on a workbench. The machines were small, fragile, and each one could only do exactly one thing. But the ideas inside them were load-bearing — every one of them is still holding up the RL systems built today.&lt;/p&gt;

</description>
      <category>rl</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>RL 1: Biological foundations and the "Law of Effect" (1898– 1949)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Wed, 02 Sep 2026 22:58:37 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-1-biological-foundations-and-the-law-of-effect-1898-1949-1a9f</link>
      <guid>https://dev.to/mitanshgor/rl-1-biological-foundations-and-the-law-of-effect-1898-1949-1a9f</guid>
      <description>&lt;p&gt;Before GPUs. Before neural networks. Before transistors were even a rumor.&lt;/p&gt;

&lt;p&gt;There was a hungry cat in a wooden crate, trying to get to a piece of fish.&lt;/p&gt;

&lt;p&gt;The main character of this era isn't an engineer. It's a loose group of psychologists — some of whom actively disliked each other's ideas — poking at animals to answer one question: &lt;em&gt;why do living things do the things they do?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;They never wrote a line of code. They were not trying to build AI. And yet, in the fifty years between 1898 and 1949, they collectively reverse-engineered the core loop that every modern reinforcement learning system still runs on.&lt;/p&gt;

&lt;p&gt;This post is that story. No math yet — I promise. Just the loop, and the four people who found its pieces.&lt;/p&gt;




&lt;h2&gt;
  
  
  First, the thing we're building
&lt;/h2&gt;

&lt;p&gt;Let me give you the shape of the answer before the story, so you know what you're collecting.&lt;/p&gt;

&lt;p&gt;Reinforcement learning describes any system that learns by &lt;strong&gt;doing stuff and seeing what happens.&lt;/strong&gt; That's it. Not by being shown correct answers — by trying, failing, and adjusting.&lt;/p&gt;

&lt;p&gt;We'll call the learner the &lt;strong&gt;agent&lt;/strong&gt; (the cat, the rat, the robot, the model). Everything outside it is the &lt;strong&gt;environment&lt;/strong&gt; (the box, the room, the game). The loop runs like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbm95lgy9r5kbc7tyi1fg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbm95lgy9r5kbc7tyi1fg.png" alt="RL" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent observes its &lt;strong&gt;state&lt;/strong&gt; — the situation it's currently in.&lt;/li&gt;
&lt;li&gt;It picks an &lt;strong&gt;action.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The environment responds with a &lt;strong&gt;reward&lt;/strong&gt; — a number saying "that was good" or "that was bad."&lt;/li&gt;
&lt;li&gt;The agent lands in a new state, and the loop repeats.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two more, and they're the ones that do the heavy lifting later.&lt;/p&gt;

&lt;p&gt;The agent needs a &lt;strong&gt;policy&lt;/strong&gt;: a strategy for choosing actions. Not a fixed script — a rule of thumb that says &lt;em&gt;in this kind of situation, do this kind of thing.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And it needs a sense of &lt;strong&gt;value&lt;/strong&gt;: how good a state is, based not on the reward sitting in it right now, but on everything it tends to lead to. An empty hallway is worth nothing on its own. An empty hallway &lt;em&gt;with the kitchen at the end of it&lt;/em&gt; is worth quite a lot.&lt;/p&gt;

&lt;p&gt;Six words: &lt;strong&gt;agent, state, action, reward, policy, value.&lt;/strong&gt; Every single one of them was discovered by someone studying animals, decades before anyone could program a computer.&lt;/p&gt;

&lt;p&gt;Let's go get them.&lt;/p&gt;




&lt;h2&gt;
  
  
  1898 — Thorndike's Cats and the Law of Effect
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flm8xra1vrxrrankczn0l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flm8xra1vrxrrankczn0l.png" alt="Edward Thorndike" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 1898, a graduate student named Edward Thorndike was annoyed.&lt;/p&gt;

&lt;p&gt;The animal literature of his day was full of charming anecdotes — dogs who &lt;em&gt;understood&lt;/em&gt; latches, cats who &lt;em&gt;figured out&lt;/em&gt; doorknobs. Thorndike's suspicion was that people were flattering their pets. Animals weren't reasoning. They were doing something else, and nobody had bothered to measure it.&lt;/p&gt;

&lt;p&gt;So he built the &lt;a href="https://www.appstate.edu/~steelekm/classes/psy5300/Documents/chance-72-433.pdf" rel="noopener noreferrer"&gt;puzzle box&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The setup is almost comically simple. A hungry cat goes in a small wooden crate. The door opens only if the cat pulls a loop of string, or presses a lever, or steps on a pedal. A piece of fish sits outside, in plain view. Then Thorndike started a stopwatch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa8weof0r3zhvb75exe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa8weof0r3zhvb75exe7.png" alt="Thorndike's puzzle box environment" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trial one is chaos.&lt;/strong&gt; The cat claws the bars. It shoves its paws through every gap. It bites things, yowls, thrashes at anything loose. After a few minutes of pure flailing, it hits the lever &lt;em&gt;by accident.&lt;/em&gt; The door swings open. Fish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trial two:&lt;/strong&gt; slightly less flailing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trial twenty:&lt;/strong&gt; the cat walks in, hits the lever, and strolls out.&lt;/p&gt;

&lt;p&gt;Here's what Thorndike noticed, and it's the part that matters: &lt;strong&gt;there was never a lightbulb moment.&lt;/strong&gt; No trial where the cat suddenly &lt;em&gt;got it.&lt;/em&gt; If cats were reasoning about levers, you'd expect the escape time to fall off a cliff — one long trial, then instantly fast ones. Instead, when he plotted escape time against trial number, he got a slow, noisy, gradual curve. The useless behaviors quietly faded. The useful one got faster.&lt;/p&gt;

&lt;p&gt;That curve is the first real evidence in this story. Learning wasn't insight. It was &lt;strong&gt;selection&lt;/strong&gt; — good behaviors surviving, bad ones dying off.&lt;/p&gt;

&lt;p&gt;Thorndike wrote it up as the &lt;strong&gt;Law of Effect&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If an action is followed by a satisfying state of affairs, the bond between that situation and that action is strengthened. If followed by discomfort, it is weakened.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Read that again with our vocabulary. &lt;em&gt;Situation&lt;/em&gt; is the &lt;strong&gt;state&lt;/strong&gt;. &lt;em&gt;Action&lt;/em&gt; is the &lt;strong&gt;action&lt;/strong&gt;. &lt;em&gt;Satisfying&lt;/em&gt; is the &lt;strong&gt;reward&lt;/strong&gt;. &lt;em&gt;Bond strengthened&lt;/em&gt; is the &lt;strong&gt;policy update&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Thorndike, in 1898, wrote pseudocode for a policy gradient. He just used the word "bond."&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; trial-and-error learning. Rewards make actions more likely. Learning is gradual, not sudden.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  But something's missing
&lt;/h3&gt;

&lt;p&gt;Thorndike's cat only learns &lt;em&gt;after&lt;/em&gt; it gets the fish. The reward does all the teaching.&lt;/p&gt;

&lt;p&gt;But watch a real animal for five minutes and you'll notice it reacting to things that aren't rewards at all. Your dog loses its mind at the sound of a cupboard opening. Nothing has been eaten yet. The cupboard &lt;em&gt;predicts&lt;/em&gt; food.&lt;/p&gt;

&lt;p&gt;Thorndike had no account of that. Rewards were where his story started and ended.&lt;/p&gt;

&lt;p&gt;The person who noticed the signal was, characteristically, not looking for it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 1900s–1920s — Pavlov and the Problem of Prediction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxrb3lotitr11lo46umfx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxrb3lotitr11lo46umfx.png" alt="Ivan Pavlov" width="800" height="1019"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ivan Pavlov was a Russian physiologist studying digestion. He won a Nobel Prize for it in 1904. He was, by most accounts, mildly irritated that history remembers him for the dogs.&lt;/p&gt;

&lt;p&gt;His actual research required measuring saliva. And his dogs kept ruining the measurements by salivating &lt;strong&gt;early&lt;/strong&gt; — at the sight of the lab assistant who usually brought food, at the sound of footsteps in the corridor. Before any food existed.&lt;/p&gt;

&lt;p&gt;Most researchers would call that noise and try to control for it. Pavlov called it the experiment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9me8tgsxmv8vn7qrwgf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9me8tgsxmv8vn7qrwgf1.png" alt="Pavlov's dog experiment" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;He ran it systematically. Present a neutral signal — a metronome, a buzzer, a light, a tone — then deliver food, a second or two later. Repeat.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Quick myth-correction, since it costs one sentence: the famous bell is mostly folklore. Pavlov's lab notes lean heavily on metronomes, buzzers, and tuning forks. The bell survived because it's easier to draw.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After enough pairings, the signal alone made the dogs salivate. Nothing about the food had changed. What changed was that the dog had learned &lt;strong&gt;the signal carries information about the future.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the second piece, and it's a big one. Thorndike's cat learned &lt;em&gt;what to do.&lt;/em&gt; Pavlov's dog learned &lt;em&gt;what's coming.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In RL terms, that's &lt;strong&gt;value&lt;/strong&gt;. The value of a state is roughly: &lt;em&gt;how much good stuff do I expect from here on out?&lt;/em&gt; A metronome that reliably precedes food is a high-value state — not because a metronome is nutritious, but because of what tends to follow it.&lt;/p&gt;

&lt;p&gt;You do this constantly. The smell of coffee is not caffeine. Your inbox badge is not the email. A green light is not arriving anywhere. Every one of these is a state you've assigned value to, purely because of what historically came next.&lt;/p&gt;

&lt;p&gt;And this is why RL agents can learn anything at all in sparse environments. A chess engine that only felt reward at checkmate would learn approximately nothing — the signal is 60 moves away from most of the decisions that caused it. What it actually learns is to value &lt;em&gt;positions&lt;/em&gt;: this pawn structure tends to precede winning. That's a metronome.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; states have value. Value comes from &lt;em&gt;prediction&lt;/em&gt;, not from the reward itself.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  But something's still missing
&lt;/h3&gt;

&lt;p&gt;Pavlov's dogs were passive. They sat in a harness and predicted. The dog's salivation doesn't make the food arrive any sooner.&lt;/p&gt;

&lt;p&gt;So now we have two halves of an agent and no glue:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Thorndike's cat&lt;/th&gt;
&lt;th&gt;Pavlov's dog&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Learns&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;which actions pay off&lt;/td&gt;
&lt;td&gt;which signals predict payoff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Can it act?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Can it anticipate?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A real agent needs both — and it needs someone to make this a controllable science rather than a collection of observations. That took a genuine control freak.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 1930s–50s — Skinner Turns Behavior Into Engineering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwal2v9jj5pw68zrj5oa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwal2v9jj5pw68zrj5oa.png" alt="B.F. Skinner" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;B.F. Skinner's question was different from everyone before him. Not "how do animals learn?" but: &lt;strong&gt;"how precisely can I control what an animal learns?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;His tool was the operant conditioning chamber — the Skinner Box. A rat inside can press a bar. A pigeon can peck a disc. Food is dispensed on rules Skinner sets. Simple inputs, measurable outputs, and — critically — the animal &lt;em&gt;stays in the box.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oszf4z6acztkuf32c73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oszf4z6acztkuf32c73.png" alt="Rat in a Skinner box" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That last detail seems minor and isn't. Thorndike's cats escaped, which meant one trial, then a reset by hand. Skinner's animals could run thousands of trials in an afternoon, uninterrupted. He'd built the first high-throughput training environment. Every RL researcher who has ever run a simulator overnight is doing the same thing.&lt;/p&gt;

&lt;p&gt;Two of his findings matter for us.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding 1: Unpredictable rewards are the stickiest
&lt;/h3&gt;

&lt;p&gt;Skinner varied &lt;em&gt;when&lt;/em&gt; reward arrived — every press, every fifth press, every fifth press &lt;em&gt;on average.&lt;/em&gt; These are &lt;strong&gt;schedules of reinforcement.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The counterintuitive result: &lt;strong&gt;variable&lt;/strong&gt; reward — where the animal can't predict which press pays — produced behavior that was hardest to extinguish. Reward a pigeon every single time, then stop, and it gives up quickly. Reward it unpredictably, then stop, and it keeps going for a remarkably long time.&lt;/p&gt;

&lt;p&gt;Slot machines run on this. So do infinite-scroll feeds. Skinner found the exploit in the 1950s; the attention economy just productized it.&lt;/p&gt;

&lt;p&gt;For us, the useful version is that reward &lt;em&gt;structure&lt;/em&gt; is a design decision with enormous consequences. Which sets up an entire genre of modern RL failure — agents that learn the reward signal instead of the task, in ways nobody intended. We'll spend real time there in a later post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding 2: You can build complex behavior out of crumbs
&lt;/h3&gt;

&lt;p&gt;The bigger idea is &lt;strong&gt;shaping.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Skinner taught pigeons to play a passable game of table tennis. Not by waiting for a pigeon to spontaneously play table tennis — you'd wait forever. He rewarded &lt;em&gt;incremental steps.&lt;/em&gt; First, reward the bird for merely facing the table. Once that's reliable, stop rewarding it and only pay for approaching the ball. Then only for contact. Then only for direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/shorts/RPJyKSmH9WM?feature=share" rel="noopener noreferrer"&gt;https://www.youtube.com/shorts/RPJyKSmH9WM?feature=share&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You are moving the goalposts on purpose, in small enough increments that the animal never falls off the curve.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;reward shaping&lt;/strong&gt;, and it's how we train robots today. A robot arm rewarded only for "successfully assembled the part" will flail randomly forever, because the odds of stumbling into success by accident are effectively zero. So we hand it crumbs: reward for moving toward the part, then for gripping it, then for lifting. Same ladder. Different species.&lt;/p&gt;

&lt;p&gt;And the strategy the animal ends up with — &lt;em&gt;in this situation, do this&lt;/em&gt; — is exactly what we called a &lt;strong&gt;policy&lt;/strong&gt; at the top of this post. Skinner spent thirty years training policies. He just did it with pigeons and a food dispenser instead of gradients and a GPU.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; policies can be &lt;em&gt;trained&lt;/em&gt;, not just observed. Reward timing and reward structure change everything.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  But something's still missing
&lt;/h3&gt;

&lt;p&gt;We now have a full behavioral picture: act, predict, get shaped, improve.&lt;/p&gt;

&lt;p&gt;Every bit of it is described from the outside. Skinner was deliberate about this — he treated the mind as a black box and argued you should only ever talk about observable behavior. Which is scientifically disciplined and completely useless if you want to &lt;em&gt;build&lt;/em&gt; one.&lt;/p&gt;

&lt;p&gt;Because if you're going to build this thing, you need to answer a question Skinner refused to ask: &lt;strong&gt;where does the learning physically live?&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1949 — Hebb Finds the Storage
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpq0oxiztlxp2o9uy8z1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpq0oxiztlxp2o9uy8z1.png" alt="Donald Hebb" width="491" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Donald Hebb, a Canadian psychologist, published &lt;em&gt;The Organization of Behavior&lt;/em&gt; in 1949 and proposed a mechanism so simple it fits in a sentence.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If neuron A repeatedly takes part in firing neuron B, some growth process or metabolic change takes place in both cells such that A's efficiency in firing B is increased.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's &lt;strong&gt;Hebb's Rule&lt;/strong&gt;, and the pop version is stickier: &lt;strong&gt;neurons that fire together, wire together.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ei581ewgfx0kd2zqhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ei581ewgfx0kd2zqhk.png" alt="Hebb's rule: neuron A firing neuron B" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two neurons active at the same time? The connection between them — the &lt;strong&gt;synapse&lt;/strong&gt; — physically strengthens. Next time, A triggers B more easily. Do it enough and the path becomes a highway.&lt;/p&gt;

&lt;p&gt;Run Thorndike's cat through this. The cat sees the lever (a pattern of neurons firing) and presses it (another pattern firing). They're active together. Their connection thickens. A hundred trials later, seeing the lever &lt;em&gt;is&lt;/em&gt; pressing the lever — there's a paved road between them.&lt;/p&gt;

&lt;p&gt;That's a habit, described in hardware.&lt;/p&gt;

&lt;p&gt;And this is where artificial neural networks come from. In a network, the connection strength between two artificial neurons is a number called a &lt;strong&gt;weight.&lt;/strong&gt; Learning means adjusting weights so that useful inputs reliably produce useful outputs. Hebb is the reason "learning = changing connection strengths" is the default assumption in the entire field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One important correction, because this gets flattened a lot:&lt;/strong&gt; Hebb's rule is &lt;em&gt;not&lt;/em&gt; backpropagation, and the difference is worth thirty seconds.&lt;/p&gt;

&lt;p&gt;Hebb's rule is &lt;strong&gt;local&lt;/strong&gt;. A synapse strengthens based only on what its own two neurons are doing right now. No supervisor, no error signal, nobody keeping score.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backpropagation&lt;/strong&gt; — the algorithm that actually trains modern networks — is &lt;strong&gt;global and error-driven&lt;/strong&gt;. It compares the network's output to a desired output, computes how wrong it was, and pushes that error signal backward through every layer, adjusting each weight by how much it contributed to the mistake. Every weight update depends on information from far away in the network.&lt;/p&gt;

&lt;p&gt;These are genuinely different mechanisms. In fact, the gap between them is one of the liveliest open arguments in neuroscience: brains clearly don't run backprop — there's no known biological machinery for shipping a precise error signal backward across a network — yet backprop works spectacularly well. Whether the brain approximates something like it, or does something else entirely, is unresolved.&lt;/p&gt;

&lt;p&gt;So the honest lineage is: &lt;strong&gt;Hebb gave us the idea that memory lives in connection strengths.&lt;/strong&gt; Backprop is a much later, mathematically-driven answer to &lt;em&gt;how to update&lt;/em&gt; those strengths. Same neighborhood, different building.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; learning is stored in connection weights. Local, physical, incremental.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Where that leaves us in 1949
&lt;/h2&gt;

&lt;p&gt;Fifty-one years, four researchers, and the loop is complete:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Idea&lt;/th&gt;
&lt;th&gt;From&lt;/th&gt;
&lt;th&gt;What it becomes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rewards strengthen the actions that earned them&lt;/td&gt;
&lt;td&gt;Thorndike, 1898&lt;/td&gt;
&lt;td&gt;the reward signal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Signals predict future reward&lt;/td&gt;
&lt;td&gt;Pavlov, 1900s&lt;/td&gt;
&lt;td&gt;value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Behavior can be sculpted step by step&lt;/td&gt;
&lt;td&gt;Skinner, 1930s–50s&lt;/td&gt;
&lt;td&gt;policies, reward shaping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learning is stored in connection strengths&lt;/td&gt;
&lt;td&gt;Hebb, 1949&lt;/td&gt;
&lt;td&gt;weights&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read that table top to bottom and you have a specification. Something that acts, predicts, gets shaped by consequences, and stores what it learned in the strength of its connections.&lt;/p&gt;

&lt;p&gt;Nobody had built it. Nobody could — the ideas were all written in the language of biology, describing wet tissue that nobody could manufacture.&lt;/p&gt;

&lt;p&gt;But 1949 is the year that stops being true. The war had just produced digital computers. A new field called &lt;strong&gt;cybernetics&lt;/strong&gt; was arguing that control and feedback worked the same way in animals and machines, and that the distinction was less fundamental than everyone assumed.&lt;/p&gt;

&lt;p&gt;For the first time, people had a spec for learning &lt;em&gt;and&lt;/em&gt; a machine to run it on.&lt;/p&gt;




&lt;h2&gt;
  
  
  One thing they all got wrong
&lt;/h2&gt;

&lt;p&gt;Before we leave the psychologists, here's the crack in the foundation — worth holding onto, because it takes another twenty years to fix.&lt;/p&gt;

&lt;p&gt;Every idea above says learning happens when things &lt;strong&gt;co-occur.&lt;/strong&gt; Metronome and food together → learn. Lever and fish together → learn. Neurons active together → wire together.&lt;/p&gt;

&lt;p&gt;But co-occurrence can't be the whole story:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your alarm has gone off at 7am every day for a year.&lt;/strong&gt; By the co-occurrence rule, this morning should have strengthened that association a little further, same as every other morning. It didn't. You learned it in the first week and then stopped — even though the pairing kept happening, perfectly, hundreds more times.&lt;/p&gt;

&lt;p&gt;So what switches learning &lt;em&gt;off&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Nobody in this post can answer that. The answer arrives in 1972, from a pair of psychologists still studying rats, and when it does it turns out to be the single most important equation in this entire series. We'll get there.&lt;/p&gt;




&lt;h2&gt;
  
  
  Next up
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;RL #2 — Cybernetics and Early Machines (1948–1954).&lt;/strong&gt; The first people to actually build this thing. Alan Turing sketching a "pleasure-pain system" in 1948. Claude Shannon's Theseus, a mechanical mouse that learned a maze by trial and error and could remember it. And Marvin Minsky wiring together the SNARC — 40 vacuum tubes, motors, and a clutch, arguably the first machine that learned by reinforcement.&lt;/p&gt;

&lt;p&gt;The cats gave us the algorithm. Now watch people try to solder it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you spot an error or think I've oversimplified something, drop it in the comments — I'd rather fix it than have it sit there.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>Reinforcement Learning Series</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Wed, 19 Aug 2026 18:40:39 +0000</pubDate>
      <link>https://dev.to/mitanshgor/reinforcement-learning-series-4m6j</link>
      <guid>https://dev.to/mitanshgor/reinforcement-learning-series-4m6j</guid>
      <description>&lt;p&gt;I created this series to make that steep learning curve far less daunting for you. My goal is to trace the evolution of RL chronologically—from its roots in early psychology and physical mechanical machines to digital binary systems and modern mathematical breakthroughs. By breaking down complex concepts with clear visual guides, graphics, and real-world analogies, I hope to demystify RL and give back to the community that inspired me. Let’s dive in!&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 1: The Psychological Seeds (1898–1949)
&lt;/h3&gt;

&lt;p&gt;This entry explores the &lt;strong&gt;Law of Effect&lt;/strong&gt; (1911), where Edward Thorndike established that actions followed by satisfaction are strengthened. It also covers Ivan Pavlov’s formal definition of &lt;strong&gt;reinforcement&lt;/strong&gt; (1927) and Donald Hebb’s 1949 hypothesis that "neurons that fire together, wire together," laying the groundwork for neural learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 2: Cybernetics and Early Machines (1948–1954)
&lt;/h3&gt;

&lt;p&gt;This blog details the first computational investigations, including &lt;strong&gt;Alan Turing’s&lt;/strong&gt; "pleasure-pain system" (1948) and Marvin Minsky’s construction of &lt;strong&gt;SNARCs&lt;/strong&gt; (1954), the first analog neural-network reinforcement calculators. It also highlights &lt;strong&gt;Claude Shannon’s&lt;/strong&gt; 1952 demonstration of "Theseus," a maze-running mouse that used trial and error to "remember" paths.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 3: The Mathematical Framework (1950s–1960s)
&lt;/h3&gt;

&lt;p&gt;This post focuses on &lt;strong&gt;Richard Bellman’s&lt;/strong&gt; development of &lt;strong&gt;Dynamic Programming&lt;/strong&gt; and the Bellman Equation (1957), which provided the formal tools for solving optimal control problems. It also introduces &lt;strong&gt;Markov Decision Processes (MDPs)&lt;/strong&gt; and Ron Howard’s &lt;strong&gt;policy iteration&lt;/strong&gt; method (1960), which are the bedrock of modern RL theory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 4: Early Heuristics and Checkers (1959–1968)
&lt;/h3&gt;

&lt;p&gt;This entry discusses &lt;strong&gt;Arthur Samuel’s&lt;/strong&gt; celebrated checkers program (1959), which was the first to implement &lt;strong&gt;temporal-difference (TD)&lt;/strong&gt; ideas by using board evaluation differences to modify earlier positions. It also details Donald Michie’s &lt;strong&gt;MENACE&lt;/strong&gt; (1961), a physical "matchbox" engine that learned to play Noughts and Crosses through reinforcement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 5: The Birth of Learning Automata (1961–1974)
&lt;/h3&gt;

&lt;p&gt;This blog examines the Soviet lineage of RL, specifically &lt;strong&gt;Mikhail Tsetlin’s&lt;/strong&gt; work on "learning automata" (1961), which were finite-state machines that updated action probabilities based on stochastic environmental feedback. It traces how this research was later systematised by Narendra and Thathachar in 1974.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 6: The "Hedonistic" Revival (1972–1980)
&lt;/h3&gt;

&lt;p&gt;This post covers &lt;strong&gt;Harry Klopf’s&lt;/strong&gt; pivotal role in reviving the trial-and-error thread by proposing the &lt;strong&gt;"hedonistic neuron"&lt;/strong&gt; (1972), which argued that neurons act as pleasure-seeking units. It also explores Paul Werbos’s 1974 thesis, which was the first to describe &lt;strong&gt;backpropagation&lt;/strong&gt; in the context of "Adaptive Dynamic Programming".&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 7: The Sutton and Barto Foundation (1981–1984)
&lt;/h3&gt;

&lt;p&gt;This blog highlights the formalisation of modern RL, beginning with &lt;strong&gt;Sutton and Barto’s&lt;/strong&gt; 1981 model of classical conditioning. It details the invention of the &lt;strong&gt;Actor-Critic architecture&lt;/strong&gt; (1983) and Sutton’s 1984 dissertation, which provided the first rigorous computational analysis of &lt;strong&gt;temporal credit assignment&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 8: The Q-Learning Breakthrough (1988–1994)
&lt;/h3&gt;

&lt;p&gt;This entry documents two watershed moments: &lt;strong&gt;Sutton’s&lt;/strong&gt; 1988 formalisation of TD learning and &lt;strong&gt;Chris Watkins’s&lt;/strong&gt; 1989 introduction of &lt;strong&gt;Q-Learning&lt;/strong&gt;, the first model-free, off-policy algorithm. It also covers the introduction of &lt;strong&gt;SARSA&lt;/strong&gt; (1994) as an on-policy alternative that prioritises training stability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 9: Superhuman Achievement in Games (1992–1999)
&lt;/h3&gt;

&lt;p&gt;This post details &lt;strong&gt;Gerald Tesauro’s TD-Gammon&lt;/strong&gt; (1992), which achieved grandmaster-level backgammon play using neural networks and self-play. It also covers the &lt;strong&gt;options framework&lt;/strong&gt; (1999) by Sutton, Precup, and Singh, which introduced temporal abstraction to help RL agents solve problems across different timescales.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 10: Theoretical Refinement (2000–2010)
&lt;/h3&gt;

&lt;p&gt;This entry explains the &lt;strong&gt;Policy Gradient Theorem&lt;/strong&gt; (2000), which proved that policy parameters could be optimised using only local information. It also introduces Sham Kakade’s &lt;strong&gt;Natural Policy Gradient&lt;/strong&gt; (2002), a precursor to modern trust-region methods that account for the geometry of parameter space.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 11: The Deep RL Revolution (2013–2015)
&lt;/h3&gt;

&lt;p&gt;This post chronicles the birth of &lt;strong&gt;Deep RL&lt;/strong&gt; with DeepMind’s &lt;strong&gt;DQN&lt;/strong&gt; (2013/2015), which used &lt;strong&gt;Experience Replay&lt;/strong&gt; and &lt;strong&gt;Target Networks&lt;/strong&gt; to master Atari games directly from pixels. It also details &lt;strong&gt;DDPG&lt;/strong&gt; (2015), which extended these successes to continuous action spaces like robotics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 12: Mastering Strategy and Control (2015–2017)
&lt;/h3&gt;

&lt;p&gt;This entry explores &lt;strong&gt;Trust Region Policy Optimization (TRPO)&lt;/strong&gt; (2015) and its simpler successor, &lt;strong&gt;Proximal Policy Optimization (PPO)&lt;/strong&gt; (2017), which became the industry standard for stable training. It also covers the historic victory of &lt;strong&gt;AlphaGo&lt;/strong&gt; over Lee Sedol in 2016.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 13: Integrated Mastery: Rainbow and MuZero (2017–2019)
&lt;/h3&gt;

&lt;p&gt;This post details the &lt;strong&gt;Rainbow&lt;/strong&gt; agent (2017), which combined seven independent DQN improvements into one "super-agent". It also highlights &lt;strong&gt;MuZero&lt;/strong&gt; (2019), which learned to master games like Go and Chess without even being told the rules of the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 14: Hard Exploration and Generalisation (2020–2022)
&lt;/h3&gt;

&lt;p&gt;This blog focuses on &lt;strong&gt;Agent57&lt;/strong&gt; (2020), the first agent to surpass the human benchmark on all 57 Atari games by solving "hard exploration" problems. It also covers &lt;strong&gt;Gato&lt;/strong&gt; (2022), a single transformer-based generalist agent capable of playing Atari, captioning images, and controlling robot arms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 15: The Transformer Pivot and LLM Alignment (2021–2023)
&lt;/h3&gt;

&lt;p&gt;This entry describes the &lt;strong&gt;Decision Transformer&lt;/strong&gt; (2021), which reframed RL as a sequence modeling problem, bypassing traditional bootstrapping. It also covers the rise of &lt;strong&gt;Reinforcement Learning from Human Feedback (RLHF)&lt;/strong&gt; with &lt;strong&gt;InstructGPT&lt;/strong&gt; and the subsequent development of &lt;strong&gt;Direct Preference Optimization (DPO)&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 16: Reasoning Models and Incentivized Thought (2024–2025)
&lt;/h3&gt;

&lt;p&gt;This blog explores &lt;strong&gt;DeepSeek Math&lt;/strong&gt; and &lt;strong&gt;GRPO&lt;/strong&gt; (2024), which removed the need for a separate critic model to improve mathematical reasoning. It details the breakthrough of &lt;strong&gt;DeepSeek-R1&lt;/strong&gt; (2024/2025), which proved that pure RL can spontaneously elicit self-correction and reflection in language models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 17: Massive Depth and the Future of Scaling (2025–2026)
&lt;/h3&gt;

&lt;p&gt;This final entry discusses the 2025 NeurIPS Best Paper on &lt;strong&gt;1,000-layer RL networks&lt;/strong&gt;, which broke the "shallow network" assumption to unlock 50x performance gains. It reflects on &lt;strong&gt;Kimi k1.5&lt;/strong&gt; and the role of the &lt;strong&gt;2024 Turing Award&lt;/strong&gt; in cementing RL as a foundational pillar of the AI revolution.&lt;/p&gt;

</description>
      <category>rl</category>
    </item>
    <item>
      <title>Personal Health Agent (PHA): Multi-Agent Health System</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 27 Nov 2025 05:33:43 +0000</pubDate>
      <link>https://dev.to/mitanshgor/personal-health-agent-pha-multi-agent-health-system-1i6l</link>
      <guid>https://dev.to/mitanshgor/personal-health-agent-pha-multi-agent-health-system-1i6l</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=cHYuEzxDJb4" rel="noopener noreferrer"&gt;VIDEO LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the last few years, we saw different types of AI systems try to answer this question:&lt;br&gt;
PH-LLM (2024) → focused on personalized coaching from wearable data.&lt;br&gt;
PHIA (2024) → acted like an agent that analyzes your data, writes code, and explains results.&lt;br&gt;
IR Prediction + IR Explainer Agent (2025) → estimated your metabolic risk and explained it like a doctor.&lt;/p&gt;

&lt;p&gt;All of these systems were important steps. But each one had a weakness:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A single LLM tries to do everything.&lt;/li&gt;
&lt;li&gt;It must read data, interpret medical meaning, check safety, and give advice.&lt;/li&gt;
&lt;li&gt;This often leads to confident hallucinations — answers that sound correct but are actually wrong.&lt;/li&gt;
&lt;li&gt;It also mixes medical reasoning with casual coaching, which creates risk. And one model cannot be an expert in every health domain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9314ab1b0c2ovlg8crme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9314ab1b0c2ovlg8crme.png" alt="banner" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the big idea behind the Personal Health Agent (PHA) is simple:&lt;/p&gt;

&lt;p&gt;Instead of one giant model doing everything, why not create multiple smaller agents — each with a role — working together like a mini health team?&lt;br&gt;
This solves the main problem with earlier systems: no single AI can fully handle the complexity of real human health. But a team of specialized agents can.&lt;/p&gt;

&lt;p&gt;Because health is multi-dimensional—where your sleep affects your stress, stress affects metabolic health, exercise influences sleep, and food and biomarkers impact everything—one AI model can’t realistically handle all of it at once. Just like a hospital relies on different specialists, a digital health system also needs different “roles”: one agent to interpret raw data, one agent to check medical safety, and one agent to translate insights into simple coaching. This is why multi-agent systems are becoming so important: they add structure, accountability, and more reliable reasoning, solving many of the issues earlier single-LLM systems struggled with.&lt;/p&gt;

&lt;h2&gt;
  
  
  A System of Specialized Agents
&lt;/h2&gt;

&lt;p&gt;When I look at the PHA system, what stands out first is the Analyst Agent. I think of this agent like a friend who loves numbers and graphs. Its whole job is to read my raw data — sleep hours, steps, heart rate, and other signals — and turn them into clear observations. It doesn’t try to coach me or act like a doctor. It just says, “Here’s what I see happening in your data,” which makes everything feel clean and easy to understand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy58om1b0a4jbjs6ocgvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy58om1b0a4jbjs6ocgvd.png" alt="dsAgent" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then there is the Domain Expert Agent, which to me is the “doctor brain” of the whole system. This agent takes what the Analyst found and checks if it makes medical sense. It worries about safety, accuracy, and whether the explanation aligns with real health science. I really like this part because it stops the system from giving random or misleading advice. It acts like the strict friend who always says, “Wait, is this actually correct?”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4rkm5lh1in07tfqpz67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4rkm5lh1in07tfqpz67.png" alt="domainExp" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next comes the Coach Agent, the most human-feeling part of PHA. This agent talks to me like a supportive friend who wants me to succeed. It takes all the technical pieces and translates them into simple, everyday advice I can act on. No medical jargon. No complicated charts. Just small, doable suggestions like, “Try walking after dinner” or “Aim for an earlier bedtime tonight.” It’s friendly and practical, which is exactly what people need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg315ncyax16diti30hvt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg315ncyax16diti30hvt.png" alt="healthcoach" width="799" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What ties everything together is how these agents work as a team. Instead of one giant AI trying to do everything — and often making confident mistakes — each agent stays in its own lane. One analyzes, one verifies, one coaches. Because of this teamwork, the final answer feels clearer, safer, and much more trustworthy. It’s almost like having a mini health team inside your phone, and that makes the whole system feel both smart and human at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Deep Dive
&lt;/h2&gt;

&lt;p&gt;Even though all agents may start from the same base LLM (like Gemini or GPT-class models), they are trained separately, so each one becomes good at one thing instead of being average at everything.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finetuning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Analyst Agent is finetuned from wearable logs (heart rate, steps, sleep), time-series patterns, data summaries, and statistical examples. It becomes good at reading numbers and spotting patterns.&lt;/li&gt;
&lt;li&gt;Domain Expert needs more serious data for finetuning, like medical guidelines, curated clinical examples, safe/unsafe reasoning samples, and explanations validated by experts. It learns how to avoid hallucinations and unsafe claims&lt;/li&gt;
&lt;li&gt;Coach Agent is the “human” one. It is finetuned on a friendly conversational dataset, lifestyle advice examples, behavior-change coaching patterns. It learns to talk in a simple, supportive way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxutm9nruja3q39zgfr6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxutm9nruja3q39zgfr6h.png" alt="data set" width="800" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This division is what makes the final system feel more stable than earlier systems like PHIA or the IR Agent, where a single LLM had to juggle all roles and often made confident mistakes.&lt;/p&gt;

&lt;p&gt;The process itself was simple but very intentional. Here’s how I imagine it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We first collected examples for each agent’s role.&lt;/li&gt;
&lt;li&gt;Then we cleaned and organized everything.&lt;/li&gt;
&lt;li&gt;Then we cleaned and organized everything.&lt;/li&gt;
&lt;li&gt;After that, we fine-tuned each agent separately.&lt;/li&gt;
&lt;li&gt;Then we tested the agents together.&lt;/li&gt;
&lt;li&gt;Finally, we fixed mistakes and improved the dataset.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  System architecture and Data Flow
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpizblec7crocjocrwah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpizblec7crocjocrwah.png" alt="system arch" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Underneath all of this, there’s a system architecture that makes their collaboration possible. I picture it like a small command center. The user’s data flows into a main controller, which decides which agent speaks first and who validates whom. The Analyst generates its interpretation, the Domain Expert checks it, and the Coach turns everything into a simple message. Each agent is isolated enough to stay focused, but interconnected enough to build on each other’s work. There’s also a safety layer running quietly in the background — something like a “medical guardrail” — to make sure the final output stays safe, consistent, and responsible before it reaches the user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Pipeline Flow
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;My raw data comes in (wearable data, blood test results, communication history)&lt;/li&gt;
&lt;li&gt;The system cleans and prepares the data.&lt;/li&gt;
&lt;li&gt;The Analyst Agent gets the cleaned data first, and it gives a report.&lt;/li&gt;
&lt;li&gt;The Expert Agent double-checks everything and makes sure the explanation is medically correct and safe.&lt;/li&gt;
&lt;li&gt;The Coach Agent gets the approved explanation and rewrites the message in simple, friendly language&lt;/li&gt;
&lt;li&gt;A final safety filter reviews the message and checks for risky things like any medical diagnosis, unsafe suggestions, and harmful claims.&lt;/li&gt;
&lt;li&gt;I receive the final output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspd5g9lkz788hjcvok15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspd5g9lkz788hjcvok15.png" alt="pipeline inference" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Inference time
&lt;/h3&gt;

&lt;p&gt;During inference — which is just a fancy word for “when the system actually responds to me” — the agents talk to each other almost like coworkers passing notes in a group chat. I don’t see any of this, but it’s happening behind the scenes. The Analyst looks at my raw data and says, “Here’s what I think is happening.” The Domain Expert looks at what the Analyst wrote and either approves it or corrects it. And finally, the Coach turns their combined reasoning into something that sounds human and helpful. What I receive as a single answer is actually the teamwork of multiple roles stitched together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools used
&lt;/h3&gt;

&lt;p&gt;To make all of this work, the system relies on a set of tools that help each agent extend its abilities. The Analyst might use data-processing tools to clean and summarize wearable data. The Domain Expert might have access to reference tools that help it compare findings against medical knowledge or validated guidelines. The Coach might use prompt templates designed for empathy, clarity, and motivation. And the main controller uses orchestration tools — something like LangGraph or a custom workflow engine — to decide who talks when and how information flows between them. These tools don’t replace the agents, but they give them structure, context, and external capabilities they wouldn’t have on their own.&lt;/p&gt;

&lt;h3&gt;
  
  
  Collection of data
&lt;/h3&gt;

&lt;p&gt;Everything starts with a real study they ran called &lt;strong&gt;WEAR-ME&lt;/strong&gt;, which included more than a thousand Fitbit users. People had to explicitly opt-in, sign digital consent, link their wearable device, and even go for a blood draw at a Quest Diagnostics center. So the data wasn’t scraped or assumed—it came from real people who agreed to share it for research. That part mattered to me because it made the whole system feel responsible, not rushed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozrz0zw4prfut4yef2yk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozrz0zw4prfut4yef2yk.png" alt="data1" width="799" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once someone joined the study, their data flowed through a very controlled pipeline.So each person had a mix of: (1) wearable time-series, (2) lab biomarkers, (3) self-reported history, (4) lifestyle questionnaires.&lt;/p&gt;

&lt;p&gt;What I liked is that the system doesn’t directly reach into a live Fitbit account or do anything “real-time.” Instead, the PHA gets access to summaries of the participant’s data, organized into tables—like a daily summary table, an activities table, and even a population-level reference table so the system could compare one user’s values against others in their age group. This gave context, not just raw numbers.&lt;/p&gt;

&lt;p&gt;Inside the actual agent pipeline, each sub-agent only receives the part of the data that’s relevant to its job. The system never dumps the full raw dataset into every agent. Instead, the orchestrator acts like a coordinator who hands the right information to the right specialist. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34ozz316vec63s0dh1mi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34ozz316vec63s0dh1mi.png" alt="data2" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing is fetched unless the user asks something that genuinely needs it. And the system also avoids asking the user for things it already knows—like their sleep hours or steps—because the orchestrator checks the available data first.&lt;/p&gt;

&lt;h2&gt;
  
  
  PHA vs Gemini Results
&lt;/h2&gt;

&lt;p&gt;PHA wasn’t just a small improvement. It was in a completely different league.&lt;/p&gt;

&lt;p&gt;From the end-user side, I noticed that people consistently picked PHA as the best experience. Not just once or twice — almost half the time. And this is after comparing it side-by-side against a single Gemini agent and a parallel multi-agent system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsqsilw9r4hl35m3n5xs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsqsilw9r4hl35m3n5xs.png" alt="enduser" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But the biggest eye-opener for me was the expert evaluation. Experts didn’t just prefer PHA — they almost abandoned the Gemini single-agent baseline. Only around 4–5% of expert rankings put Gemini in first place, while PHA was chosen as #1 about 80% of the time. That’s not a small margin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yxu0ccew7z9qmoo2mba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yxu0ccew7z9qmoo2mba.png" alt="expUser" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Strengths of the system
&lt;/h2&gt;

&lt;p&gt;What struck me most was how real the system felt. Not just in terms of architecture, but in how thoroughly it was tested. It wasn’t a small demo — it involved thousands of human annotations and hundreds of hours of expert evaluation. Because of that, the strengths and limitations felt very honest.&lt;/p&gt;

&lt;p&gt;One of the biggest strengths I noticed is how well the whole system comes together. The three-agent setup — the data scientist, the domain expert, and the coach — isn’t just theoretical. In the evaluations, PHA actually outperformed both a single-agent system and a parallel multi-agent system. End-users preferred talking to PHA almost half the time, and experts loved it even more, choosing it as the best system in about 80% of cases. To me, that says the collaboration between these agents isn’t just helpful — it genuinely changes the quality of the conversation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbzp9nzsn8e7xq9ytewz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbzp9nzsn8e7xq9ytewz.png" alt="daAdv" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data agent in particular felt like a major upgrade. It was much better at breaking down messy, vague health questions into proper statistical analyses, catching missing data, choosing the right timeframes, and generating correct code. I could see why the system became more trustworthy — it wasn’t guessing. It was reasoning over the user’s actual data. And the domain expert agent made a big difference too. It produced safer, more accurate, and more personalized medical explanations. Users rated its responses as far more trustworthy than the base model, and clinicians preferred its summaries because they were more complete and clinically meaningful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnr1mvix1o1lhgkrxff2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnr1mvix1o1lhgkrxff2f.png" alt="domainAdv" width="800" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The health coach agent also impressed me. It wasn’t just delivering motivational lines. It followed real coaching principles — active listening, SMART goals, motivational interviewing — and this made conversations feel more natural and supportive. Users were more engaged, and the conversations ended more naturally. It reminded me of talking to a real human coach who’s actually paying attention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpetug6re3d588sbi666a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpetug6re3d588sbi666a.png" alt="coachAdv" width="800" height="723"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a whole system, PHA feels more thoughtful. The orchestrator doesn’t just mix answers together — it understands the user’s goal, assigns the right agent, reflects on the output, and remembers important details for later turns. This gives the conversation a sense of direction and personalization that the baselines just didn’t have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations of the System
&lt;/h2&gt;

&lt;p&gt;But the system isn’t perfect. One thing that stood out immediately was the cost. PHA is slower and more computationally expensive because each request triggers multiple agents and reflection steps. Where the single-agent system might respond in around 35 seconds, PHA could take over 200. It’s powerful, but not cheap.&lt;/p&gt;

&lt;p&gt;Another limitation is that the diagnostic reasoning, while improved, is still not bulletproof. Sometimes the domain expert agent didn’t complete its reasoning chain, and its reliance on web search occasionally pulled in conflicting information. This reminded me that, even though it acts like a doctor in some ways, it’s not actually one — and the authors make that very clear.&lt;/p&gt;

&lt;p&gt;Bias is also a real concern. The system personalizes advice based on user traits, conditions, and context… which is great, but it also means it can unintentionally repeat patterns or assumptions from datasets that might not represent everyone equally. The paper calls out this risk directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq9spxcb92u8fqw3qlnw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq9spxcb92u8fqw3qlnw.png" alt="Limitations" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The coach agent, despite being strong overall, also had a weakness: it wasn’t great at tracking user progress over time. It did a good job helping set goals, but didn’t always follow up on them in later turns. For long-term coaching, that’s something they’ll need to improve.&lt;/p&gt;

&lt;p&gt;And finally — maybe the biggest limitation — everything was tested in short-term interactions. We don’t yet know whether PHA can support behavior change over weeks or months, which is where health coaching really matters. The team also notes that this is a research framework, not a clinical tool, and major regulatory work would be needed before deploying anything like this in the real world.&lt;/p&gt;

&lt;p&gt;So when I put it all together, here’s how I personally see it:&lt;br&gt;
PHA is a huge improvement over past systems — smarter, safer, more human, and more useful — but it’s still early. It has real strengths, but also real gaps. It’s powerful as an idea, promising as a system, and clearly built with care. But it also reminds me that great AI doesn’t replace medical care — it supports it, and it still has a lot of growing up to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;After reading the PHA paper, the biggest thing I realized is that this system isn’t just an AI answering health questions — it feels more like a small team working behind the scenes to help you make sense of your own data. The evaluations show that this multi-agent design really does lead to better, clearer, and more personalized guidance compared to older single-agent approaches.&lt;/p&gt;

&lt;p&gt;At the same time, the authors are very honest about their limits. The system can still make mistakes, it can be biased depending on the data, and it should never replace real medical care. It’s powerful, but it’s also early — more like a research blueprint than a ready product.&lt;/p&gt;

&lt;p&gt;To me, PHA represents a hopeful direction: AI that supports people in understanding their health, not by taking over, but by helping them make smarter choices with empathy, safety, and transparency in mind&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>health</category>
      <category>google</category>
    </item>
    <item>
      <title>PHIA: The Agentic LLM That Writes Code, Analyzes Your Data &amp; Explains Health Insights</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 27 Nov 2025 05:33:34 +0000</pubDate>
      <link>https://dev.to/mitanshgor/phia-the-agentic-llm-that-writes-code-analyzes-your-data-explains-health-insights-4g1a</link>
      <guid>https://dev.to/mitanshgor/phia-the-agentic-llm-that-writes-code-analyzes-your-data-explains-health-insights-4g1a</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=UR2MTLJ1d4E" rel="noopener noreferrer"&gt;VIDEO LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I honestly felt like I was looking at the “next version” of what health AI should be. Whenever I asked myself questions like, “Is my sleep improving?” or “Does exercising at night change my deep sleep?”, I realized how hard it is to answer these without real analysis.&lt;/p&gt;

&lt;p&gt;That is exactly the problem the PHIA team talks about on page 1 of the paper. They explain that even a simple question like “Do I sleep better after exercising?” requires many steps: checking recent data, comparing different days, calculating metrics, and then interpreting everything in the context of what “healthy” even means. And honestly, I could relate — that’s the kind of analysis I never do on my own.&lt;br&gt;
What really caught my attention is that the paper says today’s LLMs struggle with numerical reasoning, meaning they often miscalculate or oversimplify things. I’ve definitely seen models do that — giving a confident answer but completely messing up basic math. (Limitation of PH-LLM)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijr3r0wiwgfamfnpd0dv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijr3r0wiwgfamfnpd0dv.png" alt="int" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So PHIA tries to fix this problem by giving an LLM the ability to plan, use tools, write code, and search the web. It doesn’t just “chat.” It becomes more like a small data analyst that works with your wearable data step-by-step.&lt;/p&gt;

&lt;h2&gt;
  
  
  PH-LLM vs PHIA
&lt;/h2&gt;

&lt;p&gt;PH-LLM was an earlier coaching system that worked only with simple, pre-aggregated 30-day summaries and relied purely on the LLM’s internal reasoning. That meant it couldn’t actually analyze detailed daily wearable data, couldn’t run calculations, and completely failed on questions that required numbers or step-by-step reasoning. PHIA addresses these limitations by granting the LLM three new capabilities: (1) it can generate authentic Python code to analyze raw wearable data, (2) it can plan and break down tasks using an agent loop, and it can search the web to incorporate fresh, verified health knowledge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8xekitn7246fd5p1e9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8xekitn7246fd5p1e9k.png" alt="difference" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because of this, PHIA shifts from being “just a health coach” to becoming a true data analyst + coach, delivering insights that are more accurate, personalized, and grounded in both the user’s data and real health science. PHIA feels like the bridge between “AI as a friendly coach” and “AI as a personal data scientist.” By mixing reasoning, code execution, and web search, it finally unlocks the kind of deeper, more accurate insights that wearables have always had the potential to provide.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqkihmir6plcn25xlyp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqkihmir6plcn25xlyp4.png" alt="diff" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How PHIA Works
&lt;/h2&gt;

&lt;p&gt;PHIA more like a mini health data analyst that can think step-by-step, write code, check your wearable data, search the web, and then explain everything in normal language. The PHIA paper shows this clearly — PHIA literally cycles through think → act → observe just like a human analyst would.&lt;/p&gt;

&lt;p&gt;I’ll explain this in the simple way I understood it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9fqs7m9hl4jtzdwrc61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9fqs7m9hl4jtzdwrc61.png" alt="ReAct" width="799" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of guessing answers, PHIA acts more like a small data analyst that plans its steps, checks your wearable data, and only then explains what it found. The paper describes this using the ReAct loop— &lt;strong&gt;Thought → Action → Observation&lt;/strong&gt; — and seeing it in action helped me understand why PHIA is so different.&lt;/p&gt;

&lt;p&gt;PHIA starts by thinking through the question. If I ask something like “Is my resting heart rate improving?”, it doesn’t jump to a quick reply. It pauses and decides what it needs—maybe comparing two weeks of data or calculating averages. Then, PHIA takes action by writing and running Python code in a safe &lt;strong&gt;virtual environment tool&lt;/strong&gt;. This lets it analyze real daily time-series data using Pandas, just like a real data scientist. The nice part is that this removes mathematical mistakes that normal LLMs often make. And if its code crashes, PHIA actually fixes the error and tries again (&lt;u&gt;recurrent trials system&lt;/u&gt;), which the paper highlights as one of its strengths.&lt;/p&gt;

&lt;p&gt;In their evaluation, PHIA scored &lt;strong&gt;84% accuracy&lt;/strong&gt; on objective questions, way higher than simple LLM reasoning. This happens because PHIA can recover when the code fails.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5p6ma2p9tzg1o75gjizq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5p6ma2p9tzg1o75gjizq.png" alt="ReAct Arch" width="799" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a question requires more than numbers—like understanding recommended sleep hours—PHIA uses a built-in web &lt;strong&gt;search tool&lt;/strong&gt; to fetch verified information from trusted sources.  Sometimes the user needs context, like: “Is this amount of sleep normal for my age?” “What workouts improve resting heart rate?” “Is my stress score healthy?”&lt;br&gt;
PHIA has a built-in search tool that pulls information from verified online sources. This mixing of data + domain knowledge is what makes PHIA feel smart and practical.&lt;/p&gt;

&lt;p&gt;What impressed me most is how PHIA blends everything together. It doesn’t just give numbers or copy facts. It calculates, it checks, it researches, and then it explains the result in clear language. The examples in the paper, like &lt;u&gt;comparing a user’s sleep with national guidelines&lt;/u&gt;, really show how these steps come together. In the end, PHIA feels less like a chatbot and more like someone doing careful, step-by-step reasoning to help you understand your own health patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Deep Dive Into PHIA’s Technical Architecture
&lt;/h2&gt;

&lt;p&gt;PHIA is not a fine-tuned model. It’s an agent framework built around &lt;strong&gt;&lt;u&gt;Gemini 1.0 Ultra&lt;/u&gt;&lt;/strong&gt;, with two major tools: (1) Python data analysis runtime, (2) Web search tool.&lt;/p&gt;

&lt;p&gt;These tools are orchestrated using the ReAct (Reason + Act) agent pattern, which is why PHIA can do multi-step reasoning without fine-tuning. This design gives PHIA abilities that raw LLMs don’t have: planning, correction, stepwise attention, and grounded analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  No Fintuning
&lt;/h3&gt;

&lt;p&gt;One of the most interesting things I learned from the paper is that PHIA is not fine-tuned like PH-LLM. Instead of modifying the model’s weights, the authors built a smart scaffolding around the model and taught it how to act like an agent.&lt;/p&gt;

&lt;p&gt;Fine-tuning a huge LLM like Gemini Ultra is expensive, slow, requires tons of supervised data, and risky (can break general reasoning ability).&lt;/p&gt;

&lt;p&gt;So instead, PHIA keeps the base model untouched and teaches the model how it should “think” and use tools using few-shot ReAct examples.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is a totally different philosophy: PH-LLM → change the model. PHIA → change the system around the model&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Process
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The authors started with thousands of wearable-related questions (objective + open-ended). They needed a tiny set of example tasks that could teach the model how to behave like an agent.&lt;/li&gt;
&lt;li&gt;Instead of randomly picking examples, they converted every question into numerical embeddings using Sentence-T5. This turns each question into a vector representing its meaning, so similar questions sit close together in vector space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpyn3yfndl2r7mcb4vox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpyn3yfndl2r7mcb4vox.png" alt="Process" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They ran k-means clustering (k=20) on these embeddings to automatically group similar questions into 20 clusters. Each cluster represents a whole “type” of question, like sleep trends, workout comparisons, anomaly detection, correlations, and so on.&lt;/li&gt;
&lt;li&gt;From each cluster, they selected the most central question — the one closest to the cluster centroid.This gives 20 representative queries, each standing in for a larger family of similar queries.&lt;/li&gt;
&lt;li&gt;For each of these 20 representative queries, the team manually wrote a complete ReAct agent trajectory that included every step of reasoning:

&lt;ul&gt;
&lt;li&gt;Thought: what the model should plan to do&lt;/li&gt;
&lt;li&gt;Action (Python): the exact Pandas code needed&lt;/li&gt;
&lt;li&gt;Observation: the real output that the code would return&lt;/li&gt;
&lt;li&gt;Thought again: interpreting the output&lt;/li&gt;
&lt;li&gt;Action (Search): when domain knowledge is needed&lt;/li&gt;
&lt;li&gt;Observation: the retrieved information&lt;/li&gt;
&lt;li&gt;Final Answer: a clear, natural-language explanation. These aren’t partial examples — they are full step-by-step walkthroughs that demonstrate how an agent should behave.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;These 20 full trajectories were inserted into PHIA’s few-shot prompt, acting as demonstrations inside its system instructions. So the model is not fine-tuned — instead, it is taught by example how to: plan before acting, decide when to run code, decide when to search the web, fix code errors, combine numerical results with domain knowledge, and produce a final personalized insight.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This is called “behavior cloning via prompting.” : It will learn the “pattern of behavior” from the examples, even without changing its internal parameters.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;PHIA is a perfect example of how powerful LLMs become when they are paired with the right scaffolding instead of relying only on internal reasoning. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpezd2e5c7ozuk7p1ljgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpezd2e5c7ozuk7p1ljgh.png" alt="graph" width="800" height="697"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations in the PHIA
&lt;/h2&gt;

&lt;p&gt;PHIA is a huge step forward, especially compared to simple chat-based coaching. But it’s still early-stage. It shows what’s possible when LLMs use tools, but it also exposes how much work is left to make an AI truly trustworthy in personal health.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHIA hasn’t been tested on real people yet, so we still don’t know if it truly helps users change habits or understand their health better in everyday life.&lt;/li&gt;
&lt;li&gt;It only uses wearable data, and I feel it needs more context—like nutrition, medical records, or mood logs—to give deeper and more holistic insights.&lt;/li&gt;
&lt;li&gt;PHIA isn’t medically validated, so even though it sounds smart, its recommendations haven’t been checked by doctors or health experts for real accuracy. Personalization still feels limited, because sometimes PHIA gives generic advice even when the user’s data is available right there.&lt;/li&gt;
&lt;li&gt;Its reasoning depends heavily on prompting and Gemini Ultra, which means its behavior might change across models or updates, making it less consistent.&lt;/li&gt;
&lt;li&gt;Error handling is better than basic LLMs but still imperfect, since PHIA can misread data columns or fail on messy real-world data.&lt;/li&gt;
&lt;li&gt;Its toolset is still narrow, and I’d love to see it generate visualizations, analyze other health signals, or track long-term goals instead of just answering one question at a time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learnings from the paper
&lt;/h2&gt;

&lt;p&gt;Reading the PHIA paper honestly changed the way I think about building AI systems. Before this, I used to focus mainly on making the model smarter, but PHIA showed me that the real progress comes from giving the model the right tools and the right structure. Seeing how PHIA uses the ReAct loop—think, act, observe—made me realize how important disciplined reasoning is for avoiding hallucinations and building trust.&lt;/p&gt;

&lt;p&gt;The use of synthetic data was another eye-opener, because it proved that we can train and evaluate personal-health agents responsibly without touching real user data. On top of that, the way the authors handled safety—650 hours of human review, strict guardrails, and cautious refusal behavior—reminded me that responsible AI isn’t optional; it’s part of the engineering.&lt;/p&gt;

&lt;p&gt;More than anything, PHIA taught me that the future of AI isn’t “a bigger model,” but a system where models, tools, data, and reasoning frameworks all work together. As an AI engineer, this shifted how I think about agents: not as chatbots, but as full pipelines designed to solve real problems with accuracy, humility, and safety.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Insights I’m Taking With Me
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;PHIA wins because it’s structured, not because the LLM is smarter.&lt;/li&gt;
&lt;li&gt;Reasoning and architecture beat raw model size.&lt;/li&gt;
&lt;li&gt;PHIA shines when a question needs data + external knowledge + multi-step logic, not just basic statistics.&lt;/li&gt;
&lt;li&gt;Its real strength is disciplined reasoning, not raw computation.&lt;/li&gt;
&lt;li&gt;PHIA’s strict safety guardrails make it trustworthy in a way normal LLMs aren’t.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>google</category>
      <category>health</category>
    </item>
  </channel>
</rss>
