Show / Hide Table of Contents

Class CellularAutomataAreaGenerator

Implements a cellular automata genereation algorithm to add cave-like (unconnected) areas to a map. A connection algorithm would be needed to connect these areas. For automatic connection, see GenerateCellularAutomataMap(ISettableMapView<Boolean>, IGenerator, Int32, Int32, Int32).

Inheritance
System.Object
CellularAutomataAreaGenerator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GoRogue.MapGeneration.Generators
Assembly: GoRogue.dll
Syntax
public static class CellularAutomataAreaGenerator
Remarks

Generates a map by randomly filling the map surface with floor or wall values (true and false respectively) based on a probability given, then iteratively smoothing it via the process outlined in the cited roguebasin article. After generate is called, the passed in map will have had a value of true set to all floor tiles, and a value of false set to all wall tiles. Based on the C# roguelike library RogueSharp's implementation, and the roguebasin article below: http://www.roguebasin.com/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels. It is guaranteed that the "set" function of the map passed in will only be called once per tile.

Methods

| Improve this Doc View Source

Generate(ISettableMapView<Boolean>, IGenerator, Int32, Int32, Int32)

Generates the areas. Floor tiles will be set to true in the provided map, and wall tiles will be set to false.

Declaration
public static void Generate(ISettableMapView<bool> map, IGenerator rng = null, int fillProbability = 40, int totalIterations = 7, int cutoffBigAreaFill = 4)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to fill with values when generate is called.

Troschuetz.Random.IGenerator rng

The RNG to use to initially fill the map. If null is specified, DefaultRNG is used.

System.Int32 fillProbability

Represents the percent chance that a given cell will be a floor cell when the map is initially randomly filled. Recommended to be in range [40, 60] (40 is used in the roguebasin article).

System.Int32 totalIterations

Total number of times the cellular automata-based smoothing algorithm is executed. Recommended to be in range [2, 10] (7 is used on roguebasin article).

System.Int32 cutoffBigAreaFill

Total number of times the cellular automata smoothing variation that is more likely to result in "breaking up" large areas will be run before switching to the more standard nearest neighbors version. Recommended to be in range [2, 7] (4 is used in roguebasin article).

  • Improve this Doc
  • View Source
Back to top Generated by DocFX