Jump to content
  • Advertisement
Sign in to follow this  
phi6

Unity My Procedural Dungeon Generation Algorithm Explained for my game TinyKeep

This topic is 1969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

For a school assignment (a simple one, which is why) I added something similar. Of course it was not as good at creating dungeons, it had a similar idea of creating random rooms first then connecting them. Yours is a lot better in the fact that you use some very simple and effective algorithms to achieve a nice balance of distance and size of rooms. Your hallways (or what connects the rooms) are also a lot better, since mine were only straight lines. I also like the fact that there are no flaws, like mine could spawn you into a room with nowhere to go to. 

 

I'll also check out your game, as it seems pretty well thought out.

 

Happy coding!

Share this post


Link to post
Share on other sites

This is an interesting Top-Down approach.

 

Personally, I am more a fan of a Bottom-Up approach, where I keep adding and connecting rooms one by one, with random amount of smaller leafs - e.g. random depth (a range from 0-5) from the main corridor.

 

 

This way, I am guaranteed that the main quest items can be found easily, since the algorithm doesn't put them in the last leafs (which is frustrating from a player's perspective).

 

Also, since I am adding one main room after another (in a snake-like manner/shape), I keep generating and precomputing the pathfinding - thus making the in-game pathfinding reduced to 5-10 if..else conditions (which is plenty fast for a cell phone, even).

 

I can see, however, that it is pretty hard for you to generate some longer narrow corridors (with nowhere to dodge/escape) - which, personally, seem to be a big part of a dungeon crawler.

Share this post


Link to post
Share on other sites

It's always interesting to see someone else's take on something like dungeon/connected rooms generation. I'm curious.. is there much overhead in the part of the algorithm which moves the random rooms until they're not overlapping?

Share this post


Link to post
Share on other sites

This is an interesting Top-Down approach.

 

Personally, I am more a fan of a Bottom-Up approach, where I keep adding and connecting rooms one by one, with random amount of smaller leafs - e.g. random depth (a range from 0-5) from the main corridor.

 

 

This way, I am guaranteed that the main quest items can be found easily, since the algorithm doesn't put them in the last leafs (which is frustrating from a player's perspective).

 

Also, since I am adding one main room after another (in a snake-like manner/shape), I keep generating and precomputing the pathfinding - thus making the in-game pathfinding reduced to 5-10 if..else conditions (which is plenty fast for a cell phone, even).

 

I can see, however, that it is pretty hard for you to generate some longer narrow corridors (with nowhere to dodge/escape) - which, personally, seem to be a big part of a dungeon crawler.

 

Hmm, I do agree - Bottom-Up approaches tend to be more natural for gameplay as it almost simulates how one would explore the dungeon! Does your algorithm allow for loops or is it very much a tree? I tried this in the past to create a tree, but found it difficult to create an elegant way to loop back.

 

It's always interesting to see someone else's take on something like dungeon/connected rooms generation. I'm curious.. is there much overhead in the part of the algorithm which moves the random rooms until they're not overlapping?

 

I haven't done any serious tests, but if I turn off all the graphical visualizations the entire generation takes less than a second. There is probably quite a lot of overhead for sure but it's a one-time operation. I'll let you know when I have more specific results.

Share this post


Link to post
Share on other sites

If it takes under a second, then it is nothing to worry about during level loading. The textures alone will take longer to load than that, for sure. I was asking, since you mentioned using several of the trees, and some types of trees are very intensive - but it is clearly not the case here.

 

As for my loops - it is also more of an hack. it does not work 100%, since the conditions for the loop must be right (and I'd have to pay attention to the "loopability" during creation process - which is still something I need to do).

 

 

 

BTW, did you find an artist willing to work for royalties, or do you have a contracted artist ? I liked the art, for sure !

Share this post


Link to post
Share on other sites

I think you're right there, making loops I found very difficult.

Here's a really really early test I made in 2011, completely tree based and bottom up approach, and there's no loops.

 

http://phigameslib.org/prototypes/dungeon/

 

An interesting discussion for sure!

 

Regarding the art, it was made by Matthias Andre from bitgem3d.com

The assets I used for the prototype are royalty free from his portfolio, but he has agreed to do more art for me if we get funded.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!