Generating novel cards using Recurrent Neural Networks

By smizmeal, in Android: Netrunner The Card Game

Hello! I'm here to discuss generating novel cards for Netrunner using Recurrent Neural Networks, specifically char-rnn ( https://github.com/karpathy/char-rnn ), which is a convenient open source implementation of the algorithm. I've already been discussing this here , but I thought I'd post here as well.

The idea for this comes from this brilliant blog http://karpathy.github.io/2015/05/21/rnn-effectiveness/ on using deep RNNs to generate Shakespearean dialogue, speeches, LaTeX-formatted proofs, and even source code for Linux. If you are familiar with machine learning, I highly recommend reading the blog; if you aren't, then the basic idea is that the network (an algorithm) learns patterns in the input data and can reproduce novel sequences that plausibly adhere to those patterns. This particular implementation is a character-level "long short term memory" network, meaning it reads/comprehends data character-by-character. People have since used it to produce novel Irish folk songs, lines from the Bible, and most relevant to this audience, generating cards for Magic: the Gathering ( http://www.mtgsalvation.com/forums/creativity/custom-card-cr... ).

Using the API at netrunnerdb, I parsed and reformatted all card data (sans identities) into the following format:

{{ side | faction | card name | cost | faction cost | type | subtype(s) | strength | MU cost | trash cost | unique | limited | set name | card text | illustrator | flavor text }}

This data gets fed into the char-rnn code, which is trained for ~30-40 epochs. Sampling it gives the text output, which is text in a pattern similar to the input --- in this case, Netrunner cards!

Some things to keep in mind: the RNN has no a priori knowledge or concept of Netrunner rules, the English language, or syntax/style/formatting. It simply reads in input characters as text, character-by-character, and does its best to match what it has seen before. The amazing effect of this is that it will learn to structure cards properly at a macro level, but also learn subtler details like how ICE should have strength, programs should have memory cost, or that flavor text often has quotes around it. One drawback is the relatively small dataset (~200 KB, after preprocessing), which leads to some garbled English (in the flavor text especially), but I've been pretty pleased with the results. Some sample cards produced by the algorithm are below, I'd really like to know what you all think!

Note: whenever you see "$THIS" in the card text, the actual Netrunner card would have its own name. This helps the RNN learn a bit better/faster since it is part of the Netrunner 'grammar' anyway. Again, the format for cards is:

{{ side | faction | card name | cost | faction cost | type | subtype(s) | strength | MU cost | trash cost | unique | limited | set name | card text | illustrator | flavor text }}

--------------------------------------------------------
{{ Corp | NBN | Bardog | 2 | 2 | ICE | Sentry - Tracer - AP | 4 | _ | _ | False | False | Order and Chaos | Whenever you make a successful run on HQ, trash that card. | Matt Zeilinger | | }}

Bardog! Here's a good example of the well-formatted nonsense it is capable of. It is a 2-cost NBN sentry ICE with 4 strength, but its text is addressing a Runner. A lot of the cards are like this in terms of not being legal or making sense, but remember that the RNN has no concept of Netrunner rules; it only knows the patterns of cards.

--------------------------------------------------------
{{ Corp | Jinteki | Shintul | 0 | 1 | ICE | Sentry - Tracer - AP | 0 | _ | _ | False | False | Honor and Profit | [subroutine] Trace2– If successful, trash 1 program.
[subroutine] Trace3– If successful, trash 1 program.
[subroutine] Trace2– If successful, trash 1 program.
[subroutine] End the run. | Adam S. Doyle | The meally someting of the bust of coursed the clearence clonat whe had begen the data the seone of the tacked the first time the begine in the butinally and the had programmine encreased the end has it holk one who its a run on a ser eech time goon the sare an a coultertion to the butting a the network and the worth of the bust of creds to the first the remowndackess on a single by st first the busting of the corporate was a siltly better than consime is a remote of the most of the finds of the corporate is the install better the first the betticaceds on a piece of ice protecting to an as an aver all holl nother of danger. | }}

Shintul is clearly over-powered. It's a 0-cost, 0-strength sentry with four great subroutines that is perfect for splashing since it has a faction cost of 1. Also, I love that the RNN felt poetic when it came to the flavor text.

--------------------------------------------------------
{{ Runner | Anarch | Surbeat | 1 | 2 | Event | _ | _ | _ | _ | False | False | Core Set | [Trash]: Prevent all during this run. | Matt Zeilinger | "The have been colpering to can a counter with the numbersed. | }}

Surbeat, a 1-cost Anarch event you trash to prevent all. Underrated, IMO.

--------------------------------------------------------
{{ Corp | Haas-Bioroid | Ashack | 2 | 2 | ICE | Sentry - Tracer - AP | 0 | _ | _ | False | False | Core Set | [subroutine] The Runner cannot make another turn.
[Click]: Parce 1 virus counter on $THIS.
[Click]: Take 2[Credits] from $THIS. | Mauricio Herrera | | }}

Okay, Ashack is straight-up devastating. If the runner hits this sentry and cannot break the subroutine, he or she cannot make another turn. Conveniently, you can take credits off this ICE (I assume putting credits on ICE is a future game mechanic).

--------------------------------------------------------
{{ Corp | Neutral | Pain Track | 0 | 1 | Operation | _ | _ | _ | _ | False | False | The Spaces Between | This card is the Corp trashes $THIS when it is installed. When there are no credits left on $THIS, trash it.
[Click]: Take 1[Credits] from the bank on $THIS when it is rezzed. When there are no credits left on $THIS, trash it.
[Click]: Take 2[Credits] from $THIS. | Mauricio Herrera | | }}

Pain Track is an operation that really wants you to trash it. Trash it when installed. Trash it when it has no credits. Presumably other cards will let you install and rez operations, right?

--------------------------------------------------------
{{ Runner | Criminal | Bustor Cater | 1 | 1 | Resource | Location | _ | _ | _ | False | False | Core Set | 1[Credits]: Break code gate subroutine.
1[Credits]: +1 strength. | Adam S. Doyle | The netwar colling is a reid. Trank the from a single byone with the bughts. | }}

Bustor Cater is a code gate-breaking resource. Now if you could only use it during a run...

--------------------------------------------------------
{{ Corp | Haas-Bioroid | Helling | 4 | 0 | ICE | Sentry - Tracer | 3 | _ | _ | False | False | Trace Amount | Place 1 advancement token on $THIS. | Ed Mattinian | | }}

I'm going to need a ruling on Helling. Do you only place 1 advancement token on it once, or as many times as you want? Personally I lean to the latter -- Helling is an infinite advancement token source!

--------------------------------------------------------
{{ Runner | Anarch | Snowe | 2 | 2 | Hardware | Chip | _ | _ | _ | False | False | Core Set | [subroutine] The Runner cannot draw cards in this run. | Ed Mattinian | "It wattion of a program the door of damages. | }}

Snowe is malicious hardware. Seems appropriate for Anarch.

--------------------------------------------------------
{{ Corp | Neutral | Pasple | 2 | 2 | Asset | _ | _ | _ | 1 | False | False | Core Set | [Trash]: Break any number of live the Runner accesses $THIS, do 1 net damage for each advancement token on $THIS. | Matt Zeilinger | | }}

OK, I'm starting to think the RNN hates the runner. It only gives them unworkable cards, but gives the corp Pasple. Note that it does have faction cost even though it is neutral.

--------------------------------------------------------
{{ Runner | Anarch | Cerebral | 0 | 2 | Event | _ | _ | _ | _ | False | False | Order and Chaos | Whenever you make a successful run on HQ, the Corp to spend [Click][Click][Click]. | Matt Zeilinger | The first time. | }}

Ok maybe the RNN doesn't hate the runner... Cerebral is a couple words short of being amazing. Basically it is an event that says if you have a successful run on HQ, the corp loses three clicks on their next turn. This could be a real card ... and it would be hated [ :) ] Also, it has great flavor text.

--------------------------------------------------------

{{ Runner | Anarch | Inve | 1 | 1 | Event | _ | _ | _ | _ | False | False | Creation and Control | +1[Memory Unit]
Whenever you pass a piece of ice. | Matt Zeilinger | | }}

Did you ever need some more MU during a run? Actually, Inve synergizes really well with Overmind and Sage, making them more powerful with each ICE you pass. I would use this.

--------------------------------------------------------
{{ Corp | Weyland Consortium | Exprot Chip | 0 | 2 | Asset | _ | _ | _ | 1 | False | False | Creation and Control | The Runner may spend [Click]. | Mart Zeiling | Lingern mind is even more to and his it hold deemong the network desates of the motting and installed with mighing the brind would server. The Prich to prosell secert, che gett you any net is a highed betthent. | }}

Ok, Exprot Chip may be my new favorite. Not even messing around, just give the runner a click to spend. Play it as a handicap and see if you can still win, with extra bragging rights.

--------------------------------------------------------
{{ Corp | Weyland Consortium | Experienciviciation | 2 | 1 | ICE | Code Gate | 5 | _ | _ | False | False | Upstalk | $THIS can be advanced and has +1 strength. | Ed Mattinian | "It's you don't care of a forder the memority Everting the mow of musuaral of the corporas spenting and shame me to be foret." -The Professor | }}

Experienciviciation, no subroutines but hey it can be advanced. Someone pointed out that with Subboost or Marker this could be a really decent Code Gate for Weyland. Also, a quote from the Professor! And he is ashamed apparently.

--------------------------------------------------------
{{ Runner | Anarch | Redbuck | 1 | 2 | Program | Icebreaker - AI | 1 | 1 | _ | False | False | Core Set | 1[Credits]: Break sentry subroutine. 1[Credits]: +1 strength. | Adam S. Doyle | | }}

Redbuck is a straightforward, powerful sentry breaker.

--------------------------------------------------------
{{ Runner | Shaper | Moverthing | 3 | 2 | Event | Run | _ | _ | _ | False | False | Core Set | Make a run on HQ. If successful, instead of accessing cards, you may look at the top card of your stack. | Matt Zeilinger | "They dan'' be horded, the data bet the creditite is balie soll the crest. | }}

Ah, Moverthing! If you get to HQ and have nothing better to do, why not look at the top of your stack? Hilarious, but not worth it, honestly!

--------------------------------------------------------
{{ Runner | Shaper | Constack | 3 | 2 | Hardware | Console | _ | _ | _ | True | False | The Valley | The first time you trash and add it to your grip. Shuffle your stack. | Ed Mattinian | Somitital was subroun the install is a piece of hardware from the inned durantull flat rest of a his not costall from the renmoring minery bus surating cards in ardicc. | }}

Constack is pretty interesting. It essentially lets you hold on to the first card you would trash a turn and then shuffle your stack. I like the fact the RNN made this card unique, meaning it clearly has learned that pattern which is common to consoles.

--------------------------------------------------------
{{ Runner | Neutral | Data Con | 2 | 1 | Resource | Virtual - Subrous | _ | _ | _ | True | False | Core Set | +1[Memory Unit] Your maximum hand size is increased by 1. | Matt Zeilinger | Drewe al age the boot have in the rind what icebreaker of the untilitaly ald do gate. | }}

Data Con could easily be a real card. It is Virtual and unique... I imagine it is a data convention in cyberspace. It is easily worth the 1 neutral faction cost.

--------------------------------------------------------
{{ Runner | Criminal | Earn | 3 | 2 | Program | Icebreaker - Killer | 2 | 1 | _ | False | False | The Valley | The first time you install a piece of ice and the munt is the Corp turn begins, you may search your stack for a card and add it to your grip. Shuffle your stack. | Make Semofz | There and you're that it is a somling anduring contoting a rest program from your mexiath successing a run, the Corp maker selly like bast eath the contoring a codes, proge a that pays to payply and you thanked have bat ono was a macte sime. | }}

Earn. I'm guessing if corp installed ice, when the corp's turn begins it lets you search your stack for a card to add to your grip. Great name, great theme, but no idea why it is an icebreaker.

--------------------------------------------------------

Again, I hope you found this interesting. Netrunner is a fantastic game and it seemed really appropriate given the game's theme to see what happens when you use neural networks to make new cards.

Most of these are gibberish. This is interesting, how?

I think everything has been programmed in OCTGN so unless you are trying to reprogram a card to allow for more of a structured interface instead of depending on the players to understand the rules, however I think you might want to be using their program.

However if you are trying to rewrite card text you have to be careful. Card rule text is crafted in a specific way in order to avoid confusion and to have the card played in a way it was meant to be played with out people forgetting certain mechanics like trashing the card to use it. Now programming language could be useful in a flavor text but I think that ANR using HTML for some of the flavor text fits the theme nicely. It is a familiar language that even non-programmers will recognize. Using a more obscure program language may not resonate with majority of the players. Remember this is game with cyberpunk fantasy theme around it, not an actual game about hacking and writing programs.

The point of this was to show what machine learning is currently capable of. As he mentioned, these are cards that have been created using neural networks by simply looking at the existing cards and attempting to come up with new ones based on patterns they see in the existing ones. I find it quite interesting, but I understand that not everyone is into that sort of thing. Also note that both facebook and google are currently using neural networks to create works of art...