# Reinforcement Learning Fundamentals

> Agents, environments, rewards and value functions: the MDP framework, bandits, and tabular methods like Q-learning. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/reinforcement-learning-basics
Last updated: 2026-11-28

Agents, environments, rewards and value functions: the MDP framework, bandits, and tabular methods like Q-learning.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [Probability for ML](https://www.internhack.in/roadmaps/tracks/machine-learning/probability), [Optimization and Gradient Descent](https://www.internhack.in/roadmaps/tracks/machine-learning/optimization)

In reinforcement learning (RL) there are no labels. An **agent** takes actions in an **environment**, receives **rewards**, and must learn a **policy** that maximizes long-term reward. It is the framework behind game-playing agents, robotics control, and the preference tuning of language models.

### The vocabulary

- **Markov decision process (MDP)**: states, actions, transition probabilities, rewards and a **discount factor** gamma.
- **Return**: the discounted sum of future rewards.
- **Value function** V(s) and **action-value function** Q(s, a): how good a state or action is under a policy.
- **Bellman equations** express a value in terms of the next step's value; almost every algorithm is built on them.

### Core ideas

- **Exploration versus exploitation**: try new actions or use the best known one. **Multi-armed bandits** isolate this trade-off and are used directly for A/B testing and ad selection.
- **Dynamic programming** (value and policy iteration) when the environment model is known.
- **Monte Carlo** and **temporal-difference** learning when it is not.
- **Q-learning** (off-policy) and **SARSA** (on-policy) learn Q-values from experience with epsilon-greedy exploration.

### Tools

**Gymnasium** provides standard environments (CartPole, FrozenLake, MountainCar) with a common `reset` and `step` API. Start with tabular problems where you can print the whole Q-table and watch it converge.

**Good enough to move on** when you can implement tabular Q-learning for a grid world, tune epsilon and the learning rate, and explain the Bellman update you are applying.

## Key concepts

- **Agents, states, actions, rewards**
- **Markov decision processes**
- **Value functions and Bellman equations**
- **Exploration vs exploitation**
- **Multi-armed bandits**
- **Q-learning and SARSA**
- **Gymnasium environments**

## Mini project

Implement tabular Q-learning and SARSA for FrozenLake in Gymnasium, plot reward per episode for several epsilon schedules, and render the learned policy as arrows on the grid.

## Check yourself

What is the difference between on-policy SARSA and off-policy Q-learning, and why does the discount factor matter?

## Free resources

- [Reinforcement Learning: An Introduction (Sutton and Barto)](https://incompleteideas.net/book/the-book-2nd.html) (Sutton and Barto)
- [Gymnasium documentation](https://gymnasium.farama.org/) (Farama Foundation)
- [Hugging Face Learn](https://huggingface.co/learn) (Hugging Face)

Previous: [Time Series Forecasting](https://www.internhack.in/roadmaps/tracks/machine-learning/time-series-forecasting) · Next: [Deep Reinforcement Learning](https://www.internhack.in/roadmaps/tracks/machine-learning/deep-reinforcement-learning)

## More in Recommenders, Time Series and Reinforcement Learning

- [Recommender Systems](https://www.internhack.in/roadmaps/tracks/machine-learning/recommender-systems)
- [Time Series Forecasting](https://www.internhack.in/roadmaps/tracks/machine-learning/time-series-forecasting)
- [Reinforcement Learning Fundamentals](https://www.internhack.in/roadmaps/tracks/machine-learning/reinforcement-learning-basics)
- [Deep Reinforcement Learning](https://www.internhack.in/roadmaps/tracks/machine-learning/deep-reinforcement-learning)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
