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

From RogueBasin
Revision as of 01:53, 10 August 2010 by Gcr (talk | contribs) (→‎My implementation in Javascript: new section)
Jump to navigation Jump to search

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)

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:

   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();