Research · Experiment design (pre-registered 3 Nov 2026) · 20 min read
A Self-Play Bot for Competitive Pokémon
The full methods plan for a bot that learns to play Pokémon VGC doubles by playing against itself, on one laptop: what I'm testing, how the network and training work, how teams get built, and how I'll judge the results, written down before any of them exist.
Design pre-registered · kept as written · first results now on felipemolino.com
Summary
- The goal: a bot stronger than the #1 Reg M-C ladder bot (closed source, about 1,857 Elo), trained on a single Apple M4 Mac.
- What exists today: an engine I built that searches several turns ahead inside the real battle simulator and judges positions with a small gradient-boosted tree model on 24 hand-made features (72.3% holdout accuracy at predicting the winner).
- What I'm building: a 4–5M-parameter transformer that reads the whole board, with a damage calculator and speed order wired in as inputs. It learns to play purely by self-play (PPO against a league of its past versions), then plugs into the existing search as both the move prior and the position judge.
- Team building, too: a matchup head scores two team sheets against each other in milliseconds, and a local search with simulated annealing uses it to build teams from scratch or around a named Pokémon.
- Judged against a protocol fixed in advance: five hypotheses, pass marks for every stage, mirrored matches with confidence intervals, eleven ablations, a human study with expert players, and 18 threats to validity each with a planned mitigation.
- Status: this design is dated and pre-registered, and is left exactly as written. Since then: pretraining and a 120-hour self-play run are done, a smaller 2.3M-parameter network replaced the planned size after it matched a 5.5M one on holdout, and one pre-registered gate failed and is reported as a fail. Results so far.
01Before → now
VGC doubles is a hard game for AI. Both players choose at the same time, each Pokémon has about 30 options per turn, the opponent's exact stats are hidden, and damage rolls, accuracy and critical hits add luck. Before this project I had already built two players for it. This experiment keeps what works (the search in the real simulator) and replaces the parts that were hand-made.
| Part | Before | Now (this design) |
|---|---|---|
| Player | v1: a frozen, hand-tuned heuristic that samples one turn and scores outcomes greedily. Current engine: a multi-turn search inside the real Showdown simulator. | Hybrid: the same search, guided by a trained network for both move suggestions and position judgement. |
| Evaluator (who is winning?) | A small gradient-boosted tree model (GBDT) on 24 hand-made features such as Pokémon alive, HP, boosts, speed advantage, Tailwind and Trick Room. 72.3% holdout accuracy, log loss 0.508. | A transformer value head that reads every Pokémon, the field and both sides as tokens, with damage and speed matrices between Pokémon as attention biases. Target: beat the GBDT on the same holdout. |
| Policy (which moves to consider?) | Hand-built: opponent replies weighted by move frequencies from ladder games, adapted to the player's habits, times a fast damage and utility score. | Learned by self-play only: a joint doubles action head, a team-preview head, never trained to copy human clicks. The ladder-frequency prior stays only as an ablated fallback. |
| Search | Iterative deepening in the real simulator (up to 8 turns ahead), sampled opponent replies, a 2.5 s budget per decision, adaptive up to 6 s in critical turns. | The same search, with the network as leaf value and as the prior for candidate screening and opponent replies. It averages over 16 sampled guesses of the opponent's hidden stat points, with an optional regret-matching solve at the root. |
| Hidden information | Spread inference: an existing module (which also hosts the damage calculator) keeps a posterior over the opponent's hidden stat points. | The same inference feeds the network expected stats plus their uncertainty, and the search samples worlds from it. |
| Team building | A library of 500 tournament teams (1,500 variants, weighted by results) and a 100-player Swiss tournament pipeline: teams are judged by hours of simulated play. | A matchup head scores two sheets in milliseconds; local search with simulated annealing builds teams from scratch or around a core; the best are verified by full-search play. |
| Evaluation | Evaluator holdout accuracy and log loss by turn; tournament runs and review of play and decision logs. | A pre-registered protocol: mirrored matches, Wilson confidence intervals, Bradley-Terry ratings, calibration, eleven ablations, an exploiter, and a human study with consent. |
02Hypotheses
- H1. A full-board neural evaluator predicts the winner better than the current 24-feature tree model (72.3% holdout, log loss 0.508).
- H2. Self-play on a laptop-class machine reaches useful strength if games are cheap: policy from self-play only, plus outcome pretraining on real games.
- H3. My multi-turn search, played out in the real simulator, with the network as policy prior and leaf value, beats both the network alone and today's engine. At equal time it also beats the one-turn (1-ply) search used by the ladder-leading bot.
- H4. Explicit mechanics inputs (damage calculator, speed order, support state) cut the number of self-play games needed for a given strength.
- H5. A network trained on varied and partly random teams can score unseen teams from their sheets alone, accurately enough to build winning teams from scratch. This is checked against simulated matchups and against real tournament placements.
03Baselines
| ID | Player | Notes |
|---|---|---|
| B0 | Random legal | Sanity check |
| B1 | Heuristic (v1) | Hand-scored greedy player, already built |
| B2 | Current engine | Multi-turn search in the simulator, GBDT evaluator, 2.5 s budget, adaptive to 6 s |
| N | Network alone | Policy argmax or sampled, no search |
| H-v | Engine + network value | The network replaces the GBDT at the leaves of the search |
| H-vp | Full hybrid | Network value plus policy prior for screening my candidates and the opponent's replies |
| X | External | The #1 Reg M-C ladder bot (Bo1, open-sheet challenges) and a published open-source bot (Bo3, open-sheet challenges) |
04Data
| Set | Size | Use |
|---|---|---|
| Real Bo3 open-sheet replays, rated 1300+ | 6,044 games (about 1,250 at 1400+, 297 at 1500+, 40 at 1600+) | Value and auxiliary pretraining, holdout, calibration |
| Real Bo1 replays, rated 1592+ | 5,872 games | Value and auxiliary pretraining (team sheets mostly absent, so reduced inputs) |
| My own games | 81 | Analysis only |
| Engine self-play and simulated games | ~14k, plus new runs | Value pretraining, flagged as simulated |
| Self-play (new) | Tens of millions of games | Reinforcement learning |
- Positions. A dump step writes one row per turn: game id, source, rating, turn, holdout flag, outcome label and the position.
- Holdout. A hash of the game id mod 5 == 0, identical to the split the current tree model was trained on. Only real games are used for calibration. (Section 16 tightens this to a split by set and player.)
- Human tendencies are never a training target. Real replays supply outcome-type labels only: winner, damage dealt, KOs, survival, game length. The policy is learned purely by self-play. My rule: learn what wins, not how people click.
- Manifest. A data manifest lists counts by source, format and rating band, the open-sheet share, pull dates and file hashes.
05State representation
The network's input is a set of tokens, one per entity: 12 Pokémon tokens (6 per side), 1 field token, 2 side tokens and 1 summary (CLS) token, for 16 tokens in total. Each token is learned embeddings concatenated with numeric features, projected to the model width. The perspective is always "self = side 0"; the sides are swapped for the opponent, and the value's antisymmetry (my win chance = 1 − theirs) is enforced by training on both perspectives.
Pokémon token: identity (learned embeddings)
| Field | Dim (proposed) | Notes |
|---|---|---|
| Species / form | 64 | Base form plus a "Mega forme available" link; the Mega species embedding is also fed when the Pokémon can Mega Evolve |
| Ability | 32 | Current ability; the Mega ability is a separate slot while Mega is pending |
| Item | 32 | "None", "consumed" and "knocked off" are distinct ids |
| Moves ×4 | 64 each | Plus per-move numerics (below) |
| Nature | 8 | Also folded into the stats |
Pokémon token: numeric state
| Group | Features | Encoding |
|---|---|---|
| Stats | HP, Atk, Def, SpA, SpD, Spe: actual values at level 50 | /200. For the opponent: expected value under the stat-point posterior, plus its standard deviation |
| Mega-forme stats | The same six, if the Pokémon can Mega Evolve | 0 otherwise |
| Types | Current types (2 × 18 one-hot); Mega types if pending | |
| HP | Fraction: exact for my side, 1% buckets for the opponent (as shown in game) | |
| Presence | Alive, active slot (none / left / right), brought (yes / no / unknown), revealed | Which four the opponent brought stays hidden until seen |
| Stat stages | Attack, Defense, Sp. Atk, Sp. Def, Speed, accuracy, evasion, each −6…+6 separately | /6. Drops and boosts both kept, no clipping |
| Status | None / paralysis / sleep (turns asleep, min and max turns left) / burn / poison / toxic (counter) / freeze | One-hot plus counters |
| Volatiles | Protect streak, Fake Out available, Encore and Taunt (turns), choice lock (which move), Substitute (HP), confusion, Leech Seed, Perish count, trapping, Disable, Destiny Bond, Salt Cure, Yawn, Helping Hand received | Binary or count |
| Mega | Can Mega Evolve, is Mega, side has used its Mega | |
| Knowledge | Item known or consumed, ability known | All known under open sheets for both sides; kept for Bo1 data |
| Speed context | Effective speed now (Tailwind, paralysis, Choice Scarf, stages, weather and terrain abilities); priority moves available (count, best power) |
Per-move numerics (×4 per Pokémon)
Base power; accuracy (after No Guard or Compound Eyes); type; category (physical, special, status); priority; target class (single, spread, ally, self, field); PP fraction; disabled; flags (contact, sound, punch, bite, pulse, protect-breaking, high crit, recoil, drain, pivot, setup, recovery); and "blocked right now" flags (Psychic Terrain against priority, Armor Tail, Dazzling and Queenly Majesty, Prankster against Dark types, type immunities).
Support tags (per Pokémon, binary plus "usable now")
Fake Out · Follow Me and Rage Powder · redirection (Lightning Rod, Storm Drain) · Helping Hand · Wide Guard and Quick Guard · speed control (Tailwind, Trick Room, Icy Wind, Electroweb, Thunder Wave) · sleep (Spore, Sleep Powder, Yawn) · paralysis spreaders · Intimidate · pivots (Parting Shot, U-turn, Volt Switch) · Encore · Taunt · screens · weather and terrain setters · setup moves · recovery · Perish Song · Imprison.
Pairwise mechanics: damage and speed matrices
This is the design's main edge: the ladder-leading bot has no damage calculator. These numbers come from the existing damage calculator under the current field.
- Damage matrix. For each attacker on my side and defender on theirs, and the reverse: the best move's min and max damage %, P(OHKO), P(2HKO), and the best spread move's damage. That is 2 × 36 cells × 5 numbers. The cells feed the Pokémon tokens as attention biases (relative features) and are also pooled into each token.
- Speed matrix. For each pair: outspeeds, ties or is slower now, and under Tailwind or Trick Room flips, plus the priority bracket.
- Cost. About 72 calculator calls per state, cached by (set, set, field, stages). The measured cost is reported in P0; if it is too slow, the cells are restricted to the active Pokémon against all others.
Field and side tokens
06Actions and output heads
- Per slot. Four moves × valid targets (foe left, foe right, ally, self or none), each with and without Mega, plus a switch to each benched Pokémon, plus pass: about 30 entries, with a legality mask taken from the simulator's request.
- Joint doubles action. Slot 1's logits first, then slot 2's logits conditioned on slot 1 through a pairwise bilinear term. Illegal pairs (double Mega, both switching to the same Pokémon) are masked. This follows a design published for the ladder-leading bot.
- Team preview head. Scores all 90 plans (which four to bring, which two to lead) from the preview state, which is both team sheets. It is trained by self-play outcomes like the rest of the policy.
- Matchup head (for team building). Sees only the two team sheets, with no battle state, and predicts P(sheet A beats sheet B) when both sides play well. Its target is the self-play game result plus the running empirical win rate of that team pair. A team's strength against the field is then the usage-weighted average of this head over the field, computed in milliseconds instead of hours of simulation.
07Model
| Setting | Value (proposed) |
|---|---|
| Architecture | Transformer encoder, pre-LayerNorm |
| d_model / layers / heads / FFN | 256 / 6 / 8 / 1024 |
| Parameters | ≈ 4–5M (the ladder-leading bot: 8.7M; a published open-source bot: 1.5M). Fits a 16 GB M4 with large batches |
| Pair features | Damage and speed matrices as learned attention biases between Pokémon tokens |
| Heads | Policy, team preview, value P(win), matchup, auxiliary (below) |
| Auxiliary heads | Next-turn damage per active pair; KO within 1 or 2 turns per Pokémon; turns survived per Pokémon; turns until the game ends; next weather or terrain; next-turn status applied. The idea follows a published open-source bot |
| Loss weights | Policy 1.0 (RL), value 0.5, auxiliary 0.1 each |
| Precision | fp16 / bf16 on Apple's GPU (MPS), fp32 master weights |
| Framework | PyTorch with the MPS backend, CPU fallback |
08Training pipeline
Five stages, each with a gate that has to pass before the next one starts.
P0 · Infrastructure and tests (about a day of build)
- Simulator workers in Node. Direct battle objects with no protocol streaming. They handle batched observation encoding, legal-action masks and stepping.
- A Python learner runs inference and PPO on the Mac's GPU, and talks to the workers over shared memory or pipes with binary batches.
- Tests that gate the next step:
- The encoder matches the simulator on 1,000 random states, including HP, stages, volatiles and Mega.
- Over 100,000 random decisions, every action the mask allows is accepted by the simulator, and every action it rejects is masked (Mega once per battle, targets, switch rules).
- Mega-forme import is regression-tested against an earlier bug, where a Mega forme named in the team text started the battle already Mega Evolved.
- The damage-matrix cache gives the same answer as a direct calculation.
- Throughput benchmark with the network on 8 workers. Gate: at least 50 games per second. Below that, shrink the model or the features before running.
P1 · Outcome pretraining on real games (hours)
- Trains the value and auxiliary heads only, on the real and simulated positions from section 4. Bo1 positions without sheets use masked set fields.
- Gates: holdout log loss below 0.508 and accuracy of at least 72.3% (beat the tree model), reported per turn; calibration measured by Brier score and ECE for each phase of the game (turns 1–3, 4–6, 7+).
P2 · Self-play reinforcement learning (3–5 days, unattended)
| Setting | Value (proposed) |
|---|---|
| Algorithm | PPO with a league of past snapshots |
| Reward | +1 win, −1 loss, at the end of the game only |
| Parallel battles × steps | 2,048 × 32 = 65k samples per update (the ladder-leading bot used 8,192 × 32; scaled down for memory) |
| Epochs / minibatch | 3 / 8,192 |
| Optimiser | AdamW, learning rate 3e-4 with cosine decay to 3e-5, weight decay 0.01, gradient clip 1.0 |
| PPO clip / value coef / entropy | 0.2 / 0.5 / 0.01 annealed to 0.002 |
| γ / GAE λ | 1.0 / 0.95 (short games, terminal reward) |
| Early stop | Target KL 0.02 per update |
| Opponents | 50% current policy; 40% past snapshots weighted by PFSP, (1 − p_win)²; 10% fixed anchors (the v1 heuristic and frozen early checkpoints) |
| Snapshots | Every 2M games; keep 30 (oldest pruned, except anchors) |
| Teams | See section 9: library teams, set mutations, species swaps, random legal teams and my own Azumarill team |
| Mutation | Set level: 1–3 changes (move, item, ability, nature, stat-point spread). Species level: replace 1–2 Pokémon with a legal set drawn by usage. Every team is validated against Reg M-C (species, moves, items, Item Clause, one Mega per battle); illegal draws are resampled |
| Hidden information | The opponent's stat points are sampled from the spread prior each game; the network sees expected stats plus uncertainty |
| Value-head anchor | Keep 10% real-game positions in each update to stop value drift (to be validated) |
- Checkpoint evaluation: every 4 hours, 1,000 mirrored games against the v1 heuristic, previous checkpoints and frozen anchors. Every 12 hours, 200 mirrored games against the current engine.
- Monitoring: a dashboard in my app shows games, updates, win rates against anchors, Elo, entropy and KL.
- Collapse alarm: if the win rate against v1 drops more than 10 points, or entropy collapses, roll back to the last good checkpoint and lower the learning rate.
P3 · Search-guided refinement (1–2 days)
- The full hybrid search plays games at a reduced budget (0.5–1 s per decision). In effect this is expert iteration, similar to the search-guided games used by a published open-source bot.
- Targets: the policy learns the search's visit and weight distribution; the value learns a 50/50 mix of the search-backed value and the final outcome (proposed).
- Expected volume: 50,000–200,000 games.
P4 · Integration and evaluation
- The network goes into the current engine as the leaf value and as the prior for candidate screening and opponent replies. The ladder-frequency opponent prior stays only as a fallback, and is ablated.
- World sampling over hidden stat points: 16 by default, ablated against 4 and 64.
- An optional root solve with regret matching over the top 8×8 joint actions, compared against the current successive-halving ranking.
09Team sampling
Tournament fields work as they do now. The library has 500 teams and 1,500 variants from regional tournaments and public team databases, weighted by results. A field has 25 fixed seats; the rest are drawn by weight and swapped until the usage of the top 30 Pokémon is within about 1 point of the weighted target.
Self-play team mix (proposed)
| Share | Source | Why |
|---|---|---|
| 45% | Library, weighted by results (same weights as tournament fields) | Learn the real meta |
| 20% | Library with set mutations | Understand set changes (move, item, spread swaps) |
| 15% | Library with species swaps (1–2 Pokémon replaced) | Understand new compositions, needed to build teams from scratch |
| 10% | Random legal teams: 6 usage-weighted Pokémon with sets from the library or common sets | Cover team space far from the meta, so team search can't exploit regions the network has never seen |
| 5% | My own Azumarill team family | Always well represented: a reference team for evaluation and tuning that becomes optimized over time (below) |
| 5% | Library, uniform (not weighted) | Keep rare teams in play |
- Opponents are drawn the same way, so every team type also faces the weighted meta.
- The Azumarill share evolves. Phase 1 (from the start of P2): the 5% is my exact current sheet (Rillaboom, Incineroar, Garchomp, Azumarill, Vivillon, Raichu). Phase 2 (once the team builder passes T1 and T2): 1% stays the original sheet, frozen as the reference, and 4% becomes the team builder's current best "build around Azumarill" variants. Variants can change spreads, moves, items, natures and partners, but always keep Azumarill. The family is refreshed every 4 snapshots (about every 8M games), and every variant passes the mechanics constraints below.
- Lineage is logged: what changed from which parent, so the team's evolution can be traced.
- Held-out evaluation set: 64 library teams never used in training, to measure generalisation (the published VGC-Bench work reports that more training teams help on unseen teams). Because the Azumarill team is in training, it is evaluated against held-out opponents.
Spread mechanics constraints
Some stat totals must hit exact numbers for an item or ability to work. They are enforced as hard constraints by the validator and the spread optimizer, not left for the optimizer to discover.
- Belly Drum + Sitrus Berry: max HP must be even. Belly Drum removes floor(maxHP/2), and Sitrus activates at HP ≤ maxHP/2; with odd HP the user is left 1 HP above the threshold and the berry never fires. Verified in the simulator on my Azumarill: 202, 204 and 206 HP activate, 203 and 205 don't. The current 29 HP points (204 HP) is correct.
- Scope: only sets that run an HP-cost move or Substitute. For any HP-cost move (Belly Drum ½, Fillet Away ½, Clangorous Soul ⅓, Substitute ¼, Ghost-type Curse ½, Mind Blown ½) paired with a pinch berry (Sitrus ½; Figy, Wiki, Mago, Aguav, Iapapa ¼; Liechi, Salac, Petaya and others ¼), the HP stat is checked so the berry activates on the first use. Each pair's threshold is computed exactly in the simulator.
- Substitute (verified in the simulator) costs floor(maxHP/4) and fails at HP ≤ maxHP/4.
- No berry: max HP should not be a multiple of 4. A multiple of 4 allows 3 Substitutes from full HP; 4n+1, 4n+2 and 4n+3 allow 4 (192, 196, 200, 204 HP give 3; 193–195 and 201–203 give 4).
- With a ¼ pinch berry (Liechi, Salac, Petaya and similar): max HP should be a multiple of 4, so the berry activates after the third Substitute with ¼ HP left. With 4n+1 it activates only after the fourth, at 1 HP.
- With Sitrus: 4n+1 or 4n+2 gives 5 Substitutes with Sitrus eaten after the third; 4n gives 4, with Sitrus eaten after the second.
- The optimizer picks the HP total by the set's goal (most Substitutes vs berry timing) and reports it.
- More number-tied constraints get added as they are found, for example Life Orb and recoil survival, a Substitute surviving a set hit, and Speed benchmarks (ties, Tailwind, Trick Room minimums). Each is verified in the simulator, not assumed.
10Team building
Goal: the highest expected win % against the usage-weighted field. Two kinds of request: build a team from scratch, or build around a constraint, such as "with Azumarill", "Azumarill + Rillaboom" or "no Incineroar".
- Candidates. Library teams, constraint-filled cores (the core plus partners drawn by usage and synergy) and random legal teams. Every candidate passes the Reg M-C validator.
- Fast scoring. The matchup head against all 500 library teams. Score = Σ usage weight × P(win). The worst 5 matchups and the spread are reported too.
- Search. Local search that swaps one thing at a time (a Pokémon, set, move, item, nature or spread) and keeps changes that raise the score, with several restarts and simulated annealing (sometimes keeping a worse change early, so the search doesn't get stuck on a poor team). Item Clause and the one-Mega rule are enforced, and spreads are tuned to benchmark calculations under the spread rules.
- Verification (slow). The top 10–20 teams go through full hybrid-search play: mirrored matches against the top 50 library teams, then a 100-player Swiss. This guards against teams that only exploit the network's blind spots.
- Report for each built team: win % against the field (fast and verified), best and worst matchups, game plan and leads per archetype, and why it loses its worst matchups, from the auxiliary heads and the decision logs.
- Human test. The best teams are played by and against members of a World Cup team.
Validating the team evaluator
11Evaluation protocol
- Mirrored matches. Each team pair plays both seats with the same seeds, so team strength cancels out.
- Metrics: win rate with a 95% Wilson confidence interval; Bradley-Terry / BayesElo ratings across all players; per-turn value calibration (Brier, ECE) on held-out real games; agreement with a 30-second reference search; opponent-reply coverage, the share of real opponent actions that fall inside the screened set (a prior analysis measured 62%); and decision latency.
- Sample sizes. Detecting 55% vs 50% (α 0.05, power 0.8) needs about 1,500 games in mirrored pairs; detecting 60% needs about 400.
- Time-budget curve. Strength against budget at 0.5, 1, 2.5, 6 and 15 s per decision, for the current engine and the full hybrid. This decides whether to raise the 2.5 s default.
- Tournament check. 100-player Swiss runs on the existing pipeline with my team: qualitative play review plus the decision log.
- External. Showdown challenges from a clearly disclosed bot account, planned only after the internal gates pass: the #1 ladder bot in Bo1 with open sheets, and a published open-source bot in Bo3 with open sheets. Target at least 50 games each; ladder play optional.
- A/B test of an AI game plan. The same Swiss field with and without an LLM-written team-preview plan for my seat (full hybrid + plan vs full hybrid).
Human evaluation: expert players vs the bot
The main human benchmark: members of a World Cup team play the bot through my app, under tournament conditions.
- Bo3 with open team sheets
- Their own teams, or teams picked from a list
- The in-game timer
- The bot plays the final configuration at its normal budget, with a team from the evaluation set or one the players pick
- Full replay, decision log and the bot's win % estimates
- Pseudonymous player id, team and result
- A short survey after each set: perceived strength, best and worst decisions, and whether it "played like a human"
- Set and game win rate with confidence intervals
- Win rate by player
- An Elo estimate anchored to the players' known ratings
- The bot's calibration against real outcomes
- Expert annotation of critical turns
- Players agree to recording and anonymised publication
- Nothing is posted to Showdown under their names
- Target: at least 30 sets, a few per player; bot-vs-bot numbers carry the fine-grained comparisons
The study needs a human-vs-bot battle page in the app, a team-sheet display, a decision timer, the Bo3 flow, the post-set survey, and an export for the paper's dataset.
12Ablations
Each runs at reduced (pilot) scale, with mirrored games and confidence intervals.
- Evaluator: 24-feature GBDT vs GBDT with expanded features vs the network after P1 only vs the network after P2 and P3.
- Inputs: without the damage and speed matrices; without support tags; boosts clipped (the old way) vs full stages.
- Auxiliary heads on vs off.
- Pretraining: P1 outcome pretraining on vs off.
- League: PFSP league vs pure self-play.
- Team mutation at 0%, 30% and 50%.
- Play: network alone vs current engine vs engine + network value vs full hybrid; one-turn regret matching vs my multi-turn search at equal time.
- Worlds: 4 vs 16 vs 64 sampled guesses of hidden stats.
- Time-budget curve (section 11).
- Team mix: with vs without species swaps and random legal teams, measured by T1 and T2 accuracy on unseen teams.
- Team search: matchup-head scoring vs simulation-only scoring at equal wall-clock time.
13Success criteria
| Stage | Pass if |
|---|---|
| P0 | Tests 1–4 pass; at least 50 games per second |
| P1 | Holdout log loss below 0.508, accuracy at least 72.3%, ECE ≤ 0.03 on the real holdout |
| P2 | The network alone beats the v1 heuristic at least 80% of the time, and scores at least 50% against the current engine by day 3 |
| P4 | The full hybrid scores at least 55% against the current engine (n ≥ 1,500 mirrored games), and at least as well as the network alone on the held-out team set |
| External | At least 50% against the #1 ladder bot over at least 50 games (a stretch goal: it is still training) |
| Human | At least 50% set win rate against World Cup team members over at least 30 sets |
| Team building | T1 correlation ≥ 0.7; T2 rank correlation clearly above 0; built teams beat the library's top 20 on average in verified play; T4 built Azumarill team at least as good as the current one |
14Reproducibility and operations
- Configs are versioned files holding every proposed value on this page. Every run writes its config, git commit, data-manifest hash and seeds next to its outputs.
- Checkpoints are saved with metadata (games, updates, evaluation results), about 20 MB each.
- A dated lab notebook gets one entry per experiment: question, setup, result, conclusion. It includes negative results and bugs found, such as a sampling-order bug, Intimidate into Defiant, Armor Tail against Fake Out, and the Mega-forme import bug.
- Git commits at each milestone, for the paper's record.
- Hardware: Apple M4, 10 cores (4 performance + 6 efficiency), 16 GB. Eight simulator workers, plus the learner on the GPU with the remaining cores.
- Running unattended: plugged in and kept awake for the run; training resumable from the last checkpoint; about 5 GB of disk for checkpoints and buffers; throughput logged hourly so thermal throttling shows up as a drop.
Timeline (wall clock)
| Step | Duration |
|---|---|
| P0 build and tests | About 1 day |
| P1 pretraining | Hours |
| P2 self-play | 3–5 days, unattended |
| P3 search-guided refinement | 1–2 days |
| P4 evaluation and ablations | 1–2 days |
15Risks and fallbacks
| Risk | Fallback |
|---|---|
| Throughput below 50 games/s | A smaller model (width 192, 4 layers); damage matrix restricted to the active Pokémon; more cores to the workers |
| PPO instability or collapse | KL early stop, a lower learning rate, roll back to the last good snapshot |
| Numerical issues on the Mac GPU | fp32 or CPU for the affected operations |
| Overfitting to library teams | Mutations, the held-out team set, the uniform sampling share |
| Open sheets vs the ladder bot's closed-sheet ladder | Challenges with open sheets on, which it accepts; closed-sheet support is future work |
| Value drift during self-play | The real-game anchor share; recalibrate on the real holdout |
16Threats to validity and mitigations
A review of this plan, done on the day it was written, found 18 ways the results could mislead. Each now has a mitigation in the plan.
| # | Flaw | Mitigation |
|---|---|---|
| 1 | Holdout leakage. The split is by game id, but Bo3 games from one set, and the same players and teams, land in both train and holdout. | Split by set and player (and by team for the team-building tests). Recompute the tree-model baseline on the new split. |
| 2 | Label noise. Forfeits, timer losses and disconnects end games early. | Decided on 3 Nov, before any P1 results: keep forfeits as real outcomes, because players forfeit when they expect to lose (in a data check, the forfeiting player was behind on faints in 84% of cases). Timer losses and disconnects are excluded, because they say nothing about the board. P1 still reports the all / forfeits kept / both excluded ablation. |
| 3 | One RL run is an anecdote. Run-to-run variance can exceed the effects being measured. | Key configs run with 3 seeds at pilot scale and the spread is reported. The full 5-day run is the final config only. |
| 4 | Tuning on the test set. | Separate validation (32 teams) and test (64 teams) sets; the test set is touched only for final numbers. |
| 5 | Correlated verification of the team builder. Teams scored by the network and then "verified" by a search that uses the same network share its blind spots. | Verify with (a) the engine without the network, (b) a network from a different seed, and (c) humans. |
| 6 | Static-field optimisation. Teams optimised against a fixed field exploit it, while a real meta adapts. | Counter-team loop: after building the best team, build the best counter to it, add both to the field, and repeat. Report win % against the adapted field as well as the original. |
| 7 | Exploitability is unmeasured. Beating fixed opponents isn't the same as being hard to exploit, and humans find patterns. | Train an exploiter (a best response against the frozen bot, about a day); its win rate measures exploitability. Use mixed (randomised) strategies at team preview and in close decisions. |
| 8 | No Bo3 adaptation. Humans adjust between games; the bot forgets everything. | Bo3 memory: carry revealed stat-point information, the opponent's brings and leads, and observed tendencies into games 2 and 3; ablate it. |
| 9 | Endgames are approximated. Small endgames can be solved exactly. | An exact endgame solver for 2v2 and smaller, enumerating damage rolls (a published open-source bot matched a strict solver within about 0.5%). |
| 10 | Simulator fidelity. The simulator's implementation of this format may differ from the real game, and my encoder has had bugs. | The P0 encoder and legality tests; a pinned simulator version; a known-differences list; human games checked for disagreements. |
| 11 | Throughput is unproven. Python↔Node transfer and 72 damage calculations per state could dominate. | The P0 benchmark is a gate; profile the calculator cost; cache by (set, set, field, stages); fall back to actives only. |
| 12 | Unfair comparison with the ladder bot. Different compute, sheet setting (it plays closed sheets on the ladder) and team choice (it plays its best teams). | Report compute, time per move and team choice next to results; challenge with open sheets on; also play it with its own preferred teams. |
| 13 | Small external samples. 30 human sets and 50 games against the ladder bot give wide confidence intervals. | Pre-stated as qualitative and confirmatory; the fine-grained claims rest on bot-vs-bot games (n ≥ 1,500). |
| 14 | Human-study biases. Players learn the bot over sets, get used to the interface, and vary in motivation. | Practice games excluded; counterbalanced order if versions are compared; players blind to the version; the same timer as in tournaments; set number recorded to measure learning effects. |
| 15 | An unattended 5-day run on one Mac. Sleep, crashes, thermals. | Keep-awake, a watchdog with auto-resume from the last checkpoint, hourly checkpoint backup, a throughput alarm. |
| 16 | GPU nondeterminism. Runs on the Mac GPU can't be reproduced bit for bit. | Log seeds and versions; report variance rather than claiming bit-exactness. |
| 17 | Hindsight bias. Changing goals after seeing results. | Pre-registration: this document is dated and committed before P2 starts; deviations are logged in the notebook. |
| 18 | The biggest lever is out of scope: simulator speed (the ladder-leading bot reports a simulator about 650× faster). | Future work: a faster simulator or a cut-down rule engine for self-play. P0 records where time is spent, so the gain can be estimated. |
AHyperparameters in plain terms
All values are proposed starting values, to be tuned in a short pilot (day 1 of P2) and recorded in the notebook.
| Setting | Value | What it means | Why this value |
|---|---|---|---|
| d_model | 256 | How many numbers describe each Pokémon inside the network: the size of its "notes" on each one | Big enough for species, moves, stats and state; small enough for the Mac |
| Layers | 6 | How many rounds the network uses to compare all Pokémon with each other ("Kingambit threatens Azumarill, Raichu redirects Electro Shot…") | More rounds capture longer chains of interaction; 6 is mid-size |
| Heads | 8 | How many separate things it can pay attention to at once in each round (speed, damage, redirection…) | Standard for this size |
| FFN | 1024 | Thinking room inside each round | 4× d_model, the standard ratio |
| Parameters | ~4–5M | Total adjustable numbers: the network's capacity | Between a published open-source bot (1.5M) and the ladder leader (8.7M); fits 16 GB |
| Learning rate | 3e-4 → 3e-5 | How big each correction step is after it sees results; starts larger, shrinks | Too big is unstable, too small is slow. A standard start that decays as it improves |
| Batch (2,048 games × 32 steps) | ~65k | How many decisions it collects before each learning step | More means steadier learning; limited by memory (the ladder leader used 4× more on a big GPU) |
| Epochs | 3 | How many times it re-studies each batch | More reuses data but risks overfitting that batch |
| Minibatch | 8,192 | Chunk size per correction step | Fits the GPU's memory |
| PPO clip | 0.2 | The maximum change to its play style per update (±20% on any move's probability) | Stops one batch wrecking what it has learned |
| Target KL | 0.02 | An emergency brake: stop the update early if behaviour shifted too much | Safety against collapse |
| Entropy | 0.01 → 0.002 | A bonus for staying unpredictable and exploring | Early on, try many lines; later, commit to what works |
| γ (gamma) | 1.0 | How much a win at the end counts for earlier moves | Games are short (about 8–10 turns), so every move gets full credit |
| GAE λ | 0.95 | How it splits credit between "the win-% prediction said this was good" and "we actually won" | The standard balance between steady and accurate |
| Value coef | 0.5 | How much it cares about predicting win % compared with choosing moves | Standard |
| Aux weights | 0.1 each | How much the extra predictions (damage, KO, survival) count | Helpers, not the main goal |
| League | 50/40/10 | Who it plays: itself / past versions (more often the ones it loses to) / fixed anchors | Stops it forgetting how to beat old strategies |
| Snapshots | 2M, keep 30 | How often a past version is saved to the opponent pool, and how many are kept | Spread across training |
| Team mix | 45/20/15/10/5/5 | Section 9 | Meta realism, generalisation for team building, and the Azumarill family always present (original sheet first, optimized variants once the team builder is validated) |
| Worlds | 16 | How many guesses of the opponent's stat points the search averages over | The ladder leader's author reported blunders at 4; test 4, 16 and 64 |
| Weight decay | 0.01 | A gentle pull toward simpler solutions | Reduces overfitting |
| Gradient clip | 1.0 | Caps any single correction | Prevents spikes |
BAlgorithms glossary
- Transformer encoder
- A network that lets every token (here, every Pokémon, the field and each side) look at every other token through attention. Attention biases let known relationships, such as "this Pokémon outspeeds and OHKOs that one", steer what it looks at.
- PPO
- Proximal Policy Optimization. A reinforcement learning method that improves the policy from batches of its own games, while clipping each update so the play style can't change too much at once.
- GAE
- Generalized Advantage Estimation. A way to decide how much credit each decision gets for the final result, blending the value head's running prediction with the actual outcome; λ sets the blend.
- PFSP league
- Prioritized Fictitious Self-Play. Instead of only playing its latest self, the agent also plays saved past versions, picked more often the more it loses to them, weighted (1 − p_win)². This stops it forgetting how to beat old strategies.
- Expert iteration (search-guided refinement)
- A stronger but slower player (the network plus search) plays games, and the network is trained to imitate the search's choices and its value estimates. The improved network then makes the search stronger, and the loop repeats.
- Regret matching
- A simple game-theory solver for simultaneous moves. Each side repeatedly shifts probability toward the actions it regrets not having played, which converges toward a mixed strategy that is hard to exploit. Here it is an optional solve over the top 8×8 joint actions.
- Simulated annealing
- A local-search method that occasionally accepts a worse change, more often early on, so the search can escape a mediocre team instead of getting stuck on it.
- Bradley-Terry / BayesElo
- Rating models that turn many head-to-head results into one strength scale, where the gap between two ratings predicts the win probability between them.
- Wilson interval
- A confidence interval for a win rate that stays accurate with small samples and near 0% or 100%.
- Brier score and ECE
- Two calibration measures. Brier is the mean squared error of the predicted win probability. Expected Calibration Error checks whether, say, positions given a 70% win chance are actually won about 70% of the time.
Decide in advance what would prove you wrong, then report what actually happened. Results will be published here when they exist, negative ones included.