We built an AI-powered Magic the Gathering card generator

2 years ago (txt.cohere.com)

This post was originally made in 2022. In early 2023, I spent a lot of effort training a model with a new approach that made the generation quality extremely good...

Then the ChatGPT API came out and made all my effort obsolete.

In one hour, I was able to create a Notebook (https://colab.research.google.com/github/minimaxir/chatgpt_a... ) that was able to create mechanically valid and relatively balanced cards given a natural language prompt, even extremely absurd ones ("Create ten variations of Magic cards based on Spongebob Squarepants and ancient Roman history"). In all cases it's more stable and accurate than my hand-made solution.

That notebook is now obsolete too, due to ChatGPT's structured data support now allowing for even more control and stability. I need to create an updated MtG card generator at some point.

  • Yes. Very scary. This is a very good example of the speed of AI advancement. You used AI in 2022 to make a cool thing, then by 2023 GPT could do it better faster.

    Everyone is saying the AI craze is hype and already dying away.

    Meanwhile I can just talk to GPT4 conversationally and it will do a project for me in minutes that would have taken days.

    It is not hype, and change is still rapidly occuring.

    • To clarify, I'm not the author of the original article (although I was aware of the work).

      I've been working with generating AI Magic cards since RoboRosewater was popular.

  • Impressive anyway. I was looking for a deck generator that can generate standard, historic and explorer decks for MTG arena. I try to ChatGpt using context for the last sets, and prompt but quality wasn't what I was expecting. Sometime fails to add 24 lands or create decks Wich are copies of old decks. Try to fix it in prompt with no luck.

  • What structured data support are you referring to? I'm out of the loop, did they add something new in the API?

  • Still incredible in 2023. Goes to show UX and maybe first to market will be the differentiator

I’m stunned WOTC hasn’t sued them over this yet. I undertook a related project in ‘21 [0] and had two different lawyers tell me Wizards are notoriously litigious and that they’ve even come after creators of fan art in the past.

[0] https://hardwork.party/#/entropy/ … recursively-generated MTG-style cards generated by GPT-3 (not 3.5t) and VQGAN+CLIP. The recursion brings out the crazy!

I ended up scrubbing for every non-dictionary word in the MTG corpus - find a ‘nono’ word? Regenerate.

Also did cosine vector similarity on the body, title, type, and flavor text fields against existing MTG corpus to throw out anything too similar.

Also my partner on the project ZNO did all-original card BG, back, and icons.

In the end the thing was an art piece so it didn’t suffer from deviating widely from MTG, although I’d say it probably would have been a bigger commercial success as a straight imitation.

As a former MtG player I think the difficulty lies not in creating cards, but in ensuring there's a level of balance between existing cards and new sets.

  • The AI can be trained on all current MtG cards to be able to generate cards with comparable power levels intuitively. Also to generate art and lore that fits the power distribution.... Maybe it can create synergies between generated sets and combos or counters to generate more diverse and fair fights....

    I'm not sure Wizards of the coast should be excited or terrified with the possibilities

    • Wizards of the coast owns the patent on collectable cards, so they should be excited, since there's no way to break into the market without them suing you. They can fire all of their artists and save on costs, but still produce good working cards with AI.

      2 replies →

  • That is where AI-based play automation to test the cards should come in place.

    • This sort of stuff has been a thing for balancing AAA games for a very long time (it was in production over a decade ago), and is kept surprisingly secret by those doing it.

      One of the shocks of the games industry is in many respects it doesn’t learn from the wider world but in others it is quietly so far ahead that you can throw certain ML papers at former game devs to be met by confused faces as to why what is claimed is considered surprising.

      1 reply →

  Infernal Light
  2BB

  Sorcery
  Search your library for a creature card card with power less than or equal to the number of cards in your hand, put that card onto the battlefield, and then shuffle.

  The eternal flame has no fuel.

Very cool generator and it creates real-ish cards that mostly follow the color pie, but the power level is pretty bonkers for anyone that plays Magic.

I think one thing that's a challenge for a LLM is that small changes to text like "Search for a card and put that card into your hand" versus "Search for a card and put that card onto the battlefield" can have very different meanings and power levels.

  • Yeah, it's typical LLM output in that it superficially makes sense but if you actually know what you're talking about it really doesn't.

    Dark Ritual (it already exists and does something else, Storm players are super triggered right now)

    Sorcery - {B}

    You may cast a black or red instant or sorcery card from your hand without paying its mana cost. Excuse me?

    ---

    Winged Egg

    {2} Artifact Creature - Egg 0/2

    Whenever you cast a noncreature spell, put a +1/+1 counter on Winged Egg

    What? A similar effect is on Crackling Drake of UR Spells fame, going for {U}{U}{R}{R}.

    You also have a {1}{U} enchantment that makes you a 1/1 token with Flying whenever you draw a card. -- Bitterblossom already destroyed a format once :( --, and a {1}{U} instant with "untap all creatures and lands you control".

    • Well, for winged egg specifically, sprite dragon is a better card that already exists for a similar mana cost, so it's not too far out. But yeah, those other cards would never be printed.

    • Winged Egg is uncanny in exactly the same way that generated art is - the feeling is the same, it’s uncanny valley material.

  • Precisely my thoughts. The fact that this exists is so cool, but it's clear some more tuning would have to be done for "proper" balance.

    'Subterranean Crush' is exactly 'Flesh to Dust' but two mana cheaper and 'Silent Splendor' is 'Dramatic Reversal' cranked to 11. An instant include in any blue deck, I need it.

  • I suspect some fine tuning could solve this, or perhaps somehow train on 17lands.com pick orders to establish power levels?

> Magic the Gathering is a collectible card game played with two or more players. Each player starts with a deck of cards and 20 life points and uses those cards to deal damage to the opponent and reduce the life points to 0.

I would never risk the wrath of Mill and Infect players by omitting their favorite win conditions.

If you look at the rules, there are a bunch of win/lose conditions in MTG: https://mtg-archive.fandom.com/wiki/Win_Conditions

Intellectually, and as a creator, I love AI image generation. As a casual user of the internet, I'm growing more and more annoyed with it, simply because of all the times I lean in to examine an image that my visual cortex is stumbling on some part of, only to realize after a couple seconds, "oh, it's AI", and sit back up straight.

  • This is why ,as useful as they are, I also loathe llms, so much textual content is endless drivel, either fully created by AI or helpfully rewritten. Of course it's not new, but what is new (to me) is users using llms in discussion topics to either troll or to make their point, or receiving (real, work related) e-mails fixed up by chat-gpt; madness.

  • > only to realize

    All of it? Some people would immediately recognize the typical StableDiffusion output but not a Midjourney.

    • Midjourney is a limited set of models and (to me at least) much easier to spot than Stable Diffusion output, with it's giant array of custom models, LoRA's, textual embeddings and tricks like HiRes fix and upscale script.

      3 replies →

As someone who has played Magic off and on since 1997, most of these are actually quite terrible. None of them really make sense from a cost / utility standpoint. The images for the names of the cards and the flavor texts are all pretty good. But this model clearly didn't pick up enough details around the cost and mechanics.

Next step is, of course, to build an AI-powered exchange for Magic the Gathering cards. They could name it "Magic the Gathering Online eXchange" or something like that.

  • Ah MtGox, the missing (?) link between MtG and cryptocurrencies! One thing that is totally amazing is that some MtG cards went up in value by multiples similar of what's been seen on some cryptocurrencies.

    For example the very last MtG card I bought was around 2004, "The Tabernacle at Pendrell Vale". I sniped it on eBay for... 20 EUR (it's also, up until now, the highest priced card I ever bought). It's now listed anywhere from 2 000 EUR (for an "italian reprint") to 4 000 EUR (for an original "Legends", which is what I have). I mean: that's 100x to 200x.

    If only I knew back then ; )

I love that “Bad Lightning Bolt” is literally just Lightning Bolt that does one less damage.

  • It also only hits creatures rather than any target, so it’s even a bad shock!

    • Naming things is one of the two hardest parts of programming. If AI is this good at naming then I’ll be out of a job soon.

This is really cool! Would love to see a version for Pokemon and Yugioh to revive my childhood. Because the relative consistency of card formats, AI-generated trading cards seems like a great use-case, with some gaps depending on the type of card. For Yugioh, I imagine generating believable images is easier since the card art is extremely varied, but it's probably a bit harder to come up with meaningfully complex card effects/descriptions. It's probably the opposite for Pokemon, where there's a much smaller set of known Pokemon so AI-generated ones are easy to detect, but the moves that each one possesses are usually pretty simple (unless that card game has gotten way more complex from what I remember)

This is cool. There is undeniable value in LLMs for inspiration. I think they really augment well the creative tasks.

LLMs are getting a bad rep for not acrediting the authors, but the everyone cannot possibly know about every other source of information.

If you think of LLMs as general corpus of human intelligence, and how they can be used for lateral-thinking, there is nothing quite like it.

We live in unbelievable times.

I get to tell my children "I remember the days without the internet" and in the same monumental shift in history, I feel, I will also get to tell them "I remember the days when we had no AI assistance".

  • >We live in unbelievable times.

    What's also remarkable is the amount of people who refuse to believe.

    What's different this time around is that this technology represents competition to people who's intellectual abilities are tied to their career.

    Clearly it can't match a human yet. But in the last decade, if you follow the trendline, AI is slowly approaching that point of human replacement. A couple of years ago if you told me that I could step into a car without a driver and it could drive me around the city in SF I would've laughed in your face and told you the technology was a pipe dream.

    It won't be a matter of AI assisting all of us, it will be AI assisting a few of us and replacing most of us.

I found my old Gathering cards (e.G. Antiquities), and want to sell. Is there a good AI software that determines which cards are mint etc? I feel uncomfortable selling on eBay, b/c I have no clue.

  • I used to buy&sell mtg cards and some collections, depending on the time you want to invest there are different options: 1. Take everything to a local shop that buys cards, most big cities have one and they buy everything at once, but pay under market value. 2. Ebay, sell it as a single collection 3. cardmarket.com is very good, helps you grade the cards and shows accurate market values, might take time to set everything up and might result in lots of different sales, so lots of Briefen

  • First thing would be to quickly identify which cards are valuable. This can be done using phone app scanners like the TCG Player App, Delver lens etc. They auto-scan the cards in and give you a value based on the mid-price in the market. For p2p sales TCG's mid-price is usually used as the de facto value of a card.

    If you are in the USA you can send cards in bulk the CardKingdom.com. I know some people that even did this from outside the USA.

I like the corresponding white and black titans as a concept, but the implementation really needs tweaking.

Bad Lightning Bolt is so hilariously perfect that I’m surprised it isn’t already an un- set card.

It makes sense to think Wizards of the Coast when it comes to creating unlicensed physical media similar to what a company sells while also using their trademarks. A person could mess up and pick a ridiculously litigious company to do that with and invent a fine-tuned AI model that expedites getting sued by exuberant IP lawyers.

Why not allow the players to 'create' new cards on the fly and the LLM balance it automatically? So that one would feel like an 'real' wizard. Curiousy I was thinking on how to actually implement something like that tonight.

I'm surprised that they can get away with using "Magic the Gathering" in the headline and "Wizards of the Coast" in the image. I was pretty sure these would be trademarks.

The last three or four MTG sets already seem to be designed by manatees, so maybe this will save them some dosh on tank cleaning.

This is pretty cool. Though IMHO, the card Peanut Butter Jar that their AI generated should be 0/1, not 1/1.

I bet WOTC would find this very useful!

  • I am extremely confident WoTC is aware of this and is working on and/or using similar

    • I can see them using it in a purely creative context, like generating a bunch of cards and then looking for novel and interesting cards you wouldn't have otherwise though of. But designing cards is fun for a human to do and not terribly hard, so I don't think we'll see entire sets generated by AI, or even an entire card generated by AI that a human doesn't go back and balance numbers on or fine tune a mechanic.

    • Considering the amount of cards they tend to produce these days, makes you wonder if they aren't already using some kind of AI to generate a baseline of cards.