|
1 | | -# Reinforcement Learning Fundamentals — Code |
2 | | -This repo hosts chapter-wise companion code. Chapter 2 is complete and CI-tested. |
| 1 | +# Reinforcement Learning Fundamentals — Companion Code |
| 2 | + |
| 3 | +[](https://github.com/srikanthbaride/Reinforcement-Learning-Fundamentals-Code/actions) |
| 4 | + |
| 5 | +This repository hosts **chapter-wise companion code** for the book *Reinforcement Learning Fundamentals: From Theory to Practice*. |
| 6 | +It provides clean, minimal, and well-tested implementations of key reinforcement learning concepts. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 📂 Repository Structure |
| 11 | + |
| 12 | +``` |
| 13 | +rl-fundamentals-code/ |
| 14 | +├─ ch2_rl_formulation/ # Chapter 2: The RL Problem Formulation |
| 15 | +│ ├─ gridworld.py # 4x4 GridWorld MDP |
| 16 | +│ ├─ evaluation.py # Policy evaluation, q_from_v |
| 17 | +│ ├─ policies.py # Greedy & ε-greedy policies |
| 18 | +│ ├─ examples/ # Numeric examples + GridWorld demo |
| 19 | +│ └─ tests/ # Pytest-based validation |
| 20 | +├─ ch3_multi_armed_bandits/ # Chapter 3: Multi-Armed Bandits (placeholder) |
| 21 | +│ └─ tests/ |
| 22 | +├─ utils/ # Shared helper utilities |
| 23 | +├─ .github/workflows/ # CI: runs PyTest on every push/PR |
| 24 | +├─ requirements.txt # Global dependencies |
| 25 | +└─ README.md |
| 26 | +``` |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## 🚀 Getting Started |
| 31 | + |
| 32 | +Clone this repository: |
| 33 | + |
| 34 | +```bash |
| 35 | +git clone https://github.com/srikanthbaride/Reinforcement-Learning-Fundamentals-Code.git |
| 36 | +cd Reinforcement-Learning-Fundamentals-Code |
| 37 | +``` |
| 38 | + |
| 39 | +Set up a virtual environment (recommended): |
| 40 | + |
| 41 | +```bash |
| 42 | +python -m venv .venv |
| 43 | +source .venv/bin/activate # Linux/macOS |
| 44 | +.\.venv\Scriptsctivate # Windows PowerShell |
| 45 | +``` |
| 46 | + |
| 47 | +Install dependencies: |
| 48 | + |
| 49 | +```bash |
| 50 | +pip install -r requirements.txt |
| 51 | +``` |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## ✅ Running Tests |
| 56 | + |
| 57 | +To run all tests: |
| 58 | + |
| 59 | +```bash |
| 60 | +python -m pytest -q |
| 61 | +``` |
| 62 | + |
| 63 | +To run only Chapter 2 tests: |
| 64 | + |
| 65 | +```bash |
| 66 | +python -m pytest -q ch2_rl_formulation/tests |
| 67 | +``` |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## 🧪 Examples |
| 72 | + |
| 73 | +Run numeric checks for Chapter 2: |
| 74 | + |
| 75 | +```bash |
| 76 | +python -m ch2_rl_formulation.examples.numeric_checks |
| 77 | +``` |
| 78 | + |
| 79 | +Run the GridWorld demo: |
| 80 | + |
| 81 | +```bash |
| 82 | +python -m ch2_rl_formulation.examples.gridworld_demo |
| 83 | +``` |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## ⚙️ Continuous Integration |
| 88 | + |
| 89 | +- GitHub Actions (`.github/workflows/python-tests.yml`) automatically run tests for all chapters on every push and pull request. |
| 90 | +- This ensures correctness and reproducibility of the examples. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## 📖 License |
| 95 | + |
| 96 | +MIT License © 2025 — Srikanth Baride |
0 commit comments