Dungeons and Dragons, like other role-playing games, is hard to get into and fully understand. We wanted to make a helpful app that will take some inputs like a physical dice roll and a MadLibs for some keywords, and use those to generate a scenario. This scenario can be used as a hook to plan a full adventure, and this project can be expanded in the future to generate full character sheets, settings, and other campaign details.

What it does

The user fills out the MadLib-style form and rolls 4 six sided dice into the tray under the webcam. The system scans the dice using OpenCV and imports the MadLibs keywords to create a randomized adventure from a set of templates.

How we built it

We used OpenCV and python to detect the total number of pips between the four dice and sums them together. The python script then uploads the sum to This sum is used as a key to choose which adventure template will be used, and the MadLibs keywords are filled in throughout the template.

Challenges we ran into

Surprisingly, computer vision is hard. It took a while to implement the diceParser that reads the dice. The initial runtime of the diceParser script was nearly 20 seconds at first, but we narrowed it down to less than a second. We also had some trouble connecting the dice-reading program to the MadLibs and adventure generating program, but were able to solve this by integrating socket-io.

Accomplishments that we're proud of

The hardest part of this project was reading in values from the physical dice rolls. The python script removes everything in the captured video except for the dice themselves. Then, the script accounts for lighting and we count the number of pips on the dice. We had to make a lot of changes to the way we are parsing in data, but eventually we were able to very effectively read in the result from a dice roll in a wide variety of lighting conditions.

What we learned

We learned a lot about computer vision and web development while we were working out issues with the project, and learned how to use regex in javascript to fill in the adventure templates.

What's next for Dungeons And MadLibs

The next steps are to expand this to generate full character sheets and campaigns rather than just a short adventure hook. We would also like to add more templates to it in the current state.

Share this project: