pkmn.ai

Loxias @ b92dbdf

View diff

Agents for Gen 1 OU (RBY) and VGC (Champions Reg M-C), trained with reinforcement learning only: PPO self-play, no imitation of human logs. The two formats share the method but use separate engines and models. The project also runs bots on pkmn.bot and vgc.bot.

Setup

  • Engine: custom Rust Gen 1 battle engine for RBY; pikapro for VGC.
  • Hardware: one RTX 5090 per format on vast.ai.
  • Algorithm: PPO self-play.
  • Formats: for RBY, 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. For VGC, Reg M-C with open and closed team sheets.

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.

The VGC model adds a team-preview head and chooses its two active slots jointly.

Model sizes (width × layers, parameters), in training order
NameRBYVGC
n64 × 2, 0.13M96 × 3, 0.4M
xs128 × 4, 0.6M128 × 4, 0.8M
s192 × 6, 1.9M192 × 6, 2.3M
m256 × 8, 4.4M256 × 8, 5.0M
l384 × 8, 9.8M320 × 10, 9.4M
xl384 × 12, 14.6M448 × 12, 21.3M

RBY Loxias 0.0.0 uses a model of size l. VGC Loxias 0.0.0-vgc uses a model of size xl.

Distillation

Each size is initialised from the previous best model:

  1. Online distillation, ~4–10M 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–5M 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 for RBY and 1.7 billion for VGC, across all sizes; the larger runs are 300M+ 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. For RBY, many offline gains (small eval-score gaps between checkpoints, search versus no search) did not hold on the live ladder.