How amcheste/pokemon-red-ai works
Pokémon Red RL Toolkit provides an emulator-backed Gymnasium environment and a RecurrentPPO experiment workflow. A user launches training with a ROM and save state; the trainer builds a model and environment, which turns emulator state into observations and rewards for the agent. Evaluation and statistical comparison support the resulting runs, while callbacks, alerts, and monitoring provide operational feedback. README-documented features include pixel, symbolic, and hybrid observations, multiple reward strategies, and live monitoring. Some subsystem links rely on README documentation because their implementation was not excerpted.
Main entry points: gym_env.py Gym environment · trainer.py Trainer · agent.py Emulated agent · train.py Training entry
Components 19
Experiment workflow
- Training entry
scripts/train.py - Trainer
pokemon_red_ai/training/trainer.py - RL models
pokemon_red_ai/training/models.py - Evaluation
scripts/eval.py
Game environment
- Gym environment
pokemon_red_ai/environment/gym_env.py - Observation treatments
pokemon_red_ai/environment/observations.py - Reward strategies
pokemon_red_ai/environment/rewards.py
Game interface
- Emulated agent
pokemon_red_ai/game/agent.py - Game controls
pokemon_red_ai/game/controls.py - Game memory
pokemon_red_ai/game/memory.py - Event flags
pokemon_red_ai/game/event_flags.py
Monitoring and analysis
- Training callbacks
pokemon_red_ai/training/callbacks.py - Configurable alerts
pokemon_red_ai/training/alerts.py - Live dashboard
scripts/monitor.py - Run comparison
pokemon_red_ai/analysis/comparison.py - Statistical analysis
scripts/analyze.py - Comparison dashboard
scripts/compare.py
Other components
- Experimenter
- PyBoy emulator
Connections 22
- Experimenter → Training entry: starts training
README.md - Training entry → Trainer: configures training
scripts/train.py - Trainer → RL models: creates model
pokemon_red_ai/training/trainer.py - Trainer → Gym environment: creates environment
pokemon_red_ai/training/trainer.py - Gym environment → Emulated agent: steps game
pokemon_red_ai/environment/gym_env.py - Emulated agent → PyBoy emulator: drives emulator
pokemon_red_ai/game/agent.py - Emulated agent → Game controls: uses controls
pokemon_red_ai/game/agent.py - Emulated agent → Game memory: reads state
pokemon_red_ai/game/agent.py - Gym environment → Observation treatments: builds observations
pokemon_red_ai/environment/gym_env.py - Gym environment → Reward strategies: calculates rewards
pokemon_red_ai/environment/gym_env.py - Observation treatments → Event flags: reads event flags
pokemon_red_ai/environment/observations.py - Reward strategies → Event flags: uses flag events
pokemon_red_ai/environment/rewards.py - Event flags → Game memory: reads memory
pokemon_red_ai/game/event_flags.py - Trainer → Training callbacks: registers callbacks
pokemon_red_ai/training/trainer.py - Training entry → Configurable alerts: configures alerts
scripts/train.py - Training callbacks → Live dashboard: feeds monitoring
- Experimenter → Evaluation: evaluates runs
README.md - Evaluation → Gym environment: uses environment
scripts/eval.py - Experimenter → Statistical analysis: analyzes results
README.md - Statistical analysis → Run comparison: uses comparisons
scripts/analyze.py - Experimenter → Comparison dashboard: compares runs
README.md - Comparison dashboard → Run comparison: uses comparison logic
scripts/compare.py