Talk:Cellular Automata Method for Generating Random Cave-Like Levels

From RogueBasin
Jump to: navigation, search

I used this method on my game (Arcan Myth RL but only in developing version) but I limited the repetition cycle to 3: I like the result very much and I don't have the problem about big isolated cave. However very good method. Thank you :-) --Provolik

(Moved from article --Lethosor (talk) 21:33, 29 November 2014 (CET))


Regarding the blocks of code in the article

I think the article would be better if we removed the large blocks of C and C# code and simply link to all the examples for each different language under a section at the bottom, it simply takes up too much space. This way, all the different implementations and their credit will be evenly represented and accessible in one place. If no one voices their objection, I will change it.


AdamWhitehat (talk) 01:16, 21 July 2013 (CEST)

I'm fine with moving the code somewhere else, but I like having it on the wiki somewhere. Maybe moving the code samples to a subpage (for example, Cellular Automata Method for Generating Random Cave-Like Levels/Examples) would be less intrusive (and it could be linked to from the article as well). --Lethosor (talk) 16:15, 25 July 2013 (CEST)

Solving isolated caves

Thanks for this useful article. I implemented this scheme in python to play around with it some. I have a few comments and suggestions.

  • The author goes to some additional trouble (the tricks) to get rid of isolated cave areas and small, isolated clumps of wall tiles. These tricks were only partially successful, so he still needs an additional technique for getting rid of the isolated cave areas. The tricks require additional CA iterations, some with a larger footprint. This additional calculation could start to be a problem for my implementation in Python, if the maps are large and the hardware is slow.
  • My suggestion would be to run the CA 2-4 times using the 4-5 rule only. Then find the isolated cave areas and then fill in the small areas and connect the large ones. (yeah, large and small depends on your map and what you are trying to do with it) Finding the isolated areas (and filling small areas) is easy and fast with a simple flood fill algorithm. (here's one: [1]) Connecting the areas is conceptually easy, but I am not happy with any method I have tried so far.
  • Running the CA only twice yields very craggy caves with lots of small passages, small clumps of wall tiles, and isolated cave areas. Running it more (the caves don't change much after 4 iterations) yields smoother caves, with fewer of those features. Different designers will prefer the craggier or smoother caves--it also might be useful to randomly select the number of CA iterations to lend some more variety to the generated caves.

--Eratosthenes 16:01, 10 October 2009 (UTC)

Here is my solution to solving isolated caves: After filling in the map randomly with walls, I then set a horizontal strip in the middle to have no walls (or vertical if your map is taller than it is wide). This almost eliminated any isolated caves from forming. I think 2 blocks thick was what I used in my implementation. Using a flood fill algorithm in your logic will provide a more robust cave generating solution.

AdamWhitehat (talk) 01:28, 21 July 2013 (CEST)

My implementation in Javascript

See here: http://gist.github.com/516501

It's quite nice. Well, by my standards anyway. Here are the author's rules implemented in this builder style:

var cave = new Cave(70, 24, 0.55);

cave.mapTimes(4, function(cell, x, y) {
    return this.tilesAround(x, y, 1) >= 5;
  }).display();

cave.mapTimes(5, function(cell, x, y) {
    return this.tilesAround(x, y, 1) >= 5 ||
           this.tilesAround(x, y, 2) <= 2;
  }).display();

cave.mapTimes(5, function(cell, x, y) {
    return this.tilesAround(x, y, 1) >= 5 ||
           this.tilesAround(x, y, 2) <= 2;
  }).mapTimes(3, function(cell, x, y) {
    return this.tilesAround(x, y, 1) >= 5;
  }).display();
Personal tools