Projects

dungeon_ai šŸ†

PyTorch
Python
FastAPI
MySQL
React
Tailwind CSS
SpringBoot

A full-stack web application meant to remove the need for a traditional D&D Dungeon Master and increase accessibility to new players by allowing users to generate scenarios, monsters, and images for their game using a mix of AI technologies.

A bright pink sheet of paper used to wrap flowers curves in front of rich blue background

View on GitHub


Iowa State Computer Science Hackathon 2023

Team Members: Logan Jorgensen, Sam McGrath, David Szczepanik, Eli Brady


Project Problem: Lack of Accessibility to Dungeons & Dragons

Our team decided to pursue this project to attempt to make a Dungeons & Dragons style experience that does not require an experienced individual to act as the Dungeon Master.

Description: A Web-Based Game Inspired by Dungeons & Dragons

dungeon_ai is a full-stack web application meant to increase accessibility to Dungeons & Dungeons style games by removing the need for an experienced Dungeon Master. The user can create a character and allocate their skill points to a pool of skills, and embark on an adventure to find treasure, encounter monsters, and explore.

Games consist of campaigns with three characters. The ā€˜virtual Dungeon Masterā€ is generated by AI. Both the storyline, as well as images for environments and player characters are generated using various AI technologies. The player photos are generated based on a userā€™s description. Story generation allows for wide variety of scenarios that the characters will experience in their playthrough, ensuring that no two playthroughs are the same.

The story generation is handled by making requests to the external OpenAI API, whereas AI-based image generation is done on the FastAPI application aspect of the project using Stable Diffusion.

The Tech Stack

Technologies Used: React, Tailwind CSS, Vite, SpringBoot (Java), FastAPI (Python), PyTorch

Tech Stack Logos

Project Structure

The project is split into three main directories:

  1. /frontend - Directory for the React frontend
  2. /backend - Directory for the SpringBoot backend
  3. /diffusion - Directory for the FastAPI StableDiffusion Application

The Frontend

Image of "Game" View Page Individual ā€œGameā€ view rendered with React

The frontend of dungeon_ai consists of several different views. React Router was used to assign the different views to routes:

  • ā€œGamesā€ view
    • View all of the current games that are saved or have been created previously, with an option to create a new game
  • ā€œGameā€ view
    • View information about a selected game based on its id, including past events, character information on the sidebar, and ability to roll the die to generate a new encounter
  • ā€œCreateā€ view
    • Create a new game, along with a set of new characters
  • ā€œCharacterā€ view
    • View more details about the current status of a specific character in a game (stats, health, description, etc.)


The Backend

Springboot Logo

All logic and data for the game is handled throught the backend via a SpringBoot application.

  • Handles storage via Hibernate & MySQL to store game information, history of game events, player data, etc.
  • Henerates new events for a game via some internal game logic combined with a prepared prompt which is sent to the OpenAI API
  • Generates a prepared prompt to send to the StableDiffusion FastAPI application in order to generate images for players and events that occur during the game
  • Feeds data to frontend via RESTful API requests

StableDiffusion / FastAPI

Some examples of character images generated by the model:
Image of a Warrior CharacterImage of Paladin CharacterImage of Another Paladin CharacterImage of a Ghoul Character
Image of Warrior CharacterImage of Another Paladin CharacterImage of Paladin CharacterImage of Ghoul Character

Running the Project

To run the frontend application locally with Vite / npm:
1. ā€œnpm iā€
2. ā€œnpm run devā€

To run the FastAPI StableDiffusion Model locally with an Nvidia GPU (CUDA): ā€œdiffuzers apiā€