Skip to the content.
< go back

Teaching Computers About D&D

I am perpetually dissatisfied with the current state of machine-generated Dungeons & Dragons content on the Internet. Sure, sometimes we get some spells with funny descriptions, or someone generating spell names, but these things aren’t particularly sophisticated or interesting. Most of the spells barely make sense, let alone could be used in an actual campaign. So, this is where I want to come in. My friend David and I are going to try to generate things in a more sophisticated way using a Generative Adversarial Network (GAN). The idea is, use a neural network that is designed to distinguish real D&D spells from fabricated ones and have them compete against each other. The generator doing its best to generate realistic-looking spells and the discriminator constantly trying to detect which are fake. Through this process both networks become sufficiently sophisticated.

fireball

I’ve used GANs before, specifically a Wasserstein GAN, to generate seed files for a fuzzing operation with success. However, I believe the case of D&D spells is much more complex. Firstly, there are aspects of a D&D spell that lend themselves to being encoded as a simple array that is generated by one kind of neural network, and aspects that would prefer to be encoded as text and worked on by an RNN. In order to deal with these inherently different parts of a larger, more complex piece I have two possible approaches:

  1. Remove text-based data (spell name, description, etc.) in favor of more rigid, numbers-only representations. e.g., instead of saying “A beam of cracking energy streaks toward a creature within range. Make a ranged spell attack against the target. On a hit, the target takes 1d10 force damage”, develop an encoding for saying “deals 1d10 force”, among other spell effects, and throw everything into a simple neural net and hope it works.
  2. Use two interwovan GANs. This is the more interesting approach in my opinion and I think it would be interesting to try and do as an experiment, so we’ll proceed down this path.

weird gan

The idea is this: There’s an RNN GAN for text portions of the spell, and a simple GAN for the numbers. Both of these GANs will generate increasingly realistic portions of spells. However, since these portions are inextricably linked we must also examine them as a whole. Thus, a third discriminator is needed to judge the spell as a whole. If the text or numbers are realistic but the pairing of them is not, then the generators should be penalized (or, at least, rewarded less). Intuitively this should create realistic spells (hopefully better than some of the other computer-generated content out there).

Will this work? Who knows! But it’ll be cool to find out.

Written on August 13, 2019