Mindcrank: Measuring the Shape of an MTG Deck
Introducing Mindcrank#
Mindcrank is a small Rust library for running Monte Carlo simulations of Magic: The Gathering decks.
It tries to answer one question:
Given a deck with a certain mix of cards, how fast can I, on average, assemble a win condition?
Mindcrank does not play Magic or interpret rules. It doesn’t pay mana, resolve triggers, or fight through interaction. A card is a name with some free-form tags on it, and a win condition is a rule about which tags have to show up together in the cards you’ve seen.
That constraint is the point. Before modeling a full game, I wanted a more objective baseline for the raw geometry, the shape and texture, of a shuffled deck.
Background#
The first draft of this experiment was a single file I wrote to prove a point to a friend, and I wrote it up in Modeling MTG Combo Wins With Monte Carlo Simulations. It built a 99-card deck, shuffled it, drew until the win condition appeared, and repeated.
Mindcrank turns that experiment into a library. You describe a deck, a win condition, and a mulligan policy, and it runs as many seeded games as you ask for:
use mindcrank::{
Card, Deck, KeepIfWinOrDecent, MonteCarloParams, Params, TwoCardSet,
monte_carlo,
};
let mut cards = vec![Card::new("Land").with_tag("land"); 37];
cards.push(Card::new("Thassa's Oracle").with_tag("combo:oracle"));
cards.push(Card::new("Demonic Consultation").with_tag("combo:consult"));
cards.extend(vec![Card::new("Filler"); 60]);
let deck = Deck::new(cards);
let win = TwoCardSet::new("combo:oracle", "combo:consult");
let mulligan = KeepIfWinOrDecent::new(&win, 2, 4);
let params = Params::new(&deck, &win).london_mulligan(&mulligan, 3);
let result = monte_carlo(
MonteCarloParams::new(params, 100_000)
.with_seed(42)
.with_workers(0),
);
println!("win rate: {:.2}%", result.win_rate * 100.0);
Three pieces do the work here:
- Tags say what a card is for. Mindcrank never looks at the card’s name.
- The win condition says which tags have to be seen together.
TwoCardSetwants one card from each of two groups,KOfTagwants anykcards with a tag, andAnyOfaccepts whichever of several conditions comes first. - The mulligan policy says which opening hands to keep. This one keeps a hand that already wins, or one with two to four lands, and takes up to three London mulligans.
The seed matters just as much. Monte Carlo results vary from one run to the next. A fixed seed makes a scenario reproducible, so a surprising result can be rerun, tested, and compared after the implementation changes.
A Million Shuffles#
I ran two seeded scenarios with a 99-card deck and 37 lands. Each one used a million shuffled decks, no mulligans, and drew one card at a time until the win condition showed up.
| Scenario | Average additional draws | Opening-hand success |
|---|---|---|
| 2 combo pieces, 2 required | 59.66 | 0.43% |
| 4 combo pieces, 2 required | 33.05 | 2.43% |
These are draws after the opening seven. In the first scenario, both designated cards have to appear, so the average position of the second card is deep in the deck. Adding two redundant pieces cuts the average wait by about 26.6 draws and makes the opening-hand hit rate more than five times higher.
That doesn’t mean adding any two combo cards makes a real deck five times better. This scenario uses KOfTag, which treats all four pieces as interchangeable. Real combo packages have structure: A+B may win while A+A does nothing, some cards are dead outside the combo, and some lines need different amounts or colors of mana.
What the result does show is the size of the consistency gain available from redundancy. It gives us a baseline. Every real-world restriction can be layered on top of that baseline and measured as a cost.
Why Monte Carlo?#
Some of these probabilities can be calculated exactly with combinatorics. For a simple opening-hand question, the hypergeometric distribution is a better calculator than a million simulated shuffles. The table above has exact answers too: about 59.7 and 33.0 draws, and 0.43% and 2.44% of opening hands.
Mindcrank is still useful because the simple case is a proving ground. If the simulation lands on the known probability, the same engine can be extended into cases that are awkward to write as one equation.
The Thassa’s Oracle deck from the code above is a good example. It ships with the repository:
cargo run --release --example two_card_combo
Over a million games with mulligans, it finds both pieces by turn 50 in 32.84% of them. The hypergeometric odds of both cards sitting in the top 57 of the deck are (57/99)(56/98) = 32.90%. The simulation comes in a shade under, because a mulliganed hand sees fewer cards. That small gap is the mulligan rule showing up in the numbers, and it’s the kind of thing a closed-form answer gets harder and harder to carry.
The simulation also makes assumptions visible in code. A run is not just a percentage copied into a deck guide; it is a repeatable procedure with explicit inputs.
Beyond the Baseline#
Since that first version, Mindcrank has grown past shuffling and counting.
Mulligans. The London mulligan is built in, and both halves of it are replaceable: a MulliganPolicy decides whether to keep, and a BottomHeuristic decides which cards go to the bottom.
Piece identity and tutors. A Route is a named set of distinct pieces, so A+B is no longer the same thing as A+A. TutorAwareWin also counts a route as reachable when tutors in hand can cover its missing pieces, and each physical card can only be used once.
Pareto comparisons. compare_pareto runs a set of deck variants through one fixed protocol with a shared seed and scores each on two axes: the chance to win by an early turn and the chance to win by a later one. A variant is on the frontier unless another variant is at least as good on both and better on one.
Arena. The arena module races decks against each other over a balanced seat rotation. Its first model is a goldfish race. It compares when each deck gets there and doesn’t model the decks interacting.
The repository has an example that puts these together on a tournament Thrasios/Tymna list:
cargo run --release --example thrasios_tymna_cedh
Counting only naturally drawn combo pieces, the list has a line by turn 7 in 8.5% of games. Counting tutors as access to the missing piece, that goes to 63.2%. The Pareto comparison then changes one thing about the decklist at a time:
| Variant | Line by turn 3 | Line by turn 7 |
|---|---|---|
| Stock tournament list | 45.75% | 62.88% |
| Tutors replaced with inert cards | 5.79% | 10.21% |
| Two interaction slots become tutors | 55.49% | 72.87% |
These are access rates, not win rates. A tutor here is a free, instant substitute for the card it finds: it costs no mana and takes no turn. Nobody is casting a counterspell, either. So the last row doesn’t say the deck should cut interaction for tutors. It says how much raw access those two slots are worth, which is the number you’d want in hand before arguing about what the interaction is worth.
Implementation Notes#
Mindcrank is written in Rust and spreads trials across a bounded Rayon worker pool. Each trial gets its own random-number stream, derived from the base seed and the trial’s index. No generator is shared between workers, and a seeded run gives the same result on one worker or sixteen.
A game that reaches the turn limit without assembling anything is recorded as a miss, not as a win on the last turn. Averages such as draws to win cover winning games only, so they should be read next to the win rate.
Each run reports:
- the win rate, and wins and misses as counts;
- the opening-hand win rate;
- average draws and turns to win, with the full distribution of each;
- average lands in the opening hand; and
- the average size of the kept hand after mulligans.
What Mindcrank Does Not Know Yet#
The next useful step is not adding more runs. A million samples are already stable enough for these comparisons. The more valuable work is adding better rules:
- Mana: Lands, rocks, dorks, colors, and the turn on which a line is actually castable. Land count is collected today and feeds the mulligan policy, but it doesn’t decide whether a combo can be cast.
- Tutors: A tutor should take mana and a turn, and a top-of-library tutor should wait for the next draw.
- Interaction and resilience: Finding a line is different from resolving it. The arena’s next model is a coarse turn structure with threats, protection, and disruption.
Each layer makes the model more realistic, and also gives it more ways to smuggle in assumptions. The goal is not a machine that declares the correct decklist. It is a tool that lets us state a deck-building claim precisely, run it enough times to see its shape, and argue about the assumptions instead of the vibes.
Mindcrank is available on GitHub. It needs Rust 1.97 or newer.