Exponential Behavior in Magic: The Gathering levineuwirth.org · 18 points · 3 co...

@best

Exponential Behavior in Magic: The Gathering levineuwirth.org · 18 points · 3 comments · HN thread

TL;DR The author describes Arcana, a Magic: The Gathering rules engine they built to run reinforcement-learning experiments, and how Scute Swarm and Liliana, the Last Hope's emblem create exponential token growth that exposed performance limits. A random-play stress test on 403,200 games had nine jobs time out, and replays showed one emblem resolution taking 35 seconds at about 7,000 Zombies, with the engine's combat enumeration capped at 1,024 options.

  • Scute Swarm doubles itself on each land drop once six or more lands are present; with life-gain doublers, the author computes 6,561 Scutes and 26,240 life after eight land drops in a hypothetical setup.
  • Liliana, the Last Hope's emblem creates two plus the current number of Zombies at each end step, so Zombies follow Z(n+1)=2Z(n)+2, giving 2^(n+1)-2 Zombies after n resolutions.
  • A stress test of 64 Pioneer decks (4,032 games per pass, 100 passes) had nine games hit a two-hour cluster limit; replaying one showed a single emblem resolution taking 35 seconds at roughly 7,000 Zombies.
  • Each new Zombie's arrival triggers a scan of the whole battlefield, so the cost of resolving the emblem grows roughly quadratically with army size.
  • Arcana capped attack declarations at 1,024; with 256 eligible attackers the single-creature options consumed the cap, so the all-in attack option was never offered and the army never attacked.
  • The author added a battlefield cap of 500 permanents to the harness and proposes caching evolve checks and reserving room for all-in attacks as future engine fixes.

Discussion The comment thread is small and mostly tangential to the article's engineering details. The top comment notes that Magic is Turing complete and links the idea to the halting problem, and a reply points out that voluntary infinite loops can be a winning play while involuntary ones end in a draw. A second commenter describes a friend's independent implementation of older Magic sets with campaign and online play, citing network sync, artwork handling, and card-specific bugs, and says the game's AI struggles with many tokens and abilities under time limits. The mood is curious and appreciative, with some practical experience shared.

  • Turing completeness implies undecidable game states in theory (some): A commenter argues that because Magic is Turing complete, one will meet the halting problem in theory even if rarely in practice. This is presented as a framing of the article's exponential-growth concerns rather than a direct rebuttal.
  • Infinite loops are a deliberate strategic feature (a few): One reply notes that a voluntary infinite loop that can be stopped often wins the game for the player who controls it. An involuntary infinite loop instead ends the game in a draw, which matches the rules' handling of unbreakable loops.
  • Building a playable engine is hard, especially AI and networking (a few): A commenter describes a friend's hobby implementation covering older expansions, reporting that network synchronization, artwork rendering, and per-card bugs were the main problems. They say the AI looks only a few moves ahead and struggles with many activated abilities, and that licensing from Wizards/Hasbro is the remaining barrier.

#MagicTheGathering #Exponential #RulesEngine #GameAI #Performance