We may earn a commission when you buy through links in our articles. Learn more.

Someone taught an AI to play DnD, and it loves Magic Missile

A software engineer and Dungeons and Dragons fan ran a D&D game for an Artificial Intelligence chatbot, and it creates a 5e Wizard who hates Beholders

DnD AI player - a grey robot in yellow robes

Technology these days is amazing. Thanks to tech giants like Google, Artificial Intelligence (AI) is present on plenty of phones and in plenty of homes. AI is able to perform tasks that require human levels of intelligence by ‘learning’ patterns and predicting outcomes. So, let’s be honest – it was only a matter of time before we tried to figure out how to get machines to play D&D.

There have been plenty of attempts to make AI RPGs happen in the past. Perhaps most famously, you could play a game of Skyrim using your Amazon Alexa – but this was a scripted game that’s more closely related to a choose-your-own-adventure book than a live TTRPG. There’s also the work of computer science enthusiasts like Lara J. Martin, who’s been trying to teach AI to run D&D games since around 2018.

The most recent public attempt to unite AI and D&D came in the form of a Reddit post on June 19. Janne Mikola, a 37-year-old software engineer from Finland, shared an impromptu DnD game with OpenAI’s GPT-3 software, a language model (or a ‘chatbot’) that generates realistic-sounding responses to conversation.

Now, tabletop RPGs like Dungeons and Dragons aren’t the easiest thing to replicate with machine learning. Firstly, it requires the software to convincingly replicate the mannerisms of a human – then it must replicate a human who’s pretending to be someone else. Combine that with the improvisation and storytelling skills needed for a game, and AI D&D suddenly sounds a lot more challenging.

Mikola wasn’t deterred, however. “To me, AI is one of the most exciting areas in computer science right now”, he told Wargamer, “and it has a huge potential to shape the future of humankind in a number of ways, like helping humans to better understand and interact with their environment, or helping to create more efficient and effective systems”.

DnD AI player - Mordenkainen, a bald man seen controlling arcane golden cogs

Mikola admits being able to play D&D wouldn’t be a breakthrough that directly benefits society, but the project could provide some interesting results. “I felt it was a good way of taking an AI to a test drive, to see it building a secondary level of reality between the AI and me (the role-playing world) and being able to write and act on behalf of its character, rather than as only as his own AI-persona”, he says.

Mikola starts his conversation with the AI by asking which D&D monsters it would be most afraid of (spoilers, it’s a Beholder). Mikola asks the chatbot to compare D&D with Pathfinder, and he asks why DnD settings like The Forgotten Realms are so popular. (Of course, whether you agree with the AI that D&D is more “streamlined and simplified” than Pathfinder is up to you.) A further spanner is thrown in the works by challenging the AI’s responses and asking it for elaborations on various points.

Mikola says he was looking for creativity and problem-solving abilities in this conversation, so he asked the chatbot to choose between two popular 5e spells, Fireball and Magic Missile. AI turns out to be a big fan of Magic Missile, particularly as it avoids potentially damaging its fellow party members. He also tested what the AI would do if its Wizard character (who is named Alaric, by the way) was suddenly unable to cast spells.

“It’s good to note though that when I use words like ‘creativity’, the reality is that even OpenAI’s GPT-3 is not a sentient being with actual creativity behind it”, Mikola explains. “The concept of such a sentient AI is called a general AI, and no one is certain if that can even ever be achieved.”

DND AI player - the Wizard Tasha, a blonde woman holding a spellbook

“The ‘creativity’ challenges I gave [the AI] were more like word processing challenges to put together convincing textual responses where I had excluded the major set of the most expected sensible results, like the ability to cast spells in the fight from a spellcaster”, Mikola explains.

The creativity challenge in question would have been quite cruel if it was tested on a human player. While looking for a quest in Waterdeep, the most famous of DnD cities, Alaric the Wizard meets a Skeleton King who swiftly breaks Alaric’s arms. No more spellcasting for Alaric – good thing this is a lesson in machine learning and not how to be a DM.

DnD AI player - a grey robot in yellow robes

The AI’s creative response to the situation is to attempt to reason with the Skeleton King. Sadly, Alaric the Wizard rolls a three on his Persuasion skill check, and the game ends. While short, the AI’s ability to adapt to the game remains impressive. “The sophistication of these currently existing AIs is unexpectedly high already,” Mikola tells Wargamer. “It can very quickly pull data to its responses that would take a while for a human to think of – or Google.”

Of course, every scientific test needs clearly defined conditions. Mikola explains the settings for the test in some more detail, saying “OpenAI is configurable with some parameters, and I did fine-tune those to let the AI roam a bit more free”. “In other words, I increased the temperature to increase the randomness of the AI’s responses, the maximum length to give me longer replies to some of my questions, and the frequency and presence penalties in the hopes the AI would bring new topics into the discussion.”

Mikola adds the results shared on Reddit were from the first attempt at a D&D game, and he says the text has not been edited in any way. “Every response and the level of interaction was as surprising and unexpected to me as it can be”, he says.

You can find Mikola’s full AI D&D game in the original Reddit post. For more automated D&D goodies, be sure to check out our encounter builder 5e guide, as well as our DnD character creator guide.