The last chapter's Bellman equation was conditioned on a policy someone else handed you: , the value if you follow . But nobody handed the gridworld's agent "always right" — it has to be discovered. That means asking a sharper question: not "how good is this policy," but "how good can any policy possibly make this state?"
Step through each state and compare its two available one-step lookaheads, and — the value of taking that action once, then acting optimally forever after. Whichever is larger is , the optimal value of that state. There's no policy input here at all: the "best possible" value falls straight out of comparing the actions.
The optimal value function is the best expected discounted return achievable from , over every possible policy. It satisfies the Bellman optimality equation — the same recursive shape as before, but with a over actions replacing a policy's fixed choice:
- — the optimal value of state : the best expected discounted return any policy can achieve from here.
- — a candidate action, ranged over by the .
- — the immediate reward for taking action from state .
- — the discount factor.
- — the state landed in after taking action from .
It's often useful to split the bracketed quantity out into its own object, the optimal action-value function:
- — the value of taking action from once, then behaving optimally forever after.
- V* and Q* are two views of the same thing
— the optimal value of a state is just the best action-value available from it. Every number in this chapter is secretly a over two numbers.
- The optimal policy falls out for free
Once is known, the optimal policy is simply — no separate search required. This is exactly the relationship Q-learning exploits: learn , and a policy comes along for free.
These are the exact same numbers the MDP chapter computed for "always right" — . That's not a coincidence: with only two actions and a reward structure where moving away from the goal is strictly worse, "always right" already achieves the best possible value from every state. here only because happened to already be optimal.
Using the already-known values , , , (from the previous chapter), check that the Bellman optimality equation actually holds at each state:
- State 2 — where the two actions disagree the most
. . The max is , exactly — and "right" is clearly the better action here, by .
- State 0 — furthest from the goal
. bounces back to state itself: . The max is , exactly .
- The equation is a consistency check, not a solving method
Every one of these checks passes only because the correct values were already plugged in on the right-hand side. Nothing here computed from scratch — that's the job of the next chapter.
Step forward until you reach the state whose optimal value V*(s) equals exactly 10.
The Bellman optimality equation defines what and are — a fixed point that the true optimal values must satisfy — but it doesn't by itself say how to find them when they aren't already known. Here, they were simply recognized by re-using a policy already proven optimal. The next chapter shows the general algorithm: start from a wrong guess for every state's value, and keep applying this exact equation as an update rule until it stops changing anything.