Reinforcement learning (RL) is a type of machine learning in which an agent learns to make decisions by trial and error. At each step it observes the state of its environment, takes an action, and receives a reward. Over many episodes it learns a policy, a strategy for choosing actions, that maximises total long-term reward. RL powers game-playing systems such as AlphaGo, robotics research, some recommendation systems and the preference-tuning used to make chat models helpful.
Most machine learning learns from examples with correct answers. Reinforcement learning is different: nobody tells the agent what the right move is. It has to try things, see what happens and improve, much like a child learning to ride a bicycle or a person learning a new game. This guide explains the core ideas, the main algorithms, real uses and limits, and how to start learning RL. If you're new to ML, read what machine learning is first.
What are the building blocks of reinforcement learning?
| Term | Meaning | Example: a delivery robot in a warehouse |
|---|---|---|
| Agent | The learner and decision maker | The robot's controller |
| Environment | Everything the agent interacts with | The warehouse floor, shelves, other robots |
| State | What the agent observes now | Its position, battery level, nearby obstacles |
| Action | A choice the agent can make | Move forward, turn, pick up, wait |
| Reward | A number signalling how good the last step was | +10 for a delivery, −1 per second, −50 for a collision |
| Policy | The agent's strategy: state → action | "If the aisle is blocked, take the next one" |
| Episode | One run from start to finish | One shift of deliveries |
| Value | Expected future reward from a state | How promising it is to be near the loading bay |
Formally, many RL problems are described as a Markov decision process (MDP): states, actions, transition probabilities, rewards and a discount factor that makes near-term rewards count more than distant ones.
Why does the discount factor matter?
An agent maximises the return: the sum of future rewards, each multiplied by the discount factor γ (gamma) raised to how many steps away it is. With γ close to 1 the agent plans far ahead; with smaller γ it becomes short-sighted. Here's how much a reward of 100 received in the future is worth today:
Calculated values: 0.99¹⁰ ≈ 0.904, 0.95¹⁰ ≈ 0.599, 0.9¹⁰ ≈ 0.349, 0.5¹⁰ ≈ 0.001. A lower γ makes the agent care much less about delayed rewards.
What is the exploration vs exploitation trade-off?
An agent must balance exploiting what it already knows works and exploring new actions that might work better. Always exploiting can trap it in a mediocre habit; always exploring wastes time. A simple, widely used strategy is epsilon-greedy: with a small probability ε pick a random action, otherwise pick the best known one, and gradually reduce ε as the agent learns. The same trade-off appears in business: a recommendation system that only shows proven items never discovers new favourites.
How does Q-learning work?
Q-learning learns a value Q(s, a) for each state–action pair: the expected return of taking action a in state s and acting well afterwards. After each step, it nudges its estimate towards "the reward I just got plus the discounted best Q-value of where I landed". Repeated enough, the Q-values converge and the policy is simply "pick the action with the highest Q". For small problems, Q is a table. For large ones (like pixels from a game screen), a neural network approximates it: that's a Deep Q-Network (DQN), the approach DeepMind used to learn many Atari games from raw pixels.
What are policy gradients, actor-critic methods and PPO?
Instead of learning values and deriving a policy, policy-gradient methods learn the policy directly: a neural network outputs action probabilities, and training increases the probability of actions that led to high return. Actor-critic methods combine both: an actor (the policy) and a critic (a value estimate that reduces noise in the learning signal). PPO (Proximal Policy Optimization) is a popular actor-critic method that limits how much the policy changes in each update, making training more stable. PPO is also the algorithm historically used in RLHF to tune language models.
| Family | Learns | Good for | Examples |
|---|---|---|---|
| Value-based | Q-values; policy = best action | Discrete actions (game moves) | Q-learning, DQN |
| Policy-based | The policy directly | Continuous actions (robot joints) | REINFORCE |
| Actor-critic | Policy + value | Most modern deep RL | A2C, PPO, SAC |
| Model-based | A model of the environment, then plans | When interaction is expensive | MuZero-style planning |
Where is reinforcement learning used in the real world?
- Games: AlphaGo and AlphaZero (Go, chess, shogi) combined deep networks, search and self-play; RL agents have also reached high levels in complex video games.
- Robotics: learning to grasp, walk and manipulate objects, often trained in simulation and then transferred to real robots.
- Language models: after supervised fine-tuning, models are tuned with feedback signals so their answers better match human preferences. Methods range from PPO-based RLHF to newer preference-optimisation approaches, and RL with verifiable rewards is used to improve reasoning on maths and code.
- Recommendations and ads: treating "what to show next" as a sequence of decisions with long-term engagement as the reward (bandit methods are a simpler relative).
- Operations research: research on data-centre cooling, traffic signal control, inventory and logistics.
- Systems and chips: research on using RL for chip floorplanning and compiler optimisation.
Why is reinforcement learning hard in practice?
- Sample inefficiency: agents may need millions of trials, which is fine in a simulator but expensive or dangerous in the real world.
- Reward design: agents optimise exactly what you reward, sometimes in unintended ways (often called reward hacking). A cleaning robot rewarded for "no visible dirt" might learn to cover its camera.
- Instability: training can be sensitive to hyperparameters and random seeds; results need multiple runs.
- Sim-to-real gap: behaviour learned in simulation may fail on real hardware.
- Safety: exploration in the real world must be constrained.
That's why many business problems that sound like RL are better solved with supervised learning, forecasting plus optimisation, or simple bandits. Good engineers know when not to use RL.
How does reinforcement learning compare with other kinds of ML?
| Aspect | Supervised | Unsupervised | Reinforcement |
|---|---|---|---|
| Feedback | Correct answer per example | None | Reward, often delayed |
| Data | Fixed labelled dataset | Fixed unlabelled dataset | Generated by the agent's own actions |
| Goal | Predict labels | Find structure | Maximise long-term reward |
| Example | Spam filter | Customer segments | Game-playing agent |
What is a multi-armed bandit, and why start there?
Imagine a row of slot machines, each paying out with a different unknown probability. You have 1,000 pulls. Which machine do you play? This "multi-armed bandit" problem is RL with a single state: there's no long-term planning, only the exploration–exploitation trade-off. Strategies like epsilon-greedy, upper confidence bound (UCB) and Thompson sampling solve it in a few lines of code. Bandits are also used in practice for A/B-style decisions, such as choosing which headline or layout to show, because they shift traffic towards better options while still testing alternatives. Implementing them is the gentlest possible introduction to RL thinking.
How should you start learning reinforcement learning?
- Get the prerequisites: Python, NumPy, probability, and supervised learning with neural networks. See what deep learning is and backpropagation explained.
- Start with bandits: the multi-armed bandit problem teaches exploration vs exploitation in a few lines of code.
- Implement tabular Q-learning on a grid world or the classic FrozenLake environment in Gymnasium.
- Move to DQN on CartPole with PyTorch.
- Learn policy gradients and PPO, using a well-tested library (such as Stable-Baselines3) to compare with your own implementation.
- Read the classic textbook: Sutton and Barto's Reinforcement Learning: An Introduction, which the authors make freely available online.
Keep experiments honest: run several seeds, plot learning curves and compare against simple baselines.
How does Program Zero cover reinforcement learning?
RL builds on everything before it, so in Program Zero it comes where it's useful rather than first. You learn Python (Phase 1), classical ML (Phase 6), deep learning and PyTorch (Phase 7) and transformers (Phase 8). In Phase 9, the alignment week is hands-on: supervised fine-tuning pipelines, reward model training on preference data, a PPO implementation for RLHF, DPO and modern alternatives, and red-teaming and safety evaluation. You see RL where it matters most in today's AI: shaping how language models behave.
Classes are live Monday to Friday 9:00–10:30 PM IST (recorded), with Saturday assignments and a Sunday doubt session; cumulative tests every three months; certificates on merit.
Understand the algorithms behind game-playing AI and aligned chat models, and build them yourself. See the artificial intelligence course, the generative AI and LLM course and the full curriculum, then book your seat for the batch starting 9 January 2027. Seats are limited.
What's the summary?
Reinforcement learning trains agents by trial and error: observe a state, act, get a reward, improve the policy. Value methods like Q-learning and DQN, policy methods and actor-critic methods like PPO are the main tools. RL shines in games, robotics and model alignment, but it's data-hungry and sensitive to reward design, so use it where it fits and learn it after solid ML and deep learning foundations.