The hardest part of RL is telling the agent what you actually want.
Reinforcement Learning agents are lazy; they will exploit any loophole in your reward function. Here, we try to teach a car (blue) to park in a spot (green).
1. Sparse Reward (Hard):
We only give a reward when the car hits the spot exactly. Until then, the agent gets nothing. It wanders blindly (random walk) and learns very slowly. This is realistic but difficult to solve.
2. Dense Reward (Easy):
We give the agent a small reward every time it gets closer to the goal (Reward Shaping). This acts like a trail of breadcrumbs. The agent learns extremely fast because it gets immediate feedback on every step.
3. Bad Reward (Loophole):
We naively give the agent +1 for "moving around." The agent quickly realizes it doesn't need to park to get points; it just drives in circles forever. This is a common bug in RL known as "Reward Hacking."