Project Pinion Progress 01/16/22


May 14, 2020
Hello! This is the very first developer log/progress update for Athios’ Project Pinion that was announced last year. We held many meetings and developed a lot of ideas that we want to share with you! For this post, I really wanted to focus on one of the main parts of the project: generating the tower/dungeon. You can look forward to other posts by other staff members regarding different aspects to the gamemode in the future. This will be a fairly technical, behind-the-scenes look at what I’ve been up to.
Like most things (granted you have some experience), procedural dungeon generation might initially sound easy. However, there were big questions I had to tackle:
  1. How will rooms be built?
  2. How will they be placed in the world?
  3. How do I connect these rooms?
  4. Where do I put the start, end?
The most popular form of dungeon building I’ve seen involves rooms and corridors being shaped and built by the generator (see this article), but because Minecraft is a 3d game, it’s quite hard to do that in an aesthetic way (we don't just want flat walls!). My main inspiration for the algorithm I put together was Zorbus (reddit post), which had a dungeon-generator that allowed for me to see dungeons being built step by step. Zorbus also uses a pre-built room approach, which is what we intend to have.
My Algorithm
The biggest challenge I had to face was room collision. I could’ve just made every room into a rectangle and made it easy to detect room collisions, but that would lead to a lot of false-positives and create a far smaller dungeon than I wanted. It would also limit how wacky we could get with the shapes of rooms. To solve this, rooms are saved with a “collision map” that tracks which x- and z- coordinates have blocks on them (the Y coordinate is irrelevant, dungeon floors won’t vary in height that much). When the dungeon is being placed, it also has its own collision map that tracks the composite x- and z- coordinates and can quickly compare with room collision maps. I could have compared the block locations directly, but that would take up a lot of memory and severely limit the amount of rooms that can be placed. With this approach, I’m able to read collision maps extremely quickly and compare them extremely quickly with little memory usage. Here is a picture of the first dungeon created with my algorithm:

Wow! A dungeon!
After working out some of the bugs, I was able to generate this dungeon:
The main issue with this dungeon was the lack of rotations; notice that all the pieces have the same orientation. To solve this, every room file is read by the dungeon builder and rotated, and it turns 1 room into 4! After a bit more math to rotating the collision map and knowing where to place the Minecraft structure, my dungeons were looking like this:

Very exciting! A cool part about this builder is that the generations are seeded, just like a Minecraft world. Each dungeon has its own seed and can be recreated with the same seed. These two dungeons have approximately 450 rooms, take less than 2 seconds to generate, and around a minute to place (Minecraft isn’t too optimized with structure placements!). At this point, the main limiting factor is the JVM Stack Size; A.K.A. needs more ram! When given 4x the stack size, I was able to generate a 1800 room dungeon in about 5 seconds, but took 6 minutes to place.

I do want to clarify, these timings can’t be expected of the final product as this is very bare bones generation. Also, we don't plan to make dungeon floors nearly as big (the 1800 room version is around 1,000x1,000 blocks). These are stress tests to show off how good my algorithm is.

Here are some more pictures from the dungeon building process:
What’s Next?
The team has been working really hard to develop the concepts and ideas for other parts of the gamemode. This is just one small part that didn’t require a lot of specifics to get started, so I did! As far as an ETA, I can’t give you one, but our goal is to have a basic dungeon playable by summer. Stay tuned for more Project Pinion Progresses!

Log in

Join our Discord!

Members online

No members online now.

Forum statistics

Latest member