pkmn.ai

Loxias @ cdd2015

View diff

Gen 1 OU (RBY) agent trained with reinforcement learning only: PPO self-play, no imitation of human logs. The project also runs bots on pkmn.bot (Gen 1) and vgc.bot; the VGC bots use separate models.

Setup

  • Engine: custom Rust Gen 1 battle engine for training and evaluation.
  • Hardware: one RTX 5090 on vast.ai.
  • Algorithm: PPO self-play.
  • Formats: random battles and OU. OU teams are 50% generated by poke-env’s Smogon usage-stats teambuilder and 50% drawn from a pool of top ladder teams.

Model

Transformer over the public battle state. Pure embedding of the current state - no direct history.

Heads:

  • Move head: one logit per move token.
  • Switch head: one logit per own Pokémon token. Move and switch logits form a single distribution over legal choices.
  • Value head: win estimate from the global token.
  • Opponent head: auxiliary prediction of the opponent’s action from the global token, trained with cross-entropy alongside the PPO loss.
Model sizes, in training order
NameWidth × layersParameters
n64 × 20.13M
xs128 × 40.6M
s192 × 61.9M
m256 × 84.4M
l384 × 89.8M
xl384 × 1214.6M

RBY Loxias 0.0.0 uses a model of size l.

Distillation

Each size is initialised from the previous best model:

  1. Online distillation, ~4–6M games: the student plays its own games and regresses onto the teacher’s policy (KL) and value on the states it visits. Offline distillation on a fixed set of teacher positions overfit and collapsed once self-play began.
  2. Anchored PPO, ~2–3M games: PPO plus a KL anchor to the distilled checkpoint, weight annealed 1 → 0.
  3. Plain PPO, with the learning rate stepped down when evaluation scores plateau.

Total: on the order of 500M self-play games across all sizes; the larger runs are 150M+ games each.

League

Opponents are drawn from a league of past versions of the smaller models, past and current versions of the model being trained, and heuristic bots. Sampling weights are rebalanced over the course of a run.

A/B testing on live ladders

Offline metrics (self-play, fixed benchmark bots) frequently disagreed with live results. Recommended: test variants on pkmn.bot / vgc.bot with a bandit.

  • Arms are combinations of levers, e.g. checkpoint × decision method.
  • Fit a Bayesian win-probability model with additive lever effects and an opponent-rating term.
  • Select arms per game by Thompson sampling; retire clearly worse arms.

Most games go to strong variants while the rest stay measured. In our case many offline gains (small eval-score gaps between checkpoints, search versus no search) did not hold on the live ladder.