Models and Learning

What Is Q-Learning? How AI Learns Which Actions Produce Better Rewards.

By Rodolfo Garcia Calderoni, CFA ·

On this pageWhat Is Q-Learning?Key TakeawaysHow Does Q-Learning Work?What Is a Q-Value?How Does Q-Learning Update Its Estimates?What Is Exploration vs. Exploitation?Q-Learning vs. Deep Q-NetworkFrequently Asked QuestionsThe Bottom LineSourcesRelated terms

What Is Q-Learning?

Q-learning is a reinforcement learning algorithm that learns how valuable different actions are in particular situations.

It estimates the expected long-term reward associated with taking an action in a given state and then behaving optimally afterward.

The name comes from the Q-function, which assigns values to state-action pairs.

For example, a robot learning to navigate a simple maze may use Q-learning to discover which movement choices are most likely to lead toward its destination.

Key Takeaways

  • Q-learning learns action values using experience and reward feedback.
  • It is a model-free reinforcement learning method, meaning it does not need an explicit environment-transition model for its updates.
  • Basic tabular Q-learning works best with manageable state and action spaces; complex robotics problems often require function approximation or other methods.

How Does Q-Learning Work?

Imagine a mobile robot navigating a small grid-based environment.

At each location, the robot can choose to move up, down, left, or right.

Some movements bring it closer to a destination.

Others lead to dead ends.

The robot begins without knowing the best action at every location.

As it explores, it receives rewards based on what happens.

For example, reaching the destination might produce a positive reward.

The algorithm updates its estimates of how valuable particular actions are.

Over many experiences, the robot learns which actions are likely to produce better long-term outcomes.

What Is a Q-Value?

A Q-value describes the estimated value of taking a particular action in a particular state and then continuing optimally.

Consider a robot at an intersection.

Its learned values might be:

  • Move left: Q-value of 8
  • Move right: Q-value of 3
  • Move forward: Q-value of 5

These are illustrative values, not probabilities.

Under a greedy action-selection strategy, the robot chooses left because it has the highest estimated value.

However, Q-learning generally also needs exploration during training so it can discover potentially better actions.

How Does Q-Learning Update Its Estimates?

A simplified Q-learning update uses the immediate reward and the estimated value of the best next action.

The target is:

Target = Reward + Discount Factor × Best Next-State Q-Value

Suppose the robot receives a reward of 10.

Its discount factor is 0.9, and the best estimated next-state value is 4.

The target is:

10 + (0.9 × 4) = 13.6

The algorithm adjusts the current Q-value toward this target according to its learning rate.

For terminal states, the future-value term is typically omitted.

What Is Exploration vs. Exploitation?

Exploration involves trying actions to discover their outcomes.

Exploitation involves choosing actions believed to produce the highest reward.

A robot that always chooses the action currently rated best may never discover a better alternative.

During training, Q-learning can use exploration strategies such as epsilon-greedy selection.

Under this approach, the agent sometimes chooses a random action instead of its current best choice.

The exploration strategy can change as learning progresses.

Q-Learning vs. Deep Q-Network

Basic Q-learning can store state-action values in a table.

This is practical when the number of states and actions is relatively small.

Real robots can have enormous or continuous state spaces.

A Deep Q-Network, or DQN, uses a neural network to estimate Q-values rather than maintaining a simple lookup table.

However, conventional DQN approaches are generally associated with discrete action choices.

Continuous robot-control problems often use other reinforcement learning methods.

Frequently Asked Questions

Does Q-learning require a map of the environment?

No. It learns action values from experience rather than requiring an explicit map or dynamics model.

Can Q-learning train a real robot?

Yes, but physical exploration can be expensive or unsafe. Simulation is frequently used for early training.

The Bottom Line

Q-learning teaches an agent to estimate which actions lead to valuable outcomes. It is a foundational reinforcement learning method, especially useful for understanding how machines learn decisions through experience.

Sources

  1. TensorFlow Agents — Introduction to Reinforcement Learning and Q-Networks
  2. PyTorch — Deep Q-Learning Tutorial

Black Scarab Weekly

Follow the physical AI economy

Get Black Scarab news, deep research, and practical analysis in one clear Thursday briefing.

Weekly reporting and deep dives. Unsubscribe anytime. See our privacy notice.