Melee RL — Fox vs Jigglypuff via Dolphin + OpenEnv
A reinforcement learning system that trains a Fox AI agent to play Super Smash Bros. Melee in real-time. The agent connects to Slippi Dolphin via libmelee and learns through self-play using PPO, served over HTTP with Meta's OpenEnv framework.
How It Works
Training Script (PPO) OpenEnv Server Slippi Dolphin
┌──────────────────┐ HTTP/WS ┌──────────────┐ libmelee ┌──────────────┐
│ dolphin_train.py │ ──SmashAction──> │ FastAPI app │ ──controller───> │ Melee game │
│ │ <─SmashObs───── │ (port 8000) │ <─gamestate──── │ (60 FPS) │
│ CompetitiveMelee│ │ EmulatorEnv │ │ Fox vs Puff │
│ Reward shaping │ │ Server │ │ on FD │
└──────────────────┘ └──────────────┘ └──────────────┘
OpenEnv server launches Dolphin, navigates menus, and exposes reset() / step() over HTTP
Training client sends controller inputs (stick, buttons) each frame and receives game state back
Reward shaping (CompetitiveMeleeReward) computes per-frame reward on the client side
PPO updates the policy every 2048 frames
Training Pipeline
Phase 1 — Physics Simulator (fast, offline)
Train base policies in a custom Melee physics engine — no emulator needed.
Produces checkpoints/puff_final.pt and checkpoints/mango_final.pt.
Phase 2 — Dolphin Fine-Tuning (real game)
Fine-tune the sim-trained Fox against real Melee running in Dolphin.
bash
1# Terminal 1: Start the OpenEnv server (launches Dolphin)2cd emulator_env && uv run --project . server
34# Terminal 2: Train Fox via PPO against CPU or Puff model5cd emulator_env && uv run python dolphin_train.py --agent mango \6 --checkpoint ../checkpoints/mango_final.pt --total-frames 500000
Configuration
All environment config is in emulator_env/.env:
env
1DOLPHIN_PATH=~/Library/Application Support/Slippi Launcher/netplay
2ISO_PATH=~/Downloads/Super Smash Bros. Melee (USA) (En,Ja) (v1.02).iso
3P1_CHARACTER=FOX
4P2_CHARACTER=JIGGLYPUFF
5CPU_LEVEL=7 # 0 = model-driven P2, 1-9 = Dolphin CPU AI
6TRAINING_MODE=NORMAL # NORMAL or RECOVERY
7# P2_CHECKPOINT_PATH=../checkpoints/puff_final.pt # uncomment when CPU_LEVEL=0
Setting
Options
Description
CPU_LEVEL
0
P2 controlled by a trained model (P2_CHECKPOINT_PATH)
CPU_LEVEL
1-9
P2 controlled by Dolphin's built-in CPU AI
TRAINING_MODE
NORMAL
Standard matches
TRAINING_MODE
RECOVERY
20% of resets spawn P1 off-stage for recovery training
Model Architecture
ActorCriticMLP — shared backbone with separate actor and critic heads.