Page 1 of 2

Random dungeon generator

Posted: Sun May 04, 2014 5:09 pm
by christiankolding
Hi guys,

I made a very simple random dungeon generator inspired by http://readmythings.com/blog/2013/02/20 ... -automata/.

Basically I just start by generating a random map of floors/walls and then apply some cellular automata rules to make it look a bit more pretty. Finally I remove all but the largest cavern.

Here is an example of a dungeon generated by my program:
Image

You can check it out here: https://github.com/christiankolding/lov ... -generator. Feedback would be much appreciated!

Re: Random dungeon generator

Posted: Mon May 05, 2014 5:10 am
by Jasoco
The flat straight edges look weird. I preferred to use this method myself:

http://www.roguebasin.com/index.php?tit ... ike_Levels

Image
(The square rooms and doors are post processing of course.)

So weird that everyone's getting into cave generation lately.

Re: Random dungeon generator

Posted: Mon May 05, 2014 8:42 am
by christiankolding
Yep, I definitely agree about the edges. Perhaps I should take a look at your method and see if I can implement it. Still brand new to using both Lua and LÖVE, though. But I guess it's a pretty good way to practice doing some simple algorithms.

Re: Random dungeon generator

Posted: Sun May 11, 2014 11:21 am
by christiankolding
I have improved the program now, such that it no longer generates the ugly borders. Thanks for linking the article. This is how an example dungeon looks now:

Image

Re: Random dungeon generator

Posted: Sun May 11, 2014 5:11 pm
by Jasoco
That looks a lot cleaner than what mine was doing. I like it. More of an actual cave.

Re: Random dungeon generator

Posted: Sat May 17, 2014 4:22 pm
by christiankolding
I have now added lava (orange), treasures (purple) and altars/power-ups (blue). Treasures are supposed to be nestled in corners, while altars should be in the open. I'm still looking for a way to generate these in a natural looking fashion and avoid that they cluster up as they sometimes do. I'm all ears if anybody knows of a good way to do this.

Image

Re: Random dungeon generator

Posted: Sat May 17, 2014 5:10 pm
by Jasoco
You could do post-processing like I do for doors where you check to make sure two of some thing aren't too close together and remove one if so, and keep doing that until no two are closer than a certain amount.

Re: Random dungeon generator

Posted: Sat May 17, 2014 5:13 pm
by christiankolding
Right, that sounds like a simple and effective way to do it. Is your project open-source so I can check out your code?

Re: Random dungeon generator

Posted: Sun May 18, 2014 3:39 am
by Jasoco
I don't know how my project would help as the code bases are probably vastly different. I don't even know if I have working code anymore that would do what you need. (Since I've had to rewrite so much and the doors thing is so messed up I need to start over.)

You'd probably just run through the same table in a nested loop within a loop and check the first against the second, find out which ones are close enough together, mark each pair for checking later. Then later go through each pair and delete one at random.

I dunno. Maybe it'd be easier to do the check at creation. Forget the post-processing. Instead, when placing an item or whatever, loop through all the ones that already exist and make sure it's not too close to the spot you're trying to place the new item at. That'd probably be much easier. Have a specific threshold for how close two can be.

Re: Random dungeon generator

Posted: Sun May 18, 2014 3:21 pm
by Lap
I'm impressed. Good job.