Small single-file browser demo that visualizes a tiny reinforcement learning agent training in a grid world.
Run locally
- Start a simple HTTP server from the repository root:
python3 -m http.server 8000 --directory .- Open the demo in your browser:
http://localhost:8000/microrl.html
Demo
Controls
Pause/Resume— pause the simulationReset— restart environment and agentSpeedslider — how many train steps per frameQ-mapcheckbox — overlay per-cell max Q-value heatmap
What I added
- Q-value heatmap overlay (toggleable)
- Smooth agent motion and simple collect/death visual cues
- A small Python script
test_rl.pythat runs a tabular Q-learning equivalent to validate learning outside the browser
Python test
Run the included Python test to see equivalent training in a headless mode:
python3 test_rl.py --episodes 500The script prints per-episode rewards and writes rewards.csv with one reward per line.
Files
microrl.html— main browser demotest_rl.py— minimal Python Q-learning testLICENSE— MIT licenseCONTRIBUTING.md— short contributing notes
Notes
microrl.htmlis ~10KB and under the 50KB threshold; no further shrinking applied.
