MTG Deck Lab
Builds Magic: The Gathering Commander decks as an optimisation problem: a mixed-integer program picks 99 cards for a commander, bracket and budget, then a Monte Carlo simulator goldfishes the result ten thousand times.

The constraint
Commander deckbuilding is a constrained search: 99 singleton cards, a colour identity, a power bracket the table agreed on, and a budget. People do it by intuition and spreadsheets, and the result is rarely checked before it is played.
The approach
Model the deck as a mixed-integer linear program with constraints for colour identity, bracket and budget. Combos flagged by the Commander Spellbook estimator are forbidden outright, so a deck cannot drift above its bracket. All eight budget tiers are solved together so each cheaper deck is nested inside the next.
- 1Constraints, not heuristics
Wrote the rules of a legal, on-bracket deck as constraints, so the solver cannot return one that breaks them.
- 2Nest the budgets
Solved every budget tier together so upgrading a deck is adding cards, not rebuilding it.
- 3Simulate before trusting
Goldfished every deck ten thousand times to check it actually curves out the way the model claims.
Outcomes
- Eight nested budget tiers from one solve
- Bracket-breaking combos excluded as hard constraints
- A 10,000-game goldfish simulation for every deck
- Forty decks each for two commanders
Built a Commander deck optimiser as a mixed-integer program with nested budget tiers and bracket constraints, verified by a 10,000-game Monte Carlo simulation.
Related projects
- Read
Verso
A diary for artworks — Letterboxd where the unit is an individual work, not a visit. Offline-first capture over a real catalogue of 10,000 works currently on view at The Met.
- Read
FraudStream
A production-grade streaming pipeline that scores financial transactions for fraud in milliseconds rather than hours, built on Kafka, Spark Structured Streaming, and a Snowflake medallion warehouse.
- Read
trading-bot
An Alpaca paper-trading bot built to answer one question — can a retail momentum system beat the market? — and the measurement work that showed the answer is no. Over 2020–2024 the best validated strategy returned +16.3% against SPY's +95.3%.