Magic: The Gathering, Combo Graphs

Recently a friend of mine wrote a short program to find the best combination of Magic: The Gathering to fulfil a given win condition – a so-called combo – under specific constraints (no more than three cards with a total converted mana cost of not more than ⑤). This inspired me to think about finding Magic: The Gathering combos in an automated fashion.

In the general case, many useful combos contain loops – for example, one card may say “Whenever you gain 1 life, draw a card.”, while a second card may say “Whenever you draw a card, you gain 1 life.”. This kind of loop is not very useful by itself: Unless you control a Laboratory Maniac, you will lose the game on account of not being able to draw a card from your empty library after a finite amount of iterations.

Example loop (source code)

Value may be extracted from such a loop by exploiting a third card whose effect is repeatedly triggered by the loop. A third card that says “Whenever you gain 1 life, each opponent loses 1 life.” would have its effect repeatedly triggered by the loop: if all opponents have less life than there are cards in your library at the start of the loop, this combo wins its controller the game.

Example loop that triggers an effect repeatedly (source code)

I have put together a graph that includes all cards that contain “Whenever you gain life” and all cards that contain “Whenever you draw a card” from the Gatherer database of all Magic: The Gathering cards. If anyone manages to write a program to generate such graphs for arbitrary triggers, I would be interested in the source code for it.

Relationships of Magic: The Gathering cards that trigger on gaining life or drawing cards (source code)

There exist comments on Reddit for this article.