Temple of The Roguelike Forums

Development => Programming => Topic started by: volos314 on May 21, 2007, 09:23:54 PM

Title: Labyrinth generation
Post by: volos314 on May 21, 2007, 09:23:54 PM
Do you now any ways to generate "original" levels?
I've implemented a kind of different maze in my game, but I need some more algorithms. I think it's important to create levels with various design, that's why I strongly need more maze-gen algorithms.
Title: Re: Labyrinth generation
Post by: Grue on May 22, 2007, 04:31:13 PM
You can try cellular automata algorithm (never seen this one put to good use). If you take the Game of Life and change the parameters (when cells die and appear) you'll get stable maze-like structures. I don't remember the right parameters off the top of my head, but you can play with various freely available Game of Life simulators to find them.
Title: Re: Labyrinth generation
Post by: Slash on May 22, 2007, 04:56:24 PM
You can try cellular automata algorithm (never seen this one put to good use).
What??? CvRL and Drash use cellular automata :D

Maybe their maps arent that good :)
Title: Re: Labyrinth generation
Post by: Grue on May 23, 2007, 09:32:36 PM
I wasn't aware of it. Pretty cool!
Title: Re: Labyrinth generation
Post by: Slash on May 23, 2007, 09:47:57 PM
I also forgot to add ZeldaRL, which uses the most complex cellular automata of all them; it isn't used for labyrinths or caves but rather for the overworld... ending up in something like this: (although this one is a bit outdated)

(http://www.santiagoz.com/share/zrl2.gif)
Title: Re: Labyrinth generation
Post by: stu on May 25, 2007, 01:23:16 AM
I use CA in Cracks and Crevices and also in Fishguts.

Title: Re: Labyrinth generation
Post by: Slash on May 31, 2007, 08:28:27 PM
Fishguts?? :P
Title: Re: Labyrinth generation
Post by: stu on June 07, 2007, 02:06:50 PM
Fishguts?? :P

the name of my normal CRPG :) well it was just a codename but I havnt been able to think up a nice 1 or 2 word name
Title: Re: Labyrinth generation
Post by: Gamer_2k4 on June 29, 2007, 09:56:17 PM
Does it have to be a maze?  I have a pretty decent generator that makes good caves using a raycasting technique.
Title: Re: Labyrinth generation
Post by: Rabiat on July 11, 2007, 08:53:39 AM
Sorry if I'm stating the obvious, but maybe this could serve as a starting point for those who are unfamiliar with maze generation. Here are some widely used, basic techniques to create mazes:


These are just basic approaches, and each requires some postprocessing to create a playable Roguelike map. By themselves, none of them will produce nice NetHack or Angband style maps. Recursive subdivision doesn't create twisty tunnels, Prim and Kruskal don't make rooms at all, and the 'overlapping shapes' technique doesn't create very nice rooms or tunnels, just a roughly hewn cave. The advantage of all techniques is that they can be used to guarantee connected mazes (i.e. with no unreachable segments).

I've always liked perfect mazes as a starting point, but they involve lots of postprocessing. Creating loops in tunnels, filling up dead ends to free up space for rooms, inserting doors at appropriate places, etc.

Here's a couple of references I'd recommend:


I'd be very interested if anyone knows more techniques or references.
Title: Re: Labyrinth generation
Post by: Gamer_2k4 on July 11, 2007, 04:23:26 PM
Prim's/Kruskal's algorithms: fill a map with rock tiles, then dig out 1x3 sections, making sure each section overlaps with a single previously dug out tile. This creates a perfect maze, i.e. one that has a single path from one point to another. (Doesn't occur in any RLs that I know of)
The minotaur mazes in ADOM use this approach, I believe.

I'd be very interested if anyone knows more techniques or references.
Dungeondweller (http://www.roguelikedevelopment.org/php/category/showCategory.php?path=development/&category=MAP) has several articles about this sort of thing, as well as many other aspects of roguelike development.  Most of the articles have probably also been transferred to RogueBasin (http://roguebasin.roguelikedevelopment.org/index.php?title=Main_Page).
Title: Re: Labyrinth generation
Post by: Rabiat on July 31, 2007, 07:08:01 AM
Quote
You can try cellular automata algorithm (never seen this one put to good use).

There's an article on RogueBasin with some nice examples: Cellular Automata Method for Generating Random Cave-Like Levels (http://roguebasin.roguelikedevelopment.org/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels).
Title: Re: Labyrinth generation
Post by: Lummox JR on August 01, 2007, 04:18:22 AM
Whoa, I hadn't seen RogueBasin before. I've been to roguelikedevelopment.org--it's one of my favorites--but this is so much neater and more readable. Quite cool.

That cave article is a good one. Too bad the math symbols are lost to character formatting hell instead of using HTML entities, though. I never had much luck with the cave tests I tried before using the cellular automata technique, but this one looks very promising!

I like the idea of starting with an almost-connected cave and then completing connections as corridors that were dug into the main cave by past denizens. Some would lead to special rooms (like a monster's lair, treasure vault, etc.) as seen in those results, others to another wide cavern system, perhaps some ancient bazaar now an abode of monsters.
Title: Re: Labyrinth generation
Post by: Slash on August 01, 2007, 10:49:50 PM
Well, nice you found roguebasin... lots of info there!

About the Cellular Automata Algorithm, it sure is good for caves, but hey! there are lots of other uses for it, including post processing of fractal generated overworlds... basically. anything you need to make look organic following an example pattern :)
Title: Re: Labyrinth generation
Post by: Lummox JR on August 02, 2007, 07:51:38 PM
I kind of wonder if cellular automata would be good for forests as well, if it was modified to use some random rules. They follow a similar pattern after all. For instance, this might do nicely:

If no tree here
  If trees in radius 3 < 4
    If random(25%)
      Create tree
Else
  If other trees in radius 2 > 1
    If random(25%)
      Delete tree

A pattern of radius 3 is roughly 37 tiles, so 4 in 37 gives roughly 11% coverage, while the second rule is used to remove neighbors that are too close. There should still be plenty of cases of trees growing right next to each other, which is common, but not too many dense clumps.
Title: Re: Labyrinth generation
Post by: Slash on August 02, 2007, 09:27:29 PM
Have you seen CastlevaniaRL? it uses CA for the forests on the first levels

Putting trees based on the distance between them is a nice idea though... I will implement it and tell you how it looks! (that would be next weekend)