We built an AI-powered Magic the Gathering card generator

130 points by MWil 1 year ago | 87 comments
  • minimaxir 1 year ago
    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.

    • FrustratedMonky 1 year ago
      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.

      • minimaxir 1 year ago
        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.

      • lumtor 1 year ago
        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.
        • vonwoodson 1 year ago
          Amazing work. This is a real treasure. Thank you.
          • wordpad25 1 year ago
            What structured data support are you referring to? I'm out of the loop, did they add something new in the API?
          • lamroger 1 year ago
            Still incredible in 2023. Goes to show UX and maybe first to market will be the differentiator
          • doctorhandshake 1 year ago
            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.

          • xarope 1 year ago
            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.
            • dudus 1 year ago
              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

              • chii 1 year ago
                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.
                • navbaker 1 year ago
                  That patent expired several years ago.
              • mdp2021 1 year ago
                That is where AI-based play automation to test the cards should come in place.
                • oefrha 1 year ago
                  AI players, however strong, sometimes leave glaring (to humans, at least when told) loopholes exploitable by humans.

                  See for instance amateur Go player armed with loophole consistently beat top Go playing software which otherwise easily crushes world champions.[1]

                  [1] https://www.ft.com/content/175e5314-a7f7-4741-a786-273219f43...

                  • fidotron 1 year ago
                    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.

                    • flaghacker 1 year ago
                      That sounds interesting, can you give some examples? Is this limited to classical RL Q-learning type stuff for turn based games, or full AlphaStar-level agents for RTS games?
                    • xarope 1 year ago
                      would love to have AI be able to play MtG sensibly, key word being sensibly!
                      • mdp2021 1 year ago
                        Some would say that Microprose's "Magic: The Gathering 1997" aka "Shandalar" or "Manalink", from Sid Meyer, could already play decently well.
                  • clarle 1 year ago

                      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.

                    • qsort 1 year ago
                      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".

                      • gdown 1 year ago
                        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.
                        • mock-possum 1 year ago
                          Winged Egg is uncanny in exactly the same way that generated art is - the feeling is the same, it’s uncanny valley material.
                        • syldarion 1 year ago
                          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.

                          • thom 1 year ago
                            I suspect some fine tuning could solve this, or perhaps somehow train on 17lands.com pick orders to establish power levels?
                          • dxuh 1 year ago
                            > 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

                            • happytoexplain 1 year ago
                              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.
                              • MintsJohn 1 year ago
                                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.
                                • mdp2021 1 year ago
                                  > only to realize

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

                                  • DrSiemer 1 year ago
                                    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.
                                    • iinnPP 1 year ago
                                      I used SD1.5 when it came out and left it alone until a few days ago. The improvements are incredible and hard to articulate.

                                      If anyone put SD down for a good period of time, they should really give it another go. Use the full suite of options and make sure you are using a model fitted for your purpose.

                                • tstrimple 1 year ago
                                  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.
                                  • ivanche 1 year ago
                                    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.
                                    • TacticalCoder 1 year ago
                                      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 ; )

                                      • btbuildem 1 year ago
                                        I still get occasional emails from the class action law suit for that one
                                      • labster 1 year ago
                                        I love that “Bad Lightning Bolt” is literally just Lightning Bolt that does one less damage.
                                        • mattnewton 1 year ago
                                          It also only hits creatures rather than any target, so it’s even a bad shock!
                                          • labster 1 year ago
                                            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.
                                        • MaxfordAndSons 1 year ago
                                          This is cool, but surprised to see no lip service paid to RoboRosewater, a pioneer in the MTGML space.
                                          • ChrisArchitect 1 year ago
                                            (2022)

                                            Discussion about this a year ago:

                                            https://news.ycombinator.com/item?id=31412608

                                            • jusquan 1 year ago
                                              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)
                                              • keyle 1 year ago
                                                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".

                                                • corethree 1 year ago
                                                  >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.

                                                • KingOfCoders 1 year ago
                                                  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.
                                                  • akumetsu 1 year ago
                                                    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
                                                    • ycombinete 1 year ago
                                                      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.

                                                      • KingOfCoders 1 year ago
                                                        Sadly in Germany :-( Perhaps a reader knows about a reputable bulk service here, good point.
                                                        • ycombinete 1 year ago
                                                          Your best bet might still be to use Card Kingdom. I've had friends ship their cards from countries in the middle east over to card kingdom when their collections were large enough. For smaller collections Ebay, and even local game stores in the area should work fine as well.

                                                          If it were me I'd find a local game store, and go ask the guys there what they use.

                                                      • maxhille 1 year ago
                                                        I recently sold some of my older and valuable cards. I can recommend cardmarket.com as they have good docs on how to grade, package, identify set etc.
                                                    • mock-possum 1 year ago
                                                      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.

                                                      • terrycody 1 year ago
                                                        Great article! In 2019 someone posted same thing: https://medium.com/@lukbebalduke/mtg-hivemind-artificial-int...

                                                        But sadly, he didn't keep going into it after that. Gladly, OP made huge progress on the same topic!

                                                        • jrflowers 1 year ago
                                                          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.
                                                          • fmc30 1 year ago
                                                            I actually made a small hobby site that generates Magic cards using gpt (you can choose 3.5 or 4): https://mtgcardgenerator.com

                                                            You'll need to log in though so I can keep costs under control, but it's a lot of fun to play around with :)

                                                          • filipezf 1 year ago
                                                            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.
                                                            • Frannyies 1 year ago
                                                              How would the LLM balance it automatically?
                                                            • fxtentacle 1 year ago
                                                              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.
                                                              • getwiththeprog 1 year ago
                                                                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.
                                                                • jmartrican 1 year ago
                                                                  This is pretty cool. Though IMHO, the card Peanut Butter Jar that their AI generated should be 0/1, not 1/1.
                                                                  • anxman 1 year ago
                                                                    I bet WOTC would find this very useful!
                                                                    • tayo42 1 year ago
                                                                      It would be interesting if it could make balanced cards. I wonder what kind of crazy op decks these generated cards allows for
                                                                      • saghm 1 year ago
                                                                        Humans aren't exactly great at this either; cards needing to be banned has only gotten more frequent over time, although it looks like this year has been the first one in a while not to require a lot[1]

                                                                        [1]: https://mtg.fandom.com/wiki/Banned_and_restricted_cards/Time...

                                                                        • tstrimple 1 year ago
                                                                          I'd argue that humans are actually pretty fucking good at this. After all, it's humans who are exploiting the weaknesses WOTC build into the game via new card releases. Balance testing is a numbers game though. If you test your software you can be reasonably confident if you release it to 10 people, it'll perform pretty much as expected. If that software is installed by millions of people, you're going to start experiencing every edge case that can only occur in extremely rare circumstances.

                                                                          Or another example, the software released to ten customers can be insecure with little repercussions. But insecure software released to millions is going to be zero-day'd in no time. The MTG community absolutely has hackers that are just waiting for the latest vulnerability to be released.

                                                                          The latest set released by WOTC this week has an infinite mana loop that you can get on turn four. I don't think this stuff will ever stop, and I honestly hope it doesn't. Bans / restrictions can mitigate the damage to certain formats, and it really stirs up the creativity of folks in the meantime.

                                                                          • dtx1 1 year ago
                                                                            There has been a paper on using genetic algorithms for deckbuilding in magic[0]

                                                                            I'm working on at least partially reproducing and improving upon the paper but the reality is that MTG as a game is really hard to implement (and a shitload of work) so i'm building my own MTG inspired game to try and balance it using genetic deck building.

                                                                            [0] https://ntnuopen.ntnu.no/ntnu-xmlui/bitstream/handle/11250/2...

                                                                            • eddtests 1 year ago
                                                                              You’d expect that to happen as potential interactions increase, I assume. I’ve always wanted to learn how to use a modelling tool like TLA+ or something to find breaking issues in games - like first turn wins (that isn’t just Exodia in Yugioh)
                                                                          • wly_cdgr 1 year ago
                                                                            I am extremely confident WoTC is aware of this and is working on and/or using similar
                                                                            • standardly 1 year ago
                                                                              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.
                                                                              • WA 1 year ago
                                                                                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.