An open-source, community-driven resource for learning reinforcement learning.
rlbook.ai combines AI-assisted content generation with human curation to create high-quality educational content for reinforcement learning. Features include:
- Interactive demos running in your browser (TensorFlow.js)
- Progressive complexity - toggle math and code visibility
- PyTorch notebooks for deeper exploration (Google Colab)
- Community-driven content with transparent review status
Created by Enes Bilgin, author of "Mastering Reinforcement Learning with Python".
rlbook.ai organizes content into five categories, each serving different learning goals:
| Category | Purpose | Description |
|---|---|---|
| ๐ Chapters | Learn Concepts | Progressive lessons teaching RL from foundations to advanced topics |
| ๐ Papers | Deep Dives | In-depth analysis of seminal research papers |
| ๐ฏ Applications | Problem Formulation | End-to-end guides for formulating real problems as RL |
| ๐ง Infrastructure | Scale & Deploy | Engineering guides for distributed training and production |
| ๐ฎ Environments | Experiment | Interactive playgrounds for hands-on experimentation |
| ๐ป Code | Run & Test | Production-grade Python implementations |
See docs/CONTENT_TYPES.md for detailed descriptions and contribution guidelines.
- Node.js 18+
- Python 3.9+ (for the RL code package)
# Clone the repository
git clone https://github.com/ebilgin/rlbook.git
cd rlbook
# Run setup script (installs everything)
./scripts/setup.shThis will:
- Install npm dependencies
- Create a Python virtual environment (
.venv/) - Install the
rlbookPython package - Run tests to verify everything works
If you prefer to set things up manually:
# Node.js setup
npm install
npm run dev # Start dev server at http://localhost:4321
# Python setup (optional, for RL code)
python3 -m venv .venv
source .venv/bin/activate
pip install -e ./code
pytest code/tests/ # Verify installation| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build locally |
npm run check |
Run TypeScript and Astro checks |
pytest code/tests/ |
Run Python tests (requires venv activation) |
rlbook/
โโโ content/
โ โโโ chapters/ # ๐ Progressive learning content
โ โ โโโ XXXX-slug/ # Numbered for ordering (0010, 0020, 1010...)
โ โ โโโ index.mdx # Content
โ โ โโโ prompt.md # AI generation prompt
โ โโโ papers/ # ๐ Paper deep dives
โ โโโ applications/ # ๐ฏ Problem formulation guides
โ โโโ infrastructure/ # ๐ง Engineering guides
โ โโโ environments/ # ๐ฎ Interactive playgrounds
โโโ prompts/ # AI prompt templates and guidelines
โ โโโ PRINCIPLES.md # Core content principles
โ โโโ STYLE_GUIDE.md # Writing style guide
โ โโโ MATH_CONVENTIONS.md # Math notation standards
โ โโโ MDX_AUTHORING.md # MDX syntax rules (critical!)
โ โโโ templates/ # Reusable prompt templates
โโโ code/ # ๐ป Python package
โ โโโ rlbook/ # Installable package
โ โ โโโ envs/ # Environment implementations
โ โ โโโ agents/ # Agent implementations
โ โ โโโ utils/ # Utilities (replay buffer, plotting)
โ โ โโโ examples/ # Runnable training scripts
โ โโโ tests/ # Unit tests
โโโ src/
โ โโโ components/ # React components
โ โ โโโ interactive/ # RL demos (GridWorld, etc.)
โ โ โโโ ui/ # UI components
โ โโโ layouts/ # Astro layouts
โ โโโ pages/ # Astro pages
โ โโโ styles/ # Global CSS
โโโ notebooks/ # Google Colab notebooks (PyTorch)
โโโ scripts/ # Development scripts
โ โโโ setup.sh # One-command project setup
โโโ public/ # Static assets
โโโ docs/ # Project documentation
This project uses AI-assisted content generation. Prompts are first-class assets that define what content gets generated.
Each content type has its own structure and guidelines. See docs/CONTENT_TYPES.md for details.
Quick example for chapters:
- Create the directory:
mkdir -p content/chapters/1025-my-chapter/{exercises,assets} - Write the prompt:
content/chapters/1025-my-chapter/prompt.md - Generate content using Claude Code, Claude.ai, or the API
- Review using
prompts/EDITOR_REVIEW.md
# Install Claude Code
npm install -g @anthropic-ai/claude-code
# Navigate to the repo and start Claude
cd rlbook
claude
# Then ask Claude:
# "Read content/chapters/1020-q-learning-basics/prompt.md and generate
# the chapter content following all principles in prompts/PRINCIPLES.md."- Open claude.ai
- Upload:
prompts/PRINCIPLES.md,prompts/STYLE_GUIDE.md, and the content'sprompt.md - Ask Claude to generate the content
- Copy output to
index.mdx
import anthropic
client = anthropic.Anthropic()
with open("prompts/PRINCIPLES.md") as f:
principles = f.read()
with open("content/chapters/1020-q-learning-basics/prompt.md") as f:
chapter_prompt = f.read()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=8000,
messages=[{
"role": "user",
"content": f"{principles}\n\n---\n\n{chapter_prompt}\n\nGenerate the chapter content in MDX format."
}]
)
print(message.content[0].text)- Prompts before content: Write/refine the prompt, then generate content
- Use slugs, not numbers: Reference content by slug (e.g.,
q-learning-basics) - Three complexity layers: Intuition โ Mathematical โ Implementation
- Interactive-first: Every concept should have or suggest an interactive demo
- Test builds: Always run
npm run buildbefore committing MDX content
See prompts/PRINCIPLES.md for detailed guidelines.
Content is written in MDX, which has some parsing quirks. Read prompts/MDX_AUTHORING.md before writing content.
Quick rules:
- Avoid
\begin{cases}in LaTeX (use bullet lists instead) - Avoid
|x|in table cells (conflicts with markdown tables) - Escape
<,>,{,}in prose
All content shows its review status:
| Status | Icon | Meaning |
|---|---|---|
| Draft | ๐ | AI-generated, pending review |
| Editor Reviewed | โ | Approved by editor |
| Community Reviewed | ๐ฅ | Incorporates community feedback |
| Verified | ๐ | Code tested, demos working |
-
GitHub Integration:
- Go to Cloudflare Dashboard โ Pages
- Connect to Git and select this repository
- Build command:
npm run build - Output directory:
dist
-
GitHub Actions (Current Setup):
- Add secrets:
CLOUDFLARE_API_TOKEN,CLOUDFLARE_ACCOUNT_ID - Commits to
maintrigger production deployment - PRs get preview deployments
- Add secrets:
npm run build
npx wrangler pages deploy dist --project-name=rlbookWe welcome contributions! See docs/CONTRIBUTING.md for guidelines.
- Report issues: Typos, bugs, unclear explanations
- Improve prompts: Better prompts = better content
- Build demos: Check issues labeled
interactive - Review content: Use checklist in
prompts/EDITOR_REVIEW.md - Add applications: Share your RL problem formulations
- Write paper analyses: Deep dive into seminal papers
- Contribute code: Add tested implementations to
code/rlbook/
- Framework: Astro with islands architecture
- Content: MDX with React components
- Styling: Tailwind CSS
- Math: KaTeX for LaTeX rendering
- ML Runtime: TensorFlow.js (browser)
- Python Package: PyTorch + Gymnasium (code/)
- Notebooks: PyTorch (Colab)
- Hosting: Cloudflare Pages + R2
- Comments: Giscus (GitHub Discussions)
- Content: CC BY-NC-SA 4.0
- Code: MIT