Random dungeon generator

Showcase your libraries, tools and other projects that help your fellow love users.
christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Random dungeon generator

Post by christiankolding » Sun May 04, 2014 5:09 pm

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!
Last edited by christiankolding on Sun May 11, 2014 11:18 am, edited 2 times in total.

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post by Jasoco » Mon May 05, 2014 5:10 am

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.

christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post by christiankolding » Mon May 05, 2014 8:42 am

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.

christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post by christiankolding » Sun May 11, 2014 11:21 am

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

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post by Jasoco » Sun May 11, 2014 5:11 pm

That looks a lot cleaner than what mine was doing. I like it. More of an actual cave.

christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post by christiankolding » Sat May 17, 2014 4:22 pm

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

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post by Jasoco » Sat May 17, 2014 5:10 pm

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.

christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post by christiankolding » Sat May 17, 2014 5:13 pm

Right, that sounds like a simple and effective way to do it. Is your project open-source so I can check out your code?

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post by Jasoco » Sun May 18, 2014 3:39 am

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.

User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: Random dungeon generator

Post by Lap » Sun May 18, 2014 3:21 pm

I'm impressed. Good job.

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests