Bogles: a tiny model that plays Selesnya Bogles

Bogles: a 124,162-parameter policy that plays Pauper Selesnya Bogles

A tiny transformer that plays the Pauper Selesnya Bogles deck (green-white auras) in a real Magic: The Gathering rules engine (Argentum). Its only job is to kill a goldfish, an opponent with 60 Islands that never does anything, in as few turns as possible: put one creature on the battlefield, stack every aura on it, attack. The hero is always on the play.

On the 1000 test games (seeds 10000โ€“10999, run once) it wins on turn 5.646 on average, 10.8% of games by turn 4, 52.7% by turn 5, win rate 99.7%. It makes 3.08 real decisions per turn. Its companion mulligan scorer (mulligan.py) takes the keeps and London bottoms.

Watch it and the other decks' models play: the goldfish player.

Models in this repo

folder budget kill turn by turn 4 by turn 5 win rate difficulty
/ standard 5.646 10.8% 52.7% 99.7% 3.08

The model was trained with the fixed budget every deck gets, from scratch: clone the rules oracle (4000 games), label a mulligan scorer, two cycles of expert iteration (3 rounds ร— 480 games each, the mulligan scorer relabelled in between), checkpoint chosen on 1000 validation games. Games not won by turn 12 count as 13.

Bogles is decided in the opening hand: the mulligan scorer alone gained 0.42 turns over the hand-written keep rule, and expert iteration about 0.04 more.

How it decides

Every decision the rules engine asks for becomes one sequence of tokens: a global token (turn, life, lands, cards drawn and spells cast this turn, decision kind, phase, the library), one token per card you can see with its zone, and one token per legal option. A 3-layer transformer (width 64, 4 heads) scores the option tokens; the softmax runs over legal options only.

Bogles adds three things to the shared inputs:

  • extra decision kinds: target (which creature gets an aura), search (library picks) and color (Utopia Sprawl, Benevolent Blessing);
  • attachments: an aura shares a slot embedding with the creature it enchants, and a target option with its target, so the model sees which creature carries what;
  • card stats: power, toughness and can-attack on battlefield cards (added after this model was trained; its weights for them are zero, so it plays exactly as trained).

How it was trained

  1. Rules oracle. Forest first, a creature, Utopia Sprawl, then the auras on the biggest creature (an Eldrazi Spawn token is a fine host against a goldfish), each rule kept only if faster on paired validation games.
  2. Supervised cloning of the oracle.
  3. Expert iteration. At up to 8 non-obvious decisions per game, try every legal option on 4 reshuffled futures finished by the model; the fastest becomes the label; fine-tune, repeat.

Mulligan scorer

A separate MLP (mulligan.py, weights in mulligan/) predicts the mean kill turn of keeping a hand with a given set of cards on the bottom, trained on simulated games played by this model's predecessor. A mulligan is worth turn 6.59 to six, 7.08 to five and 7.87 to four (mulligan/constants.json). Keep when the best keep beats it.

Use

import sys
from huggingface_hub import snapshot_download
from safetensors.torch import load_file

path = snapshot_download("vedalken/gw_bogles")
sys.path.insert(0, path)
from model import Policy, collate, featurize

policy = Policy()
policy.load_state_dict(load_file(f"{path}/model.safetensors"))
policy.eval()
# msg = {"kind": "main", "options": [...], "state": {...}}  (an Argentum bridge request)
# logits, value = policy(collate([featurize(msg)]))

Limitations

  • Trained only against a goldfish: hexproof never matters, and it ignores blockers and removal.
  • One deck list (deck.dck, main deck only) and 12 turns maximum.
  • Attacks, mana payment and yes/no prompts are scripted by the bridge, not chosen by the model.

Files

  • model.safetensors, config.json, results.json: weights, network size and source, test summary.
  • model.py: featurizer and network with this deck's vocabulary; deck.dck: the deck.
  • mulligan.py, mulligan/: the mulligan scorer.
Downloads last month
29
Safetensors
Model size
124k params
Tensor type
F32
ยท
Video Preview
loading