Struct MazeSettings
Settings for the Recursive Backtracker maze generation algorithm, invoked via ProceduralMapGenerator. Controls two optional post-generation passes - dead-end removal and loop creation - that transform a perfect maze into a more game-friendly layout. Operates on square grids only.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct MazeSettings
Remarks
The Recursive Backtracker algorithm generates a perfect maze - a spanning tree of passages with exactly one path between any two cells and no loops. The two settings here apply after the maze has been generated:
-
Dead-end removal (DeadEndRemovalRatio) - floor cells
with only one open neighbour are called dead ends. The algorithm repeatedly
fills in a random fraction of these dead ends with walls, shortening corridor
fingers and opening up interior areas. A ratio of
0preserves all dead ends (pure perfect maze); a ratio of1removes every dead end until none remain. -
Loop creation (LoopCreationRatio) - interior wall cells
adjacent to two or more floor cells can be broken to create shortcuts and
loops. The algorithm randomly removes a fraction of eligible interior walls.
A ratio of
0preserves the perfect maze structure; higher values increase connectivity and create multi-path areas.
MazeSettings is also embedded inside MazeRoomSettings to control the maze backbone when using the Maze-with-Rooms composite algorithm.
Use the static presets (Default, Imperfect,
Open) as starting points. All fields are readonly;
use Lerp(MazeSettings, MazeSettings, float) to smoothly transition between configurations.
Constructors
MazeSettings(float, float)
Initializes a new MazeSettings with explicit control over post-generation modification passes.
Declaration
public MazeSettings(float deadEndRemovalRatio = 0, float loopCreationRatio = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deadEndRemovalRatio | Fraction of dead-end floor cells to fill with walls after generation. Must be
in |
| float | loopCreationRatio | Fraction of eligible interior walls to break for loop creation. Must be in
|
Fields
DeadEndRemovalRatio
Fraction of dead-end floor cells to remove after maze generation. A dead-end cell is a floor cell with exactly one open (floor or corridor) neighbour. The pass randomly fills the specified fraction of all identified dead ends with walls.
A value of 0 leaves the maze as a perfect maze with all dead ends
intact. A value of 1 removes dead ends iteratively until none remain,
which can significantly alter the layout. Values in between produce
progressively less finger-heavy layouts. Must be in [0, 1].
Declaration
public readonly float DeadEndRemovalRatio
Field Value
| Type | Description |
|---|---|
| float |
Default
Produces a pure perfect maze: no dead-end removal and no loops. Every pair of cells has exactly one path between them. Best used when a classical puzzle-maze feel with a unique solution is desired.
Declaration
public static readonly MazeSettings Default
Field Value
| Type | Description |
|---|---|
| MazeSettings |
Remarks
Specific values: DeadEndRemovalRatio=0.0, LoopCreationRatio=0.0.
Imperfect
Produces a moderately modified maze with some dead ends removed and a small number of loops added. Creates a more natural dungeon-corridor feel while retaining most of the maze's structural complexity.
Declaration
public static readonly MazeSettings Imperfect
Field Value
| Type | Description |
|---|---|
| MazeSettings |
Remarks
Specific values: DeadEndRemovalRatio=0.3, LoopCreationRatio=0.1.
LoopCreationRatio
Fraction of removable interior wall cells to break in order to create loops after maze generation. An eligible wall cell is one that is surrounded on at least two opposite sides by floor cells, meaning breaking it would create a shortcut or merge two passages.
A value of 0 preserves the perfect tree structure with no loops.
A value of 0.2 breaks roughly 20% of eligible walls, creating
multiple alternative paths. Values closer to 1 produce highly
connected, arena-like open areas. Must be in [0, 1].
Declaration
public readonly float LoopCreationRatio
Field Value
| Type | Description |
|---|---|
| float |
Open
Produces a heavily modified maze with aggressive dead-end removal and many loops, creating large open areas connected by wide networks of passages. Suitable for action-oriented levels where navigation should feel open and permissive.
Declaration
public static readonly MazeSettings Open
Field Value
| Type | Description |
|---|---|
| MazeSettings |
Remarks
Specific values: DeadEndRemovalRatio=0.7, LoopCreationRatio=0.3.
Methods
Lerp(MazeSettings, MazeSettings, float)
Linearly interpolates between two MazeSettings instances and returns the blended result.
Declaration
public static MazeSettings Lerp(MazeSettings a, MazeSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| MazeSettings | a | The start settings returned when |
| MazeSettings | b | The end settings returned when |
| float | t | Interpolation factor in the range |
Returns
| Type | Description |
|---|---|
| MazeSettings | A new MazeSettings whose fields are blended between
|
Remarks
Both DeadEndRemovalRatio and LoopCreationRatio are
interpolated continuously. t is clamped to [0, 1]
before any calculation.