Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: [1]

Author Topic: RNN generated cards  (Read 2903 times)

0 Members and 1 Guest are viewing this topic.

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
RNN generated cards
« on: September 18, 2020, 08:19:09 am »
0

I know that there's an old thread about neutral network generated Dominion cards: that was 2 years ago, and the results were more funny than practical.

In July this year there was an Escapist article about RNN generated MTG cards https://v1.escapistmagazine.com/articles/view/scienceandtech/14276-Magic-The-Gathering-Cards-Made-by-Artificial-Intelligence

The results are impressive (at least from page 7 onwards), to the point that the RNN had created a new keyword ("Tromple"), defined it, and was applying it to new cards.

Is there any interest with trying this again with Dominion cards? I suspect that the problem last time was that not enough time was spent training. When I get time I'm going to follow Talco's step-by-step guide for setting this up.
Logged

Awaclus

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 11815
  • Shuffle iT Username: Awaclus
  • (´。• ω •。`)
  • Respect: +12868
    • View Profile
    • Birds of Necama
Re: RNN generated cards
« Reply #1 on: September 18, 2020, 11:19:51 am »
0

The returns at the point were extremely diminishing. To get substantially better results than what we were getting, you need a better dataset.
Logged
Bomb, Cannon, and many of the Gunpowder cards can strongly effect gameplay, particularly in a destructive way

The YouTube channel where I make musicDownload my band's Creative Commons albums for free

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9707
  • Respect: +10765
    • View Profile
Re: RNN generated cards
« Reply #2 on: September 18, 2020, 11:44:12 am »
+1

I might have asked this before, I don't remember.... so in my limited understanding of neural networks and machine learning, the basic idea is that each generation, the "best" survive and move on. So in the next generation, more of the population will be more similar to that previous best, giving a better chance to reach a new best.

I've seen videos on training AI to play Mario, for example, and there, the "best" is defined as "got farthest to the right in the stage". On an AI learning to play Tetris, it knows it did well if it survived for a longer time, or more total piece drops, or total lines cleared, etc.

But with generating Dominion or MTG cards, how is "best" defined? What criteria is used to determine which members of the population survive to the next generation? If it is "similarity to existing cards", then wouldn't the AI eventually just generate exact existing cards repeatedly forever? I wouldn't think it would even take very many generations for it to arrive at "hey, if I just copy this existing card word-for-word, I end up with a result that gives me a perfect score".

Or, does training an AI to generate cards or other text in this way follow a different fundamental principle from training an AI to do better in a video game?
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

ben_king

  • Golem
  • ****
  • Offline Offline
  • Posts: 190
  • Shuffle iT Username: ben.king
  • formerly grsbmd
  • Respect: +612
    • View Profile
Re: RNN generated cards
« Reply #3 on: September 18, 2020, 01:03:13 pm »
+2

I might have asked this before, I don't remember.... so in my limited understanding of neural networks and machine learning, the basic idea is that each generation, the "best" survive and move on. So in the next generation, more of the population will be more similar to that previous best, giving a better chance to reach a new best.

I've seen videos on training AI to play Mario, for example, and there, the "best" is defined as "got farthest to the right in the stage". On an AI learning to play Tetris, it knows it did well if it survived for a longer time, or more total piece drops, or total lines cleared, etc.

But with generating Dominion or MTG cards, how is "best" defined? What criteria is used to determine which members of the population survive to the next generation? If it is "similarity to existing cards", then wouldn't the AI eventually just generate exact existing cards repeatedly forever? I wouldn't think it would even take very many generations for it to arrive at "hey, if I just copy this existing card word-for-word, I end up with a result that gives me a perfect score".

Or, does training an AI to generate cards or other text in this way follow a different fundamental principle from training an AI to do better in a video game?

What you're thinking of is called "genetic programming", which has been used in the past to train neural networks, though it's not common to use that lately.  The neural networks here are trained using supervised learning, which uses backpropagation to optimize a specific function, usually some sort of distance from its prediction to the correct answer.  In this case, the objective function is trying to predict the next word at each position, given all the words up to that point.

AI for video games usually uses reinforcement learning, which tries to optimize future rewards, where the reward might be proportional to how long the agent lasts before dying or how many points it gets, or something similar.
Logged

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
Re: RNN generated cards
« Reply #4 on: September 18, 2020, 02:21:16 pm »
0


But with generating Dominion or MTG cards, how is "best" defined? What criteria is used to determine which members of the population survive to the next generation? If it is "similarity to existing cards", then wouldn't the AI eventually just generate exact existing cards repeatedly forever? I wouldn't think it would even take very many generations for it to arrive at "hey, if I just copy this existing card word-for-word, I end up with a result that gives me a perfect score".


The commentry from the Escaped article I linked to suggested that the AI was coming up with novel mechanics for MTG cards, and was learning which mechanics were appropriate for which colour card. This is after (I think) weeks of training. I don't know how many "similar to existing cards" were generated and not presented to us.

I have installed pytorch (I have some python experience) and intend to go through some tutorials when my kids are finally up in their bedrooms.
Logged

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: RNN generated cards
« Reply #5 on: September 18, 2020, 02:25:33 pm »
0

One thing I heard about the MTG cards is that some of the models got too good, they would just output exact copies of existing cards due to memorization, or the new cards they generated wouldn't come up with new mechanics because those mechanics didn't appear on real cards. The entire point is that the model is trained to mimic the existing text - if it mimics it too well then you're stuck. There's a sweet spot where the model's output is coherent, but also still gets things wrong in a funny way. Training the model for longer may not give you want you want.

The state of the art language models are based on Transformer models, not RNN / LSTM. There have been past efforts at taking the GPT models from OpenAI and trying to get them to generate Dominion cards. http://forum.dominionstrategy.com/index.php?topic=20446.msg848017#msg848017
Logged
I have a blog! It's called Sorta Insightful. Check it out?

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
Re: RNN generated cards
« Reply #6 on: September 18, 2020, 03:07:10 pm »
0

What if the training data included a small percentage of text from other card games?
Logged

D782802859

  • Apprentice
  • *****
  • Offline Offline
  • Posts: 292
  • Respect: +385
    • View Profile
Re: RNN generated cards
« Reply #7 on: September 18, 2020, 03:10:41 pm »
+1

What if the training data included a small percentage of text from other card games?

Basically all other card games aren't compatible so it would end up nonsensical.
Logged

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9707
  • Respect: +10765
    • View Profile
Re: RNN generated cards
« Reply #8 on: September 18, 2020, 03:25:23 pm »
0

What if the training data included a small percentage of text from other card games?

Basically all other card games aren't compatible so it would end up nonsensical.

Hey now, you're allowed to name MTG cards when playing Wishing Well.

And you you are NOT allowed to name a Dominion card when resolving an MTG effect that asks you to name a card.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
Re: RNN generated cards
« Reply #9 on: September 18, 2020, 05:11:44 pm »
0

Okay, I had chance to have a quick mess around with pytorch. I didn't have much time, hvaen't really read any documentation, so I simply used the script at https://www.aritrasen.com/deep-learning-with-pytorch-text-generation-lstms-3-3/ with the text from the wiki's card lists.

I know that we won't get anything comprehensible, since the input isn't encoded like the MTG corpus is. I'm just checking to make sure I can get anything.

10 Epochs took about 1 minute. Output is nonsense such as "Fountain Boon. +$1 Moneylender mat. Province. Otherwise, +2 cost. Event has end Silvers would Lucky -1 Chariot left, Reveal Treasure game" but at least it compiles, eh?
Logged

Awaclus

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 11815
  • Shuffle iT Username: Awaclus
  • (´。• ω •。`)
  • Respect: +12868
    • View Profile
    • Birds of Necama
Re: RNN generated cards
« Reply #10 on: September 18, 2020, 06:03:25 pm »
0

Okay, I had chance to have a quick mess around with pytorch. I didn't have much time, hvaen't really read any documentation, so I simply used the script at https://www.aritrasen.com/deep-learning-with-pytorch-text-generation-lstms-3-3/ with the text from the wiki's card lists.

I know that we won't get anything comprehensible, since the input isn't encoded like the MTG corpus is. I'm just checking to make sure I can get anything.

10 Epochs took about 1 minute. Output is nonsense such as "Fountain Boon. +$1 Moneylender mat. Province. Otherwise, +2 cost. Event has end Silvers would Lucky -1 Chariot left, Reveal Treasure game" but at least it compiles, eh?

Learning from complete words instead of individual characters is already an improvement and will lead to sensible cards a lot sooner. The obvious downside is that this way it won't be able to invent new words.
Logged
Bomb, Cannon, and many of the Gunpowder cards can strongly effect gameplay, particularly in a destructive way

The YouTube channel where I make musicDownload my band's Creative Commons albums for free

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
Re: RNN generated cards
« Reply #11 on: September 18, 2020, 07:43:01 pm »
0

80 Epochs, 2 layers, and its beginning to mimic my lazy input format (which is of the form "Cellar   Action   $2   +1 Action"), and there's a hint of grammar, such as "Deluded, Action $2 Add one Boon. " or "Treasure Zombie phase, 1VP per Adventurer", but it's still mostly nonsense.

At the moment I'm just a script kiddie while I figure things out. I think I need to add some kind of checkpointing so I can save the progress of longer training sessions.




Logged

chipperMDW

  • Duke
  • *****
  • Offline Offline
  • Posts: 368
  • Respect: +822
    • View Profile
Re: RNN generated cards
« Reply #12 on: September 18, 2020, 08:48:53 pm »
+3

And you you are NOT allowed to name a Dominion card when resolving an MTG effect that asks you to name a card.

Crap, you mean I can't name Moat?
« Last Edit: September 18, 2020, 08:52:21 pm by chipperMDW »
Logged

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
Re: RNN generated cards
« Reply #13 on: September 23, 2020, 01:41:03 pm »
0

Had another play with this.
1) The MTG generator generates the card's effect first, then uses a seperate categorization NN to guess at the card's name, keywords, color and cost. So i've stripped my text input to just card effects for now.
2) The Dominion card sample size is too small. I've tried going up to 3 layers to see if I can benefit from "an ensemble mechanism".

The result is, I dunno, it looks more structured, but it fixates almost exclusively on the words "Setup" and "When".
Logged

marasmusine

  • Pearl Diver
  • **
  • Offline Offline
  • Posts: 11
  • Respect: +2
    • View Profile
Re: RNN generated cards
« Reply #14 on: September 23, 2020, 07:15:58 pm »
+1

Okay, I'm trying a "model zoo" type template, and the results are funnier, at least:

"When scoring, 2 VP per differently named Curse onto your hand of Coppers and +1 VP."

"You may trash a card from your hand costing up to $4. You may reveal an Action card from your hand."

"+1 Action, +$1, When you gain a Victory card, you may play an Action or 3 Action"



Logged
Pages: [1]
 

Page created in 0.085 seconds with 20 queries.