Struct CellularAutomataSettings
Settings for the Cellular Automata (CA) map generation algorithm, invoked via ProceduralMapGenerator. Controls the initial random wall fill, the number of simulation iterations, and the birth/death neighbour thresholds that govern how cells transition between wall and floor states.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct CellularAutomataSettings
Remarks
The CA algorithm operates in two phases:
- Initial fill - every cell on the grid is independently set to wall with probability InitialFillRatio or to floor otherwise. Higher values produce denser initial walls and, after simulation, more solid cave rock; lower values produce more open starting conditions.
-
Simulation - the grid is evolved for Iterations steps.
At each step the following rules are applied simultaneously to all cells:
<ul><li> A <b>floor cell becomes a wall</b> (birth rule) if the count of wall neighbours is greater than or equal to <xref href="Scylla.Core.Util.ProceduralMapGen.CellularAutomataSettings.BirthThreshold" data-throw-if-not-resolved="false"></xref>. </li><li> A <b>wall cell becomes a floor</b> (death rule) if the count of wall neighbours is strictly less than <xref href="Scylla.Core.Util.ProceduralMapGen.CellularAutomataSettings.DeathThreshold" data-throw-if-not-resolved="false"></xref>. </li></ul> The neighbourhood used for counting is either 4-cell Von Neumann or 8-cell Moore, controlled by <xref href="Scylla.Core.Util.ProceduralMapGen.CellularAutomataSettings.UseVonNeumann" data-throw-if-not-resolved="false"></xref>. For hex grids the neighbourhood is always the 6 axial neighbours; <xref href="Scylla.Core.Util.ProceduralMapGen.CellularAutomataSettings.UseVonNeumann" data-throw-if-not-resolved="false"></xref> is ignored. </li></ol>Use the static presets (Default, Smooth, Rough) as starting points. All fields are
readonly; use Lerp(CellularAutomataSettings, CellularAutomataSettings, float) to smoothly transition between configurations.
Constructors
CellularAutomataSettings(float, int, int, int, bool)
Initializes a new CellularAutomataSettings with explicit control over all simulation parameters.
Declaration
public CellularAutomataSettings(float initialFillRatio = 0.48, int iterations = 5, int birthThreshold = 5, int deathThreshold = 4, bool useVonNeumann = false)
Parameters
| Type | Name | Description |
|---|---|---|
| float | initialFillRatio | Probability of each cell starting as wall during the initial random fill.
Must be in |
| int | iterations | Number of CA simulation iterations to execute. Defaults to |
| int | birthThreshold | Wall neighbour count at which a floor cell becomes a wall. The rule fires when
the count is greater than or equal to this value. Defaults to |
| int | deathThreshold | Wall neighbour count below which a wall cell becomes a floor. The rule fires
when the count is strictly less than this value. Defaults to |
| bool | useVonNeumann | When |
Fields
BirthThreshold
The minimum number of wall neighbours required for an empty (floor) cell to
become a wall on the next iteration. A floor cell whose wall neighbour count
is greater than or equal to this threshold is converted to a wall. Higher
values make birth less likely, producing more open cave areas; lower values
make birth more aggressive, filling in gaps. Typical range: 4-6.
Declaration
public readonly int BirthThreshold
Field Value
| Type | Description |
|---|---|
| int |
DeathThreshold
The minimum number of wall neighbours a wall cell must have to survive into the
next iteration. A wall cell whose wall neighbour count is strictly less than
this threshold is converted to floor. Higher values make death more aggressive,
eroding thin wall structures; lower values preserve more wall cells.
Typical range: 3-5.
Declaration
public readonly int DeathThreshold
Field Value
| Type | Description |
|---|---|
| int |
Default
A balanced preset that produces natural-looking cave systems suitable for most dungeon and cave map types. Uses a near-50% initial fill, five iterations, and classic 5/4 thresholds with Moore neighbourhood.
Declaration
public static readonly CellularAutomataSettings Default
Field Value
| Type | Description |
|---|---|
| CellularAutomataSettings |
Remarks
Specific values: InitialFillRatio=0.48, Iterations=5, BirthThreshold=5,
DeathThreshold=4, UseVonNeumann=false.
InitialFillRatio
Probability that each grid cell is set to wall during the initial random fill
phase, before any CA iterations run. Must be in the range [0.0, 1.0].
A value near 0.5 produces a balanced starting state that converges into
distinct cave chambers. Values closer to 0.0 create very open starting
grids that may collapse into largely open areas; values closer to 1.0
create dense starting grids that may converge into solid walls.
Declaration
public readonly float InitialFillRatio
Field Value
| Type | Description |
|---|---|
| float |
Iterations
Number of CA simulation steps to execute after the initial random fill.
More iterations produce smoother, rounder cave shapes; fewer iterations
leave the output closer to the initial noise and result in more jagged,
irregular walls. A value of 0 skips simulation entirely and returns
the raw random fill.
Declaration
public readonly int Iterations
Field Value
| Type | Description |
|---|---|
| int |
Rough
A preset that generates more irregular, jagged cave walls by running fewer iterations. Produces a noisier, rougher aesthetic suitable for ancient or unstable underground passages.
Declaration
public static readonly CellularAutomataSettings Rough
Field Value
| Type | Description |
|---|---|
| CellularAutomataSettings |
Remarks
Specific values: InitialFillRatio=0.50, Iterations=3, BirthThreshold=5,
DeathThreshold=4, UseVonNeumann=false.
Smooth
A preset that generates smoother, more rounded cave chambers by running more iterations. Suitable for large open cavern environments where smooth organic shapes are preferred over jagged walls.
Declaration
public static readonly CellularAutomataSettings Smooth
Field Value
| Type | Description |
|---|---|
| CellularAutomataSettings |
Remarks
Specific values: InitialFillRatio=0.47, Iterations=7, BirthThreshold=5,
DeathThreshold=4, UseVonNeumann=false.
UseVonNeumann
When true, use the 4-cell Von Neumann neighbourhood (orthogonal
neighbours only: north, south, east, west) for counting wall neighbours on
square grids. When false, use the 8-cell Moore neighbourhood (all
orthogonal and diagonal neighbours). Von Neumann adjacency tends to produce
blockier, more rectilinear cave shapes; Moore adjacency produces smoother,
rounder results.
This field is ignored for hex grids, where the neighbourhood is always the 6 axial neighbours.
Declaration
public readonly bool UseVonNeumann
Field Value
| Type | Description |
|---|---|
| bool |
Methods
Lerp(CellularAutomataSettings, CellularAutomataSettings, float)
Linearly interpolates between two CellularAutomataSettings instances and returns the blended result.
Declaration
public static CellularAutomataSettings Lerp(CellularAutomataSettings a, CellularAutomataSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| CellularAutomataSettings | a | The start settings returned when |
| CellularAutomataSettings | b | The end settings returned when |
| float | t | Interpolation factor in the range |
Returns
| Type | Description |
|---|---|
| CellularAutomataSettings | A new CellularAutomataSettings whose fields are blended between
|
Remarks
InitialFillRatio is interpolated continuously. Integer fields
(Iterations, BirthThreshold,
DeathThreshold) are interpolated and rounded to the nearest
integer. UseVonNeumann switches from a to
b at t = 0.5.
t is clamped to [0, 1] before any calculation.