Technology enabled Dungeon Master
In 2020, I began to explore the world of Virtual Table Top (VTT) and playing D&D online.
A year later, I am using technology to create more immersive experiences for my players and lighten my workload at the table (virtual or otherwise). How did I do it? Read on…
At work I help people implement automation and artificial intelligence. I’ve seen that providing people a toy project is a great way for them to see the value of AI outside of the lab. That is to say, real-world application vs. concept/theory. What can AI really do?
When I picked up Steam Forged Games Epic Encounters: Caverns of the Frost Giants box set, inspiration hit. That inspiration was to build a Random Encounter generator using the D&D Beyond Encounter Builder tool. But how…how could I build a random encounter?
Technology to the rescue
Robotic Process Automation (RPA) was the right tool to get my random encounter builder built.
RPA is a technology that is getting a lot of attention right now. The easy way to think about RPA is that RPA is teaching a computer how to use a computer like a human. So, you train the RPA “bot” how to use a computer just like a human would. In this case, the RPA bot would be taught how to build an encounter in the D&D Beyond Encounter Builder.
Why automate?
In this case, I’m just doing a toy project but there is a good reason to automate this process. The process of Random Encounter generation involves multiple books, some tables to look up, a few rolls, a bit of math, then some clicks to use the D&D Beyond Encounter Builder. Not so simple. Imagine making this all as simple as click a button and enter what environment the players are in.
When playing D&D my players are all about the game moving quickly. Saying “hold on, let me look that up” creates a pause that threatens to invite distraction (my players are younger). D&D Beyond helps me keep the story moving and the players engaged. Taking a moment to build out a random encounter could be a moment that leads to many moments of distraction. And, I want to support my young players discovering the power of technology in life not just school/work.
Getting started
I always start RPA projects by examining the process being automated. In this case, the process to build a random encounter.
Open the browser to the Encounter Builder to see the average level of the characters in the campaign.
Open Xanthar’s Guide to Everything (XGtE) and go to the Random Encounter tables.
Figure out the environment the characters are currently in
Go to the environment section (in XGtE) the characters are currently in
Find the table to use based on the character level
Roll to find what creature is encountered
Roll to figure out how many creatures are randomly encountered
Add the creatures to the encounter in the Encounter Builder
Save the encounter in the Encounter Builder
Press the Run button to start the Random Encounter
The process is pretty straight forward but things aren’t that easy. Lucky for us, the Encounter Builder and XGtE has everything we need to build the encounter except the environment.
Asking Questions and Reading
For this project, I chose to use Microsoft’s Power Automate Desktop as my RPA tool of choice. There are many great vendors out there (I really like UiPath too) and I chose Microsoft’s tool because it was free. Power Automate Desktop allows you to read information on the screen and prompt the user for information.
I prompt the user to enter an environment. The environment will be used to load the appropriate random encounter tables in XGtE.
We also need to read information from the Encounter Builder like average party level. Further, we need to read results from the random encounter table in XGtE. We’ll get results like:
1d3 ice mephits
1d6 + 1 orcs
Single-file tracks in the snow that stop abruptly
How can we figure out what to do next? We found an encounter in the random encounter tables but what does that sentence mean? How do we translate it to action for the Encounter Builder?
NLP to the rescue
Natural Language Processing (NLP) is a study of Artificial Intelligence that focuses on understanding human language. Using NLP, I can break apart the statement and extract dice rolls, modifiers, and creatures. Simple parsing gets complicated when you have statements like:
1d3 winged kobolds with 1d6 kobolds or 1d4 + 3 giant rats
and the next entry is as simple as:
A pit in the floor
Using Luis.ai, I built an NLP model to understand the results of the encounter table. Breaking the statements down, I can extract the roll from any modifiers and get a list of creatures. Using Luis.ai, I broke down the encounter statement to be:
Roll: What is the #d# to determine how many creatures exist
Modifier: What is the “plus #” to add to the roll
Creature: What is the name of the creature to select in the encounter creator list.
This gave me all the information I need to select and populate the encounter using the encounter builder.
What if it is not a Creature?
It is possible that you will get an environmental hazard instead of a creature. For this I set up logic in the RPA bot that if a creature is not found, then alert the user and don’t use the encounter builder.
How does the NLP system know if what is found is a creature? Using machine learning the NLP system compares what it thinks is a creature in the statement to known creatures and the position of creatures in the analyzed text to guess if the word(s) are a creature. Each analyzed creature in the returned NLP object is given a confidence level which is the percent of confidence the machine learning system has as to whether or not the word(s) are a creature. Anything over 90%, I assume is a creature.
That’s how I roll: Randomly
With the power of NLP, I now know which creatures to have in the encounter and I know the rolls to figure out how many to have. Now I need to resolve the count and figure out if we have 1 kobold or 6.
To do this, I used random number generators with the dice creating the upper limit for the random number. A d12 would create a random number between 1 and 12. A d4 would be random between 1 and 4. Then, I use the first number of the roll to loop through the random number generator and add together all the results. A 3d4 kobolds would loop through the 1 - 4 random number generator 3 times and add all the results together for a total number of kobolds.
Now to build the encounter
Finally, using the powers of RPA, I search for the creature in the encounter builder “Kobold” and then click the “Add” button the number of times resolved from the total above.
After the encounter is built, I manually add a name to the encounter and then save it. From here, we can launch into the encounter and treat my players to a surprise.
Why not just do this all manually?
Creating a random encounter can be distracting from the story. Automation is supposed to help you focus on what’s important. Building a random encounter to snap your players out of spinning their wheels or shock them into a new direction, whatever your purposes are for your random encounter, don’t stop the story to do paperwork. Automate so you empower yourself to stay in the story, to stay with your players and keep the fun flowing.