Reward

The Feedback Signal

Reward is a scalar number the environment returns after each action — positive for good, negative for bad. The agent's entire goal is to maximize cumulative reward over time. The reward function is the most powerful and dangerous thing you design in an RL system.

Why Reward Design Is Hard

Reward hacking

The agent optimizes exactly the reward specified — whether or not it matches the real intent. A cleaning robot rewarded for floor area covered learns to spin in circles. A recommendation system rewarded for engagement time discovers that outrage retains users better than quality. Fully specifying what good behavior means as a scalar number is one of RL's core unsolved challenges.

Dense vs Sparse Rewards

Dense Rewards

Informative feedback at every (or most) time steps. A walking robot receives reward proportional to forward velocity each step — always knows if it's improving. Fast, stable learning. But harder to define what "good progress" means at every step.

Sparse Rewards

Reward only at key moments (win/loss at game end). Natural to define but makes learning very slow — the agent may take thousands of random actions before seeing any reward. Creates a severe credit assignment problem.

Discount Factor (γ)

How much to care about the future

γ (0 to 1) determines how much future rewards are worth today. γ = 0: only immediate reward matters (fully myopic). γ → 1: distant future rewards valued nearly as much as immediate ones (far-sighted). Common values: 0.95–0.999. Higher γ → better long-term planning but harder credit assignment.

Need Help?

Ask the AI assistant about RL reward, reward hacking, dense vs sparse rewards, or what the discount factor does.