5.2.13 · D3Deep & Advanced RL

Worked examples — Reward shaping and sparse rewards

2,571 words12 min readBack to topic

This page is the exhaustive drill for the parent topic. We take the potential-based shaping formula and run it through every kind of situation that can appear: moving toward or away from a goal, standing still, looping, terminal states, the discount set to different values, a non-potential (dangerous) shaping, and a real-world word problem. If you have never seen this notation, read the parent first — but every symbol used here is re-anchored below.


The scenario matrix

Here is every case class this topic can throw at you. Each later example is tagged with the cell it covers.

Cell Situation What we test
A Move toward goal ( increases) ?
B Move away from goal ( decreases) ?
C Stay put () sign of when unchanged
D Full loop back to start does sum to ?
E Terminal / degenerate state (episode ends) how (terminal) is handled
F Limiting vs small how the factor bites
G Non-potential shaping (the trap) policy corruption
H Real-world word problem translate a task into
I Exam twist — recover from policy-invariance algebra

The examples below cover A–I.


Worked examples


Recall Quick self-test across the matrix

Toward-goal step sign of ? ::: Positive (Example 1, ). Stay-put when and ? ::: , e.g. at — small, not zero (Example 3). Sum of around any closed loop under PBRS? ::: Exactly (Example 5). Does a -per-wall bonus corrupt the policy? ::: Yes — a 4-step loop pays , it is not potential-based (Example 6). Recover true from shaped ? ::: (Example 9).

Related tools when a good is unavailable: Hindsight Experience Replay, Curriculum Learning, and Exploration vs Exploitation bonuses. The invariance proof rests on Value Functions and Bellman Equations over Markov Decision Processes.