Author Topic: Cavern generation code  (Read 16040 times)

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Cavern generation code
« on: June 30, 2013, 04:33:34 AM »
Want to get some feedback on this generation method I've been working on.  Mainly, does it look cavern-y?

http://languard.koding.com/cave/Build.html

And source for those interested: http://languard.koding.com/cave/CaveGenDropMethod.zip

The general idea behind the algorithm is I drop splats onto the area.  To see what I mean, turn drops to 1 and drop size to different values to see what one drop looks like.  The more red an area is, the more likely it is to be floor.  Clicking convert changes the raw data into dungeon data (floor - white or wall - black) and cleanup does that, it removes the little orphan areas.

I can write more later, but I'm more than just a little time crunched for getting this month's #1GAM done :P

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: Cavern generation code
« Reply #1 on: June 30, 2013, 05:35:34 AM »
That's pretty nifty and looks very cavern-like.
Everyone you will ever meet knows something you don't.
 - Bill Nye

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Cavern generation code
« Reply #2 on: June 30, 2013, 08:29:09 AM »
1. Don't have unity web player installed, wont install it
2. If generation creates orphan areas in the first place it sucks

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: Cavern generation code
« Reply #3 on: June 30, 2013, 02:37:40 PM »
@Krice:
Fair enough on the unity plugin.  If you're truly interested in seeing it run I can build a stand-along version.

I am curious as to why a multi-pass algorithm is inherently worse than a single pass algorithm in your mind.  If I left all the tiny one or two space areas in, then I could see it being called inferior, but I don't.  They get cleaned up.  In fact I would argue the ability to create disconnected zones in the context of cavern generation a strength.  Take this cave for instance.  Coloring done in GIMP.

You could setup a series of portals, or 'narrow passage' or whatever you would want to call it to connect the different areas.  Also, performance is very good.  This dungeon is from a 56x34 area with 2500 size 3 drops, and it only took roughly a second to generate.  And if I wanted a single continuous, increasing the drops to around 3000 would do it rather nicely.

Darren Grey

  • Rogueliker
  • ***
  • Posts: 2019
  • Karma: +0/-0
  • It is pitch black. You are likely to eat someone.
    • View Profile
    • Games of Grey
Re: Cavern generation code
« Reply #4 on: June 30, 2013, 03:11:15 PM »
Looks nice. I like how it uses 4-way connectivity check - this is much better than allowing diagonal connected areas. I also like how it tends to make little islands/pillars.

One problem is it sometimes creates small levels bunched into the corner. When I had a similar algorithm I made it check that its max and min x and y coordinates were within 4 spaces of the map edges, so you'd never get a bunched up level.

Anyway, nice little algo, but go make some gameplay now  ;P

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Cavern generation code
« Reply #5 on: July 01, 2013, 03:58:41 AM »
Watch those diagonals.

4-way connectivity is nice, but the aesthetic is incomplete when diagonal edges between tiles still exist.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Cavern generation code
« Reply #6 on: July 01, 2013, 08:34:19 AM »
Looks nice.

Not only doesn't look nice, but it's not even ready yet (no connections).

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: Cavern generation code
« Reply #7 on: July 01, 2013, 08:53:35 AM »
Yep. Connections are the hardest part.
Fame (Untitled) - my game. Everything is a roguelike.

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: Cavern generation code
« Reply #8 on: July 01, 2013, 05:12:05 PM »
Not only doesn't look nice, but it's not even ready yet (no connections).

You are relentlessly pessimistic.  Say something nice every once in  a while.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Cavern generation code
« Reply #9 on: July 01, 2013, 07:51:08 PM »
Say something nice every once in  a while.

All I can say is that our culture is not full of pretending. In US everything is always "nice" and you guys "love" each other. What actually happens is that your culture is sick in the inside and you lie all the time.

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: Cavern generation code
« Reply #10 on: July 01, 2013, 08:06:35 PM »
I agree with your premise.  I appreciate blunt honesty.

But even so, things aren't all bad all the time.  It's one thing to have standards, and another to expect perfection.

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: Cavern generation code
« Reply #11 on: July 01, 2013, 08:45:26 PM »
Looks nice.

Not only doesn't look nice, but it's not even ready yet (no connections).

One hour tops to implement connections.  Maybe an extra hour to tiddy it up to make it as generic as possible., so I don't consider that a major hurdle, especially since if you configure the input values correctly you can get very large continuous zones.  The main reason behind the speed is how the data is stored, it is trivial to pick a random node in zone 1, a random node in zone 2, and bamf! connection.  Assuming you have to enter a command to go through it, as is the case with most rogue-likes.  Connections that auto-move you do suddenly become more interesting to place.

Keep in mind my intent with this is to create a general purpose generator that can be used in any C# based rogue-like.

Krice: Could you give me an example or two of algorithms that you consider good as far as cavern generation goes?

I agree with your premise.  I appreciate blunt honesty.

But even so, things aren't all bad all the time.  It's one thing to have standards, and another to expect perfection.
Some cultures are just like that, doesn't bother me.  My wife is from Taiwan, and she's like that (though considerably less...blunt ;) ) On the rare occasion she says good job I know I dun good.  The rest of the time is spent pointing out what could have been done better so it can be done better next time :P

Watch those diagonals.

4-way connectivity is nice, but the aesthetic is incomplete when diagonal edges between tiles still exist.
*sigh* Yes, it's something I've been struggling with.  I believe a good tileset rather than solid squares would hide this to some extent, but then it looses some of it's general application, since many rogue-likes don't use graphical tilesets.  You could of course hide it with a lighting engine, you can only see the area around you, so the player couldn't tell there was a space diagonal.  Still not ideal, I agree.

Anyway, nice little algo, but go make some gameplay now  ;P

Gameplay?  What's that? ;)

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Cavern generation code
« Reply #12 on: July 02, 2013, 04:35:06 AM »
You can fix the diag issue with a clean-up phase.

Yep. Connections are the hardest part.

Eh? Pray tell.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Cavern generation code
« Reply #13 on: July 02, 2013, 09:43:48 AM »
Krice: Could you give me an example or two of algorithms that you consider good as far as cavern generation goes?

It's kind of difficult, because caverns are just blobs, usually connected with corridors. However I think even caverns could be improved by looking at real caves and trying to figure out how they could be more cavernous. One important thing is of course what is in those caverns and how they are related to other structures in the level or game world in general.

However I can say that poor cavern generators create diagonals and loose tiles. Good cavern generators don't just create "random" generic blobs, but caverns can have distinctive, yet random shapes.

guest509

  • Guest
Re: Cavern generation code
« Reply #14 on: July 05, 2013, 07:40:45 AM »
Say something nice every once in  a while.

All I can say is that our culture is not full of pretending. In US everything is always "nice" and you guys "love" each other. What actually happens is that your culture is sick in the inside and you lie all the time.

1. Totally agree.
2. Go fuck yourself

Did I do good?  ;)