Skip to content
Learn Motion
ExploreHow it worksMembership
Log in
Learn Motion

How AI Learns from Rewards and Mistakes

1The Trial-and-Error Loop: How an Agent Learns2Formalizing the Problem: States, Actions, Rewards, and Policies3Measuring Success: Return, Discounting, and Value4Learning from Experience: Value Updates and Q-Learning5Exploring vs. Exploiting: Where Mistakes Come From6Learning Policies Directly and Scaling Up
Learning from Experience: Value Updates and Q-Learning

From a Learned Q-Table to a Greedy Policy

2 / 2
Look at the small table in the example. In state A the two values are two point zero and five point five, so the greedy rule picks right. In state B the values are four point zero and one point five, so it picks left. The policy is not stored anywhere separately; it is read off the table every time we need a decision. That is also why a bad early estimate is not fatal. When the agent first tries an action, the reward it gets plus the discounted value of where it lands becomes the new target, and the gap between that target and the old estimate is the correction. Repeat that enough times and the numbers settle near the true values.
0:00 / 0:00

The greedy rule

In each state s, the greedy policy selects the action with the largest Q-value: pi(s) = argmax over a of Q(s, a). The policy is read off the table, so it improves whenever the table improves.

Reading a policy from a small table

Consider a corridor with two states, A and B, and two actions, left and right. Suppose the learned table is Q(A, left) = 2.0, Q(A, right) = 5.5, Q(B, left) = 4.0, Q(B, right) = 1.5. Applying argmax in each state gives pi(A) = right and pi(B) = left. No extra training is needed to produce this policy; it is a direct read of the table.

Why a wrong early estimate gets fixed

Suppose Q(A, right) starts at 0 because nothing has been tried. The first time the agent takes right from A, it receives a reward and lands in a next state whose best value is already nonzero. That reward plus the discounted next-state value becomes the target, and the error is large and positive, so Q(A, right) jumps upward. Each later visit adds another correction. The estimate does not need to be right at the start; it only needs to be updated often enough that the errors shrink.

A boundary on the greedy rule

Greedy action selection is how we extract a decision from a finished table. It is not by itself a good way to act while the table is still being learned, because always taking the current best action can leave better alternatives untried. That problem is the subject of the next chapter.

Previous2 / 2Next

Learn Motion

Generate a course. Learn it properly.

Operated by Wuhan Daoyin Technology Co., Ltd.

Contact: [email protected]
Privacy PolicyTerms of Service

© 2026 Learn Motion