Analysing my Magic: The Gathering Commander Deck using Monte Carlo Simulations with Python

Guilherme Braga
6 min readFeb 6, 2022

So, Magic: The Gathering has kind of been a big deal in my life, especially for the last 4 years. Well, If you are unaware, MTG is a very famous Trading Card Game from the 90’s that never really died. The company behind the game is still releasing new cards to this day and players usually have meetups in every major city out there. It’s been 25 years and the game re-imagined itself a lot of times through different sets of rules and what players call formats (like Modern, Standart, Commander, Pauper). Magic has been a really satisfying hobby for me, not only because It added a new aspect to my social life, but also because the game itself is fun as hell, filled with math and strategies to elaborate. So, It felt more productive than staying home and playing video games or watching movies in my spare time. Putting It this way makes me feel like I’m a couch potato, but I swear, I am also really into jogging and other things like that, but enough about my personal life.

I’m writing this because I felt like I could make a Medium post out of my Muldrotha, The Gravide Commander deck (Commander is a multiplayer MTG format, and It is fairly popular). I will try to make this post as simple as possible to non-players, I swear. Please stick with me for this one.

So, about my deck. It is not perfect, but slowly changing It kind of was my deal for the last couple of years, and now I consider It finally completed! It’s a fairly strong set of cards to play with, not perfect (again), but strong. I picked Muldrotha as my first deck (and main deck) because I was inspired by the Commander’s Quarters video on It. The slow trial and error aspect of deck building made me a better player overall, and doing things slowly made me understand the game better because I would always play with the same deck at my local MTG Shop in Brasília, DF (Brazil).

Lately I have been wondering about how “fast” my deck could be. As in, how fast I can win in theory. Not saying that I win a lot when I play, but I have decent chances. It’s really impossible to explain the entire game right now, but basically I want to cast my Commander as fast as possible, because usually my graveyard is filled with cards I may use and that’s how this deck works. I also rely on a few combos, he he he. When I first started playing the game, I had a difficult time adjusting what is called the deck’s mana curve. Think of this as a basic game design thing: there is no free lunch. In order to cast good cards, you need to produce the necessary resources, in this game that’s what we players call mana. In order to cast my Commander, I need 3 colored mana (green, blue and black) and 3 colorless mana (I can use any color of mana for these 3). Land cards produce specific colors of mana, and a few other card types produce specific colors of mana. I have 36 lands in my deck out of 99 cards (very typical number of lands), and I can only use 1 land card per turn. A player starts a match by drawing 7 cards. I think that you can see where I’m going with this. Yes, Monte Carlo simulations with Python! Yey!

I realized that problems related to “chances of getting cards” are typical Monte Carlo simulations that could be executed with Python. I could easily adapt scripts in order to work with a MTG deck, and not a regular deck of cards. In theory, I imagine that even simplified simulations should be very insightful.

And that’s what I did with a little help from some nice resources I found online. You can check out my Python script right here.

Simulations

The first simulation should, given my deck of cards, determine the chances of us getting a good starting hand. A decent starting hand should have a few land cards, but should not have 0 or 7 lands, or even a number close to that. In this cas, balance is key. Cards like Birds of Paradise and Sol Ring are good because they generate mana, but they are not lands. Sol Ring is perfect because it produces two of that colorless mana that is needed to cast Muldrotha, and It costs one colorless mana to cast. It’s the perfect first turn thing to play. Actually, Sol Ring is a staple Commander card, almost every deck has one of those.

This is how the basic simulation looks like. Every simulation is a variation on this.

Anyway, the mana color won’t matter in this simulation, only the amount of mana produced by the initial hand (the first 7 cards of the deck). My personal experience with this deck says that the initial hand should be fine, but simulations are always welcome.

Simulation 1

Now, the second simulation will be just like the first one, but the next 3 turns will be analyzed. It means that this simulation will determine the amount of lands in the first 10 cards (you are able to draw one card per turn). I also changed the structure of the decklist for a different version of this simulation. Now It does not matter the card type, but only If it is a land, If It generates mana or If It does not generate mana.

Simulation 2(a)
Simulation 2(b)

The third simulation will keep the change in the structure of the deck list. Still, the color doesn’t matter, but If the deck is able to produce 6 mana by turn 3, chances are that It is possible to make at least one of each color necessary (cards like Evolving Wilds and Cultivate usually fix this relation between colors).

Simulation 3(a)
Simulation 3(b)
Simulation 3(c)
Simulation 3(d)
Simulation 3(e)
Simulation 3(f)
Simulation 3(g)
Simulation 3(h)
Simulation 3(i)
Simulation 3(j)
Simulation 3(k)

Conclusions

To keep It simple, all I need to understand from the simulations is that a 3 land hand is a good (maybe ideal…?) starting hand and that usually It is worth It to pick another starting hand If I only have two lands.

Simulation 2(b) is what is more important to me. The peak among probabilities go from 3/4 to 5! It shows a lot of consistency compared to what use to happen to me back when I started It! This is what the deck looks like when I’m typing this.

Thanks for reading!

--

--

Guilherme Braga

A Computer Engineer from Brazil. I write about my nerdy stuff, mostly about my experiences as an IT professional and Magic: The Gathering/boardgames.