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 »

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: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post 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.
christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post 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.
christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post 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
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post by Jasoco »

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 »

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: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post 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.
christiankolding
Prole
Posts: 17
Joined: Sun Jul 22, 2012 11:15 am
Location: Copenhagen, Denmark
Contact:

Re: Random dungeon generator

Post 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?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Random dungeon generator

Post 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.
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: Random dungeon generator

Post by Lap »

I'm impressed. Good job.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 6 guests