← all repositories
ShangtongZhang/reinforcement-learning-an-introduction

The canonical RL textbook, translated into Python plots

Self-contained Python scripts that reproduce the figures and examples from Sutton & Barto’s reinforcement-learning bible.

14.7k stars Python LearningML Frameworks
reinforcement-learning-an-introduction
Not currently ranked — collecting fresh signals.
star history

What it does

This repository translates the algorithms and experiments from Sutton & Barto’s Reinforcement Learning: An Introduction (2nd Edition) into plain Python. Each file is a standalone script that recreates a specific textbook figure—whether it is epsilon-greedy bandits, blackjack value functions, or Dyna-Q learning curves—using NumPy and Matplotlib.

The interesting bit

There is no framework here, only pedagogy. By keeping every example self-contained, the repo lets you isolate one algorithm at a time and observe its behavior without digging through layers of abstraction. It is the computational equivalent of working the problem sets in the margins.

Key highlights

  • Covers Chapters 1 through 13, from multi-armed bandits to REINFORCE with baseline
  • Every script is self-contained; no package boilerplate or cross-file state to track
  • Reproduces the textbook’s exact figures, including Baird’s counterexample and Mountain Car cost-to-go plots
  • Built on NumPy, Matplotlib, and Seaborn—no opaque RL library underneath

Caveats

  • The README only catalogs figures through Chapter 13, so later chapters in the book are not represented
  • The maintainer explicitly states that exercise answers are not provided
  • The repository is organized as a flat figure index rather than a reusable library or modular package

Verdict

Ideal if you are reading Sutton & Barto and want to see the algorithms move. Skip it if you need a production-grade RL framework or deep neural network agents.

Frequently asked

What is ShangtongZhang/reinforcement-learning-an-introduction?
Self-contained Python scripts that reproduce the figures and examples from Sutton & Barto’s reinforcement-learning bible.
Is reinforcement-learning-an-introduction open source?
Yes — ShangtongZhang/reinforcement-learning-an-introduction is open source, released under the MIT license.
What language is reinforcement-learning-an-introduction written in?
ShangtongZhang/reinforcement-learning-an-introduction is primarily written in Python.
How popular is reinforcement-learning-an-introduction?
ShangtongZhang/reinforcement-learning-an-introduction has 14.7k stars on GitHub.
Where can I find reinforcement-learning-an-introduction?
ShangtongZhang/reinforcement-learning-an-introduction is on GitHub at https://github.com/ShangtongZhang/reinforcement-learning-an-introduction.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.