Interesting cave systems can be created using ROT.Map.Cellular
, a generator which simulates a cellular automaton. Using this generator is a bit more complex,
because it offers richer features and is more configurable.
Apart from the traditional width and height arguments, ROT.Map.Cellular
accepts also a configuration object with the following optional keys:
born
– array of neighbor counts; when an empty cell has this number of neighbors, a new cell is bornsurvive
– array of neighbor counts; when an existing cell has this number of neighbors, it will survive into next iterationtopology
– how are neighbors defined: a cell can have four, six or eight neighbors. Six neighbors correspond to the "hex" layouting algorithm
of ROT.Display.It is also possible to initialize/set values for the first generation of cells. Two methods are provided:
set(x, y, value)
to directly set a cellrandomize(probability)
set all cells to "alive" with a given probability (0 = no cells, 1 = all cells)It is possible (and desirable) to call the create
method repeatedly: every call will create a new generation. There is no need to specify a callback,
if you only want to advance into next generation, without actually retrieving the current map data. By default, the born and survive options
are set according to this Roguebasin article.
ROT.Map.Cellular
uses the following callback values:
0
: no cell1
: alive cell