Show / Hide Table of Contents

Class QuickGenerators

Collection of algorithms that put map generation pieces together, in ways that allow you to quickly and easily generate a given type of map in a single function call. The implementation of these functions may also be used as the basis for implementing more customized generation processes.

Inheritance
System.Object
QuickGenerators
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
Assembly: GoRogue.dll
Syntax
public static class QuickGenerators

Methods

| Improve this Doc View Source

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

Generates a cave-like map using the cellular automata algorithm here: http://www.roguebasin.com/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels. See CellularAutomataAreaGenerator for details. This algorithm is identical, except that it connects the areas automatically afterward.

Declaration
public static IEnumerable<MapArea> GenerateCellularAutomataMap(ISettableMapView<bool> map, IGenerator rng = null, int fillProbability = 40, int totalIterations = 7, int cutoffBigAreaFill = 4)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map
Troschuetz.Random.IGenerator rng
System.Int32 fillProbability
System.Int32 totalIterations
System.Int32 cutoffBigAreaFill
Returns
Type Description
System.Collections.Generic.IEnumerable<MapArea>

Collection of areas representing the areas of the map before they were connected.

| Improve this Doc View Source

GenerateDungeonMazeMap(ISettableMapView<Boolean>, Int32, Int32, Int32, Int32, Single, Single, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Generates a dungeon map based on the process outlined here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/.

Declaration
public static IEnumerable<(Rectangle Room, Coord[][] Connections)> GenerateDungeonMazeMap(ISettableMapView<bool> map, int minRooms, int maxRooms, int roomMinSize, int roomMaxSize, float roomSizeRatioX = 1F, float roomSizeRatioY = 1F, int maxCreationAttempts = 10, int maxPlacementAttempts = 10, int crawlerChangeDirectionImprovement = 10, int minSidesToConnect = 1, int maxSidesToConnect = 4, int cancelSideConnectionSelectChance = 50, int cancelConnectionPlacementChance = 70, int cancelConnectionPlacementChanceIncrease = 10, int saveDeadEndChance = 0, int maxTrimIterations = -1)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

System.Int32 minRooms

Minimum amount of rooms to generate.

System.Int32 maxRooms

Maximum amount of rooms to generate.

System.Int32 roomMinSize

The minimum size of the room. Forces an odd number.

System.Int32 roomMaxSize

The maximum size of the room. Forces an odd number.

System.Single roomSizeRatioX

The ratio of the room width to the height. Defaults to 1.0.

System.Single roomSizeRatioY

The ratio of the room height to the width. Defaults to 1.0.

System.Int32 maxCreationAttempts

The max times to re-generate a room that cannot be placed before giving up on placing that room. Defaults to 10.

System.Int32 maxPlacementAttempts

The max times to attempt to place a room in a map without intersection, before giving up and re-generating that room. Defaults to 10.

System.Int32 crawlerChangeDirectionImprovement

Out of 100, how much to increase the chance of the crawler changing direction each step during maze generation. Once it changes direction, the chance resets to 0 and increases by this amount. Defaults to 10.

System.Int32 minSidesToConnect

Minimum sides of the room to process. Defaults to 1.

System.Int32 maxSidesToConnect

Maximum sides of the room to process. Defaults to 4.

System.Int32 cancelSideConnectionSelectChance

A chance out of 100 to cancel selecting sides to process (per room) while we are connecting them. Defaults to 50.

System.Int32 cancelConnectionPlacementChance

A chance out of 100 to cancel placing a door on a side after one has already been placed (per room) during connection.Defaults to 70.

System.Int32 cancelConnectionPlacementChanceIncrease

Increase the cancelConnectionPlacementChance value by this amount each time a door is placed (per room) during the connection process. Defaults to 10.

System.Int32 saveDeadEndChance

After the maze generation finishes, the small dead ends will be trimmed out. This value indicates the chance out of 100 that the dead end remains. Defaults to 0.

System.Int32 maxTrimIterations

Maximum number of passes to make looking for dead ends when trimming. Defaults to infinity.

Returns
Type Description
System.Collections.Generic.IEnumerable<System.ValueTuple<Rectangle, Coord[][]>>

A list of the interior of rooms generated, and the connections placed.

Remarks

First, non-overlapping rooms are randomly placed using RoomsGenerator. Then, a maze is generated into the remaining space using a MazeGenerator. Those mazes are then connected. The rooms are connected to the maze using a RoomDoorConnector, and finally, small dead ends are trimmed out.

| Improve this Doc View Source

GenerateDungeonMazeMap(ISettableMapView<Boolean>, IGenerator, Int32, Int32, Int32, Int32, Single, Single, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Generates a dungeon map based on the process outlined here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/.

Declaration
public static IEnumerable<(Rectangle Room, Coord[][] Connections)> GenerateDungeonMazeMap(ISettableMapView<bool> map, IGenerator rng, int minRooms, int maxRooms, int roomMinSize, int roomMaxSize, float roomSizeRatioX = 1F, float roomSizeRatioY = 1F, int maxCreationAttempts = 10, int maxPlacementAttempts = 10, int crawlerChangeDirectionImprovement = 10, int minSidesToConnect = 1, int maxSidesToConnect = 4, int cancelSideConnectionSelectChance = 50, int cancelConnectionPlacementChance = 70, int cancelConnectionPlacementChanceIncrease = 10, int saveDeadEndChance = 0, int maxTrimIterations = -1)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

Troschuetz.Random.IGenerator rng

The RNG to use. If null is specified, the default RNG is used.

System.Int32 minRooms

Minimum amount of rooms to generate.

System.Int32 maxRooms

Maximum amount of rooms to generate.

System.Int32 roomMinSize

The minimum size of the room. Forces an odd number.

System.Int32 roomMaxSize

The maximum size of the room. Forces an odd number.

System.Single roomSizeRatioX

The ratio of the room width to the height. Defaults to 1.0.

System.Single roomSizeRatioY

The ratio of the room height to the width. Defaults to 1.0.

System.Int32 maxCreationAttempts

The max times to re-generate a room that cannot be placed before giving up on placing that room. Defaults to 10.

System.Int32 maxPlacementAttempts

The max times to attempt to place a room in a map without intersection, before giving up and re-generating that room. Defaults to 10.

System.Int32 crawlerChangeDirectionImprovement

Out of 100, how much to increase the chance of the crawler changing direction each step during maze generation. Once it changes direction, the chance resets to 0 and increases by this amount. Defaults to 10.

System.Int32 minSidesToConnect

Minimum sides of the room to process. Defaults to 1.

System.Int32 maxSidesToConnect

Maximum sides of the room to process. Defaults to 4.

System.Int32 cancelSideConnectionSelectChance

A chance out of 100 to cancel selecting sides to process (per room) while we are connecting them. Defaults to 50.

System.Int32 cancelConnectionPlacementChance

A chance out of 100 to cancel placing a door on a side after one has already been placed (per room) during connection.Defaults to 70.

System.Int32 cancelConnectionPlacementChanceIncrease

Increase the cancelConnectionPlacementChance value by this amount each time a door is placed (per room) during the connection process. Defaults to 10.

System.Int32 saveDeadEndChance

After the connection finishes, the small dead ends will be trimmed out. This value indicates the chance out of 100 that a given dead end remains. Defaults to 0.

System.Int32 maxTrimIterations

Maximum number of passes to make looking for dead ends when trimming. Defaults to infinity.

Returns
Type Description
System.Collections.Generic.IEnumerable<System.ValueTuple<Rectangle, Coord[][]>>

A list of the interior of rooms generated and the connections placed.

Remarks

First, non-overlapping rooms are randomly placed using RoomsGenerator. Then, a maze is generated into the remaining space using a MazeGenerator. Those mazes are then connected. The rooms are connected to the maze using a RoomDoorConnector, and finally, small dead ends are trimmed out.

| Improve this Doc View Source

GenerateRandomRoomsMap(ISettableMapView<Boolean>, Int32, Int32, Int32, Int32)

Generates a map by attempting to randomly place the specified number of rooms, ranging in size between the specified min size and max size, trying the specified number of times to position a room without overlap before discarding the room entirely. The given map will have a value of false set to all non-passable tiles, and true set to all passable ones.

Declaration
public static IEnumerable<Rectangle> GenerateRandomRoomsMap(ISettableMapView<bool> map, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom = 10)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

System.Int32 maxRooms

The maximum number of rooms to attempt to place on the map.

System.Int32 roomMinSize

The minimum size in width and height of each room.

System.Int32 roomMaxSize

The maximum size in width and height of each room.

System.Int32 attemptsPerRoom

The maximum number of times the position of a room will be generated to try to position it properly (eg. without overlapping with other rooms), before simply discarding the room. Defaults to 10.

Returns
Type Description
System.Collections.Generic.IEnumerable<Rectangle>

Rectangles representing the interior of each room generated.

| Improve this Doc View Source

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

Generates a map by attempting to randomly place the specified number of rooms, ranging in size between the specified min size and max size, trying the specified number of times to position a room without overlap before discarding the room entirely. The given map will have a value of false set to all non-passable tiles, and true set to all passable ones.

Declaration
public static IEnumerable<Rectangle> GenerateRandomRoomsMap(ISettableMapView<bool> map, IGenerator rng, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom = 10)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

Troschuetz.Random.IGenerator rng

The RNG to use to place rooms and determine room size. If null is specified, the default RNG is used.

System.Int32 maxRooms

The maximum number of rooms to attempt to place on the map.

System.Int32 roomMinSize

The minimum size in width and height of each room.

System.Int32 roomMaxSize

The maximum size in width and height of each room.

System.Int32 attemptsPerRoom

The maximum number of times the position of a room will be generated to try to position it properly (eg. without overlapping with other rooms), before simply discarding the room. Defaults to 10.

Returns
Type Description
System.Collections.Generic.IEnumerable<Rectangle>

Rectangles representing the interor of each room generated.

| Improve this Doc View Source

GenerateRectangleMap(ISettableMapView<Boolean>)

Generates a map, as a simple rectangular box, setting the map given as a "walkability map". Wall tiles (the edges of the map) will have a value of false set in the given map, whereas true will be set to all non-wall tiles.

Declaration
public static void GenerateRectangleMap(ISettableMapView<bool> map)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

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