NPC Generator for Dungeons and Dragons
NPC Generator for Dungeons and Dragons
By John Robinson | May 31, 2024
calendar_month
Built in May 2024
schedule
1 Week
build_circle
OpenAI, DALL-E, Flask, Python
This post is part of a series where we document our journey to build 1 product per week, in an effort to explore what’s possible with AI.
This post is part of a series where we document our journey to build 1 product per week, in an effort to explore what’s possible with AI.
This post is part of a series where we document our journey to build 1 product per week, in an effort to explore what’s possible with AI.
The idea
This week we’d like to show off a bit of a random creation. It’s a NPC character generator for Dungeons and Dragons that uses AI image and text generation to create Non-player Characters (NPCs) on the fly.
Why this idea?
The NPC generator was an exploratory project to help our team learn more about building with AI tools. For dungeon masters hosting a Dungeons and Dragons game, creating these characters can be a lot of work. Dungeon masters can spend hours crafting characters for their games, we figured AI could do the heavy lifting instead. Our NPC Generator can create interesting back stories, unique personalities, and even pictures of these characters.
By building the NPC generator, we were especially interested to learn:
How various OpenAI interaction methods produce different results (think Prompts vs. Assistant API vs. Custom GPTs)
How to get DALL-E to produce creative outputs, within a specific set of instructions
How to use OpenAI output in another system
How it works:
By building the NPC generator, we were especially interested to learn:
Enter a prompt or have the NPC generator come up with something random
Send the prompt to GPT 4o and DALL-E simultaneously
Receive JSON from GPT-4o and stream the response to the web app
Display character image when DALL-E job is complete
What we learned:
In one week, our team built a web app that could produce an NPC with a unique description, backstory and image. This was mostly a fun project to learn how to shape and interact with AI text and image generation. We learned a few things in this project:
AI isn’t very good at being random. While testing, we found that results often defaulted to the average. In this case, AI really liked to generate Elves with similar backstories. 🤷
With DALL-E, we found that specific instructions will often be ignored. Trying to give Thaddeus that Sword? Well it may take a few tries.
Out of the different interaction methods we tried (prompt, assistant, custom GPTs), the Assistant API was the easiest and most efficient. The ability to generate structured JSON from prompts makes the output far more useful.
Want to check it out?