
Generating Magic cards using deep, recursive neural networks - dunstad
http://www.mtgsalvation.com/forums/creativity/custom-card-creation/612057-generating-magic-cards-using-deep-recursive-neural
======
JoshTriplett
> Shring the Artist

> 2BB

> Legendary Creature - Cat

> Flying

> Whenever you cast a spell, you may return target creature card from your
> graveyard to your hand.

> 2/2

That's actually a fairly plausible card, in terms of mechanics. It's
thematically appropriate for black, it's about the right cost, it's powerful
but specialized (returns creature cards only, and only to hand rather than to
play), and it's legendary to avoid multiplying its effect. This would work
well in a deck with many creatures with "enters the battlefield" effects
(common in black, as well as blue and red which are often used together with
black), as well as many ways to sacrifice cards. Would even work as the
general in an EDH/Commander deck.

The only thing slightly odd is the flavor: it's a flying cat. And with the
right art (and perhaps a "black cat crossing your path" joke in the flavor
text), that could work quite well.

~~~
tarblog
I'm not so sure this card is on cost.

My neural network is telling me that it's actually too good at 4 mana.

Don't forget about potential combos like having a bunch of zero cost creatures
in your graveyard + anything else that triggers when you play a spell or when
a creature enters the battlefield. But even without that, this is a card
advantage machine.

~~~
JoshTriplett
It's rather good at 4 mana, though that could be balanced in the metagame by
making it rare or mythic.

What zero-cost creatures did you have in mind? Those aren't incredibly common.
And in any case, a combo that requires 3-4 specific cards is not overpowered;
one that only requires 2 specific cards often is.

~~~
lsiebert
you need two zero cost creatures and a way to sacrifice them for benefits,
then just trade off. I can think of infinite mana with four cards.

~~~
JoshTriplett
Magic is not a game that considers all combos a bug, and there are any number
of ways to get to infinite mana (or infinite many other things) with less than
four cards.

------
Everlag
Magic is an interesting game just from an text analytics perspective. Using a
source like mtgjson you get a reasonably sized corpus of text that looks
natural enough for a human to comfortably grok but sufficiently templated to
apply even naive methods and acquire awesome results.

I built a tool that uses n-grams to find cards similar to each other. The
result is comparable to manual suggestions done by users but takes around a
minute rather than months to cleanly update after a new set is released!

~~~
centizen
I am extremely interested to see anything you have public on this project -
both from a technical and deckbuilder's perspective!

~~~
Everlag
You can see a working example over at
[https://preorda.in/card/Kiora,%20the%20Crashing%20Wave/Born%...](https://preorda.in/card/Kiora,%20the%20Crashing%20Wave/Born%20of%20the%20Gods)

I wrote it around a year ago when I was still getting a good feel for go so
its a fairly gross ~500 line go package. However, it exports a moderately sane
QueryableSimilarityData with the ability to Query that data for individual
names. A query result is both the cards that were found to match and how
confident it was. It caches after computing the entire dataset's results so it
is fast to query after closed.

If you want to muck around with it, you'll need to use a relative import
because its just easier for a single file package.

Everything you need apart from the dataset is in
[https://github.com/Everlag/goPricesBeta/blob/master/utilitie...](https://github.com/Everlag/goPricesBeta/blob/master/utilities/cardData/similarityDB/similarityBuilder.go)

Just stick an AllCards-x.json from mtgjson.com in the same directory as binary
the package was used in and it should expose the interface I described above
to anything trying to use it.

As a note, its non-permissively licensed but message me on reddit under this
username and I'll re-license that component. Also, feel free to message me if
you want a hand or have any ideas.

------
vertoc
If I'm interested in Neural Networks, and I've mainly been working in web
development (I know Java, C, and Python). Where would be a good place for me
to start so that I can eventually make something like this project?

~~~
deet
Andrej Karpathy's blog is excellent as a first introduction. Start with
[http://karpathy.github.io/neuralnets/](http://karpathy.github.io/neuralnets/)

He also has a fantastic article specifically about recurrent neural networks
here: [http://karpathy.github.io/2015/05/21/rnn-
effectiveness/](http://karpathy.github.io/2015/05/21/rnn-effectiveness/)

~~~
karpathy
Thanks! I'm really enjoying seeing the huge variety of domains people have
applied char-rnn to. I haven't anticipated response at this scale, to both the
original blog post and the code release. (I try to keep a somewhat up to date
list of responses on the bottom of the blog - cooking recipes, music, obama
speeches, magic cards...)

In terms of learning, I would also encourage people to try the materials from
our CS231n class - this is a class I taught at Stanford last quarter with my
adviser. It's technically about Convolutional Networks, but most of the class
material is building up generic Neural Networks, backprop, and so on. You can
also try our IPython Notebook assignments.

Course notes: [http://cs231n.github.io/](http://cs231n.github.io/) Syllabus
with slides too:
[http://cs231n.stanford.edu/syllabus.html](http://cs231n.stanford.edu/syllabus.html)

Another good pointer is Andrew Ng's Coursera class - that's a thorough
introduction as well.

------
vectorjohn
Wow, this has to be my favorite HN post. I couldn't finish reading it at work
due to tear filled laughter.

I think it is less funny if you don't know anything about MTG. Which is
interesting - if you don't, or don't know it well, these cards seem fairly
indistinguishable from real cards. The differences are hillarious.

Mointainspalk.

------
lips
The author remarks that most of these are nonsensical. As a non-magic player
who lives in a house that sometimes hosts magic games (and thus clicks links
re:mtg), I found every line to be entirely plausible overheard banter.

------
zck
> 3: add 2 to your mana pool

Another card nerfed by the removal of mana burn!
([http://archive.wizards.com/magic/magazine/article.aspx?x=mtg...](http://archive.wizards.com/magic/magazine/article.aspx?x=mtg/daily/feature/42a)
section 3, "Mana Pools and Mana Burn")

~~~
herbig
Combos with Power Artifact.

This thing is really cool. Also, he's using mtgjson.com, which I've used in
the past and it's really awesome.

------
zyxley
A real gem of gibberish interpretation by the thread:
[https://i.imgur.com/AWTQ0bM.jpg](https://i.imgur.com/AWTQ0bM.jpg)

------
dunstad
This actually uses the same neural network discussed here a few weeks ago:
[https://news.ycombinator.com/item?id=9584325](https://news.ycombinator.com/item?id=9584325)

------
lars
These are recurrent neural networks, not recursive. That's a different model,
also used for NLP, but not so readily applicable for generating text AFAIK.

------
kriro
Would be interesting to do this for other other games (that interest me more
;)).

Netrunner ICE generation would be interesting. I'd also like to run some
algorithm over all Star Wars LCG cards and have it generate new arrangements
of objective sets. [for those that don't know the game you don't build your
deck by picking cards like in Magic but rather predefined bundles of 6 cards
(objective sets)]

------
derefr
Reminds me: it feels to me like MTG card text (excluding flavor text) obeys a
formal grammar of some sort. Does it?

If it does, the NN's could possibly be made a lot more powerful if you put a
"parser" in front of its input end (so it was being fed ASTs instead of text)
and a "code generator" on the output end (to convert confabulated ASTs back
into text).

~~~
wlphoenix
I'm not sure if it's officially a formal grammer, but there are definitely
correct and incorrect phrasings for certain effects, and those are changed
over time with official rewordings posted for old cards.

It's one of the ways that unofficial card spoilers are judged. If there are
phrasings that sound "out-of-style" for the effect, its usually judged as a
fake from the first pass.

------
jakozaur
How about IDE that suggest you next line of code? Or next variable, or method
to call?

Add static analysis and it can actually be fairly useful. E.g. val name =
object.[maybe you wwant to use getFirstName]?

~~~
seanmcdirmid
Believe me, it's been thought of (it's been in my head ever since my colleague
Frank Seide introduced me to RNNs 4 years ago, I'm sure I wasn't the first!).
It is one thing to generate code that looks like code, quite another to
generate code that is useful. Character-by-character probably isn't good
enough for this task.

Anyways, I talk about how to use probability (but not compute it!) in
[http://research.microsoft.com/pubs/179363/mcdirmid12.pdf](http://research.microsoft.com/pubs/179363/mcdirmid12.pdf)

~~~
Robin_Message
The old Jungloid technique for Java factory automation/type conversions (I
have an A, I want a B) seems like a possible use for this kind of thing.
[http://dl.acm.org/citation.cfm?id=1065018](http://dl.acm.org/citation.cfm?id=1065018)

~~~
seanmcdirmid
There has been a lot of work on code mining. It still isn't that useful, and
no one has used RNNs (well, there is one paper I remember reading).

------
valbaca
Thanks for the giggle fit.

The cards do get very "real" very fast. Love it

------
columbo
This is a very interesting idea. I'd like to see it played with 100% of the
cards being generated through a system like this. 4 players, 4 automated decks
of random (possibly nonsensical cards), that would be _so much fun_!

~~~
digitalzombie
You probably would draft instead of just automate the deck.

I think the mechanic is hard to generate a deck that utilize these mechanic
and build synergy and combo out of these decks.

~~~
columbo
Oh totally, draft would be fine, but even the idea of playing something
randomly generated like this would be pretty fun.

------
vertoc
A question I have about this, and I'm new to neural networks so this might be
entirely wrong, but would it be possible to create another neural network that
returns whether or not a card is overpowered or not and run that on all the
cards generated by this neural network? Then you could get a set of fairly
balanced cards even if a few might be somewhat nonsensical

------
Yhippa
Wonder what MaRo and the gang thinks about this. I am pretty surprised at the
results so far from that post. They mostly don't make sense but I'm sure if
you went through say 100 of them you're bound to find one or two legitimate
ideas in there.

~~~
RansomTime
Unfortunately they might not be able to view this - as it might be viewed as
"unsolicited design" \- which they can't view due to company policy.

Stops people suing Wizards if they print a card identical or similar to a
homebrew card.

------
jwecker
I was very excited to learn about recursive neural networks and how they are
different from recurrent neural networks. I began imagining self-similar
fractal topologies and automatic convolution layer creation etc...
Disappointed to see it was just a typo :-)

~~~
Houshalter
There are actually recursive neural networks.
[https://en.wikipedia.org/wiki/Recursive_neural_network](https://en.wikipedia.org/wiki/Recursive_neural_network)

------
nallerooth
Magic + AI = mandatory upvote. Nice one!

~~~
wjnc
I am enamoured that geeks can find amazement in computer generated content. I
wonder if Shakespeare scholars felt the same with the recent neural net
creating Shakespeare-like content. What is to come, when cgc starts to become
even more amazing? A individualized, computer generated TV-shows that hit all
your favorite subjects?

------
octatoan
Probably offtopic, but the second or third poster in that thread had
"Stormfront" in the sig.

Well.

~~~
ubernostrum
The full signature is:

    
    
        My Custom Sets
        
        Avant Block: Avant -- Stormfront
    

Which suggests that it's the name of the in-progress second set of a block of
custom user-created cards the person is working on. Quick glance at the posts
the signature links to gives me the impression it was chosen simply as a
generic "storm is coming" fantasy-setting name.

And for people who know a bit about Magic: seems a lot like "Scars block
without the Phyrexians", even down to the user posting a variation on Koth.

