Creating custom RPG dungeon maps can be a daunting task, particularly for beginners or those short on time. Our project addresses this challenge by generating dungeon maps that consider both size and difficulty, ensuring coherent and accessible designs.
Our dungeon map generator takes the user-specified size and difficulty level to create a detailed dungeon map featuring interconnected rooms, paths, treasures, traps, and monsters. The process ensures no isolated rooms or paths, making every part of the dungeon accessible from the starting point.
First, using GPT-4, we generate an initial labyrinth map based on the desired size. This map consists solely of path and rock tiles, ensuring all path tiles are interconnected. A correction algorithm runs to eliminate any isolated paths, ensuring a fully connected labyrinth.
GPT-4 determines the dungeon's pixel dimensions and calculates the number of rooms, traps, treasures, and monsters based on the specified size and difficulty. The generated output is parsed to extract the correct number of events, which are then randomly placed on the path tiles, after which specific algorithms are run for applicable event tiles, such as expanding a room till into a fully formed room.
Each tile is then replaced with a corresponding pixel array. The final array of tiles is converted into a JPEG image, providing a visually appealing and practical dungeon map.
We used the minimal functioning concept when designing our project, where each step in the process was the next minimal step that still worked. After building a maze map, we ensured that the paths were all interconnected. We then added events, added the code to create rooms, and finally added improved graphics, where each tile was tied to an actual set of pixels.
The principal technical challenges faced were in properly parsing the return values from GPT-4 into our array, designing the correction algorithm, and getting good graphics.
The two principal issues with the parsing algorithm were that GPT-4 did not always use the same layout to return the values wanted, which made consistently extracting the correct values from the prompt difficult and required additional safety measures in case of incoherent values due to the extraction changing. Our solution was to ask for a python dictionary in the prompt, as that had the most consistent formatting, and to have default values in case of any changes in format.
The other difficulty was that it was unable to properly carry out chained commands, where the next command relied on the result of the previous one but had to be done afterwards. This meant that the rooms had to be created separately from the original paths and required a correction algorithm to ensure that they were properly connected.
Finally, the principal issue with the correction algorithm was to avoid too many connections between the paths, and to ensure all paths were connected. The final solution we used was Breadth-First Search algorithm to verify and connect every path. The main challenge when adding the graphics was preventing pixel loss during the graphic conversion process. We implemented verifications and additional checks, to maintain pixel integrity.
Built With
- openai
- python
Log in or sign up for Devpost to join the conversation.