The original notebook was trained with the baseline configuration and also tested with a modified gamma value. Both runs are documented here alongside their recorded terminal output. All recorded results belong to the preserved Python/Keras notebook.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/cartpole/llms.txt
Use this file to discover all available pages before exploring further.
Baseline Training Configuration
The nine constants below define the DQN agent’s learning behavior. For a full description of each value see Model Configuration.| Parameter | Value |
|---|---|
| ENV_NAME | CartPole-v1 |
| GAMMA | 0.95 |
| LEARNING_RATE | 0.001 |
| MEMORY_SIZE | 1,000,000 |
| BATCH_SIZE | 20 |
| EXPLORATION_MAX | 1.0 |
| EXPLORATION_MIN | 0.01 |
| EXPLORATION_DECAY | 0.995 |
Solve Criterion
The CartPole-v1 environment is considered solved when the agent achieves a rolling average score of 195 or greater across 100 consecutive episodes. A single episode ends when the pole falls beyond 15 degrees, the cart moves outside bounds, or the step limit of 500 is reached. The live demo tracks a rolling average of the last 100 scores toward this same goal, displayed in real time in the training metrics panel.Gamma Experiment
A second training run testedGAMMA = 0.995 — stronger weighting of future rewards — while leaving all other parameters at their baseline values. The hypothesis was that more long-term weighting would encourage more stable pole-balancing decisions, at the possible cost of slower convergence.
experiment-gamma.py
Recorded Run Results
The preserved notebook contains the output from three solved runs. Each run reached the CartPole-v1 maximum score of 500 and surpassed the 195 rolling-average threshold.| Run | Rolling Average | Max Score | Solve Run | Total Runs |
|---|---|---|---|---|
| Gamma 0.995 | 195.38 | — | 89 | 189 |
| Recorded Run 01 | 197.25 | 500 | 99 | 199 |
| Recorded Run 02 | 199.43 | 500 | 39 | 139 |
The browser demo does not reproduce the original Python training results exactly — it is a live interactive simulation. The recorded averages (195.38, 197.25, 199.43) come from the preserved
Cartpole.ipynb notebook, which used Keras and the full OpenAI Gym environment. The JavaScript demo recreates the same learning structure but runs in a physics approximation inside the browser.Exploration Decay Timeline
Exploration rate decays multiplicatively after each call toexperience_replay(). Starting from EXPLORATION_MAX = 1.0, each replay multiplies the current rate by EXPLORATION_DECAY = 0.995, down to the floor of EXPLORATION_MIN = 0.01.
The update applied after each call to experience_replay() is:
| Target Epsilon | Replay Calls Required |
|---|---|
| 0.5 | ≈ 139 replays |
| 0.1 | ≈ 460 replays |
| 0.01 (floor) | ≈ 920 replays |
BATCH_SIZE = 20, a replay call requires at least 20 experiences in memory. The decay milestone at ≈ 920 replays means the agent has sampled at least 18,400 individual experience tuples by the time it reaches minimum exploration.