Unit 11 of 11 · about 4 hours · explain, implement

Reward timing, shaping, unintended optima and MDP formulation

Reward and formulation are the task. No planner fixes a proxy that rewards the wrong behaviour.

You'll be able to

  • Explain reward timing, shaping with and why arbitrary shaping changes the optimal policy.
  • Give a reward-hacking example where the proxy optimum differs from the intended behaviour.
  • Formulate an MDP with state sufficiency, action authority, horizon, observability and evaluation policy.

Covers

Reward timing, reward shaping and unintended optimal policiesMDP formulation with state sufficiency, action authority and evaluation policy
1

Read

In this order, only the parts listed

0 of 4 done

  1. Goals, rewards and the reward hypothesisReinforcement Learning: An Introduction (2nd ed.) - Chapters 3 and 4

    Chapter 3, Section 3.2 Goals and Rewards with the reward hypothesis, printed pp. 53 to 54. The authors post the full text free at incompleteideas.net.

  2. Reward shaping and misspecificationHands-on Modern RL - MDPs, Values and Bellman Equations

    Reward Shaping with potential-based form and the distance potential numbers, and Reward Misspecification with Coast Runners and Noisy-TV (page read 2026-10-14)

  3. Reward hacking proxyStanford CS234 Winter 2026 - Foundations and Planning

    Assignment 1, Section 2, Reward Hacking with the park versus merge proxy and part (b) alternate reward design, p. 3

  4. AI Tutor formulation exerciseStanford CS234 Winter 2026 - Foundations and Planning

    Refresher Exercise: AI Tutor as a Decision Process with the state, action, reward and dynamics question and which items the agent will learn to give (slides 28 to 29)

2

Focus on

  • Reward defines the task. Value is always value under that reward. Changing reward changes and .
  • Potential shaping preserves the optimal set. Other shaping such as a positive per-step bonus without a time limit can make looping optimal when is 1 or close to it.
  • Formulation must state what makes the state Markov, what actions control, how episodes end, what and mean and how the evaluation policy differs from behaviour.
Common mistakes · 3
  • Treating discount or horizon as implementation detail. Assignment 1 Section 1 shows they change the optimal inventory policy.
  • Adding an alive bonus to speed learning and keeping it for evaluation. The bonus becomes part of the task.
  • Evaluating with the exploratory behaviour policy. Fix a separate evaluation policy with its own seeds before claiming an optimal policy.
3

Try it yourself

Closed-book, before checking anything

On one grid with , as in the Hands-on Rule C numbers, compare sparse terminal-only reward with a positive per-step bonus and no time limit to show looping beats finishing. Then replace the bonus with shaping and show the optimal set is unchanged.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.What is the potential-based shaping form?Answer

    . It adds a state-potential difference without changing the optimal set.

  2. 2.Why does the Hands-on Rule C grid loop?Answer

    Each step pays positive reward with no time limit and no discount, so longer paths collect more. Looping near the goal beats finishing quickly.

  3. 3.Why does the Assignment 1 car park instead of merging?Answer

    The proxy maximizes mean velocity. Merging adds a slow car and lowers the mean. Parking avoids the penalty while the true goal wants short commutes.

  4. 4.What must an MDP formulation state?Answer

    State sufficiency for Markov structure, action authority, reward components and timing, termination and truncation, and , observability limits and the evaluation policy.

You're done when

You can turn one ambiguous task into two competing MDPs, predict how their optimal policies differ, and name the evaluation policy for each.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 4 more in the section
  • Stanford CS234 Winter 2026 - Foundations and PlanningStanford University · primary

    Study Lecture 1 (lecture1pre.pdf and lecture1post.pdf) and Lecture 2 on tabular MDP planning (lecture2pre.pdf and lecture2post.pdf under https://web.stanford.edu/class/cs234/slides/). Work Assignment 1 independently: the written MDP, horizon and Bellman-operator questions and the vi_and_pi.py planning code on RiverSwim (NumPy only). Do not copy or publish course solutions.

  • Reinforcement Learning: An Introduction (2nd ed.) - Chapters 3 and 4Richard Sutton and Andrew Barto · required

    The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Chapter 3 (Sections 3.1 to 3.7, finite MDPs, returns, Bellman equations and optimality) and Chapter 4 (Sections 4.1 to 4.7, policy evaluation, improvement, policy and value iteration, asynchronous DP and GPI). Reproduce Example 4.1 and Figure 4.1 exactly, then Example 4.3 (the gambler), and write exact tests for stochastic transitions, terminals, ties and stopping error.

  • Hands-on Modern RL - MDPs, Values and Bellman EquationsWalking Labs · support

    Use the value and Bellman page and the value experiment page (code/chapter03_mdp/bellman_equation_verify.py and gridworld_q_learning.py run on CPU in seconds) as a code companion. Check every equation against Sutton and Barto before adopting it. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its code/chapterNN folders do not follow the site chapter numbers.

Also in this section

  • Gymnasium - Time Limits and Episode SemanticsFarama Foundation · required

    Read the termination, truncation and "importance in learning code" sections, then the vector autoreset note at https://farama.org/Vector-Autoreset-Mode (next-step autoreset is the default in Gymnasium 1.x). Build a wrapper test that distinguishes termination from truncation and proves which cases bootstrap before using any third-party environment.

  • Deep-ML - Planning ProblemsDeep-ML · support

    Use named problems as closed-book checks after your own implementation passes: 157 (Bellman equation for value iteration), 164 (the gambler's problem by value iteration) and 467 (policy iteration). Read each problem's tests before trusting its statement.

  • Reinforcement Learning Control Laboratory - Planning CoreRoadmap-Final · required

    Complete Milestone A planning requirements: an explicit finite MDP, exact policy evaluation, value iteration, policy iteration, simulator agreement and seeded reward, transition, terminal and tie defects.

  • Reinforcement Learning: An Introduction (2nd ed.) - Chapter 2 banditsRichard Sutton and Andrew Barto · reference

    Read Section 2.9, Associative Search (Contextual Bandits), printed p. 41, with Exercise 2.10 as the context versus no-context check. Use only this section from Chapter 2.