Reward function

A reward function defines the goal in reinforcement learning by assigning a numerical score to the outcomes of an agent's actions. The agent learns to act by maximizing cumulative reward, so the reward function encodes what success means.

What is a reward function?

A reward function is how you tell a reinforcement learning agent what you want. It maps the outcome of an action, or a state, to a number, and the agent's entire objective is to accumulate as much reward as possible over time. Because the agent optimizes exactly what the reward specifies, the reward function is where the goal of the whole system is defined.
Designing it well is subtle: an imperfect reward can be maximized in ways that technically score high but miss the real intent.

Key takeaways

  • The reward function assigns numerical value to outcomes.
  • The agent learns by maximizing cumulative reward.
  • Poorly designed rewards lead to unintended behavior.

How it works

At each step the environment returns a reward reflecting how good the outcome was, and the agent updates its policy to favor actions that lead to higher long-term return. Rewards can be sparse, given only on success, or shaped to provide more frequent guidance. Reward shaping speeds learning but risks encouraging shortcuts if the shaped signal does not perfectly reflect the true goal.

Why it matters

The reward function is the specification of desired behavior for any reinforcement learning system, which makes it central to robot learning and control. Reward design is a well-known challenge in physical AI, since agents reliably exploit loopholes in an imperfectly specified reward.

Frequently asked questions

What is reward shaping?

Adding intermediate rewards to guide learning toward the goal faster, which helps with sparse rewards but can cause shortcuts if designed carelessly.

Why is designing a reward function hard?

Agents optimize exactly what is rewarded, so any mismatch between the reward and the true intent can produce technically high-scoring but undesirable behavior.

Related terms

Last updated July 9, 2026

Building visual or physical AI?

Let's talk.