How pwhiddy/pokemonredexperiments works
This repository trains reinforcement-learning agents to play Pokémon Red. The principal workflow is: PPO/Ray selects actions, the Gym environment applies them through PyBoy, extracts screens and game-state features, computes exploration/progress rewards, and returns observations for learning. Training can emit checkpoints and TensorBoard metrics, while coordinate streams feed a shared map. Separate recording and visualization tools replay sessions or render movement. Evidence is sampled from the V2 environment, trainers, recorder, and visualization scripts; some documented integrations are represented by their exact tree paths without unsampled call details.
Main entry points: red_gym_env_v2.py Red Gym V2 · baseline_fast_v2.py PPO Learner · red_gym_env_ray.py Ray Gym Env · run_pretrained_interactive.py Interactive Runner
Components 19
RL Training
- PPO Learner
v2/baseline_fast_v2.py - Ray PPO Trainer
baselines/ray_exp/train_ray.py - Training Metrics
baselines/tensorboard_callback.py
Game Environment
- Red Gym V2
v2/red_gym_env_v2.py - Legacy Gym Env
baselines/red_gym_env.py - Ray Gym Env
baselines/ray_exp/red_gym_env_ray.py - Minimal Gym Env
baselines/red_gym_env_minimal.py - Interactive Runner
baselines/run_pretrained_interactive.py
Live Broadcast
- Stream Wrapper
v2/stream_agent_wrapper.py
Recording Replay
- Session Recorder
jippity-6-test/play.py - Session CSV
- Replay Renderer
jippity-6-test/render_replay.py
Visualization
- Coordinate Renderer
jippity-6-test/render_coordinates.py - Map Flow Visualizer
visualization/BetterMapVis_script_version_FLOW_edge.py - Static Map Tools
visualization
Other components
- Researcher
- PyBoy Emulator
- ROM And States
- Shared Global Map
Connections 25
- Researcher → PPO Learner: starts training
- Researcher → Interactive Runner: plays interactively
- PPO Learner → Red Gym V2: creates environments
- PPO Learner → Training Metrics: registers callbacks
- Red Gym V2 → PyBoy Emulator: ticks emulator
- Red Gym V2 → PPO Learner: returns observations
- PPO Learner → Red Gym V2: sends actions
- Ray PPO Trainer → Ray Gym Env: configures workers
- Ray Gym Env → PyBoy Emulator: ticks emulator
- Ray Gym Env → Ray PPO Trainer: returns rewards
- Legacy Gym Env → PyBoy Emulator: ticks emulator
- Minimal Gym Env → PyBoy Emulator: ticks emulator
- Interactive Runner → PyBoy Emulator: drives emulator
- ROM And States → Red Gym V2: initializes game
- ROM And States → Interactive Runner: loads game
- Red Gym V2 → Stream Wrapper: emits coordinates
- Stream Wrapper → Shared Global Map: broadcasts progress
- Session Recorder → PyBoy Emulator: records gameplay
- Session Recorder → Session CSV: writes events
- Session CSV → Replay Renderer: reads sessions
- Replay Renderer → PyBoy Emulator: replays frames
- Session CSV → Coordinate Renderer: reads coordinates
- Coordinate Renderer → Static Map Tools: renders movement
- Session CSV → Map Flow Visualizer: loads trajectories
- Map Flow Visualizer → Static Map Tools: renders map flow