Class DefaultAlgorithms
A collection of functions that return pre-defined series of generation steps that generate particular types of maps. For more customizable map generation, see documentation for the individual steps in GoRogue.MapGeneration.Steps and use AddStep to add them to a generator.
Inherited Members
Namespace: GoRogue.MapGeneration
Assembly: GoRogue.dll
Syntax
public static class DefaultAlgorithms
Remarks
These algorithms serve as a quick way to generate a map and demonstrate how generation steps may be used together. Feel free to look at the source, and copy onr or more of the generation steps into a custom generator.
Methods
View SourceBasicRandomRoomsMapSteps(IEnhancedRandom?, int, int, int, int, float, float, int, int, IConnectionPointSelector?, ITunnelCreator?)
Generates a basic dungeon by randomly sizing and placing rooms on the map, then connecting them with basic tunnels.
Declaration
public static IEnumerable<GenerationStep> BasicRandomRoomsMapSteps(IEnhancedRandom? rng = null, int minRooms = 4, int maxRooms = 10, int roomMinSize = 3, int roomMaxSize = 7, float roomSizeRatioX = 1, float roomSizeRatioY = 1, int maxCreationAttempts = 10, int maxPlacementAttempts = 10, IConnectionPointSelector? connectionPointSelector = null, ITunnelCreator? tunnelCreator = null)
Parameters
Type | Name | Description |
---|---|---|
IEnhancedRandom | rng | The RNG to use for map generation. Defaults to DefaultRNG. |
int | minRooms | Minimum amount of rooms to generate on the map. Defaults to 4. |
int | maxRooms | Maximum amount of rooms to generate on the map. Defaults to 10. |
int | roomMinSize | The minimum size allowed for generated rooms. Rounded up to an odd number. Defaults to 3. |
int | roomMaxSize | The maximum size allowed for generated rooms. Rounded up to an odd number. Defaults to 7. |
float | roomSizeRatioX | The ratio of the room width to the height for generated rooms. Defaults to 1.0. |
float | roomSizeRatioY | The ratio of the room height to the width for generated rooms. Defaults to 1.0. |
int | maxCreationAttempts | The maximum times to re-generate a room that fails to place in a valid location before giving up on generating that room entirely. Defaults to 10. |
int | maxPlacementAttempts | The maximum times to attempt to place a room in a map without intersection, before giving up and re-generating that room. Defaults to 10. |
IConnectionPointSelector | connectionPointSelector | The area connection strategy to use. Defaults to a CenterBoundsConnectionPointSelector. |
ITunnelCreator | tunnelCreator | The tunnel creation strategy to use. Defaults to HorizontalVerticalTunnelCreator using the given RNG. |
Returns
Type | Description |
---|---|
IEnumerable<GenerationStep> | A set of map generation steps that generate a map with rectangular rooms connected to each other. |
CellularAutomataGenerationSteps(IEnhancedRandom?, ushort, int, int, Distance?, IConnectionPointSelector?, ITunnelCreator?)
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.
Declaration
public static IEnumerable<GenerationStep> CellularAutomataGenerationSteps(IEnhancedRandom? rng = null, ushort fillProbability = 40, int totalIterations = 7, int cutoffBigAreaFill = 4, Distance? distanceCalculation = null, IConnectionPointSelector? connectionPointSelector = null, ITunnelCreator? tunnelCreationMethod = null)
Parameters
Type | Name | Description |
---|---|---|
IEnhancedRandom | rng | The RNG to use. Defaults to DefaultRNG. |
ushort | 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]. |
int | totalIterations | Total number of times the cellular automata-based smoothing algorithm is executed. Recommended to be in range [2, 10]. |
int | 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. Must be less than or equal to |
Distance | distanceCalculation | The distance calculation that determines distance/neighbors for determining unique areas and connecting them. Defaults to Manhattan. |
IConnectionPointSelector | connectionPointSelector | The area connection strategy to use. Not all methods function on maps with concave areas -- see respective class documentation for details. Defaults to using a RandomConnectionPointSelector. |
ITunnelCreator | tunnelCreationMethod | The tunnel creation strategy to use. Defaults to DirectLineTunnelCreator with given distance's adjacency rules. |
Returns
Type | Description |
---|---|
IEnumerable<GenerationStep> | A set of map generation steps that generate a cave-like map using the cellular automata algorithm. |
DungeonMazeMapSteps(IEnhancedRandom?, int, int, int, int, float, float, int, int, ushort, ushort, ushort, ushort, ushort, ushort, ushort, int)
Generates a dungeon map based on the process outlined here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/.
Declaration
public static IEnumerable<GenerationStep> DungeonMazeMapSteps(IEnhancedRandom? rng = null, int minRooms = 4, int maxRooms = 10, int roomMinSize = 3, int roomMaxSize = 7, float roomSizeRatioX = 1, float roomSizeRatioY = 1, int maxCreationAttempts = 10, int maxPlacementAttempts = 10, ushort crawlerChangeDirectionImprovement = 10, ushort minSidesToConnect = 1, ushort maxSidesToConnect = 4, ushort cancelSideConnectionSelectChance = 50, ushort cancelConnectionPlacementChance = 70, ushort cancelConnectionPlacementChanceIncrease = 10, ushort saveDeadEndChance = 40, int maxTrimIterations = -1)
Parameters
Type | Name | Description |
---|---|---|
IEnhancedRandom | rng | The RNG to use for map generation. Defaults to DefaultRNG. |
int | minRooms | Minimum amount of rooms to generate on the map. Defaults to 4. |
int | maxRooms | Maximum amount of rooms to generate on the map. Defaults to 10. |
int | roomMinSize | The minimum size allowed for generated rooms. Rounded up to an odd number. Defaults to 3. |
int | roomMaxSize | The maximum size allowed for generated rooms. Rounded up to an odd number. Defaults to 7. |
float | roomSizeRatioX | The ratio of the room width to the height for generated rooms. Defaults to 1.0. |
float | roomSizeRatioY | The ratio of the room height to the width for generated rooms. Defaults to 1.0. |
int | maxCreationAttempts | The maximum times to re-generate a room that fails to place in a valid location before giving up on generating that room entirely. Defaults to 10. |
int | maxPlacementAttempts | The maximum times to attempt to place a room in a map without intersection, before giving up and re-generating that room. Defaults to 10. |
ushort | crawlerChangeDirectionImprovement | Out of 100, how much to increase the chance of a crawler changing direction each step during maze generation. Once it changes direction, it resets to 0 and increases by this amount. Defaults to 10. |
ushort | minSidesToConnect | Minimum sides of each room to connect to the maze. Defaults to 1. |
ushort | maxSidesToConnect | Maximum sides of each room to connect to the maze. Defaults to 4. |
ushort | cancelSideConnectionSelectChance | A chance out of 100 to cancel selecting sides to connect to the maze (per room). Defaults to 50. |
ushort | cancelConnectionPlacementChance | A chance out of 100 to cancel placing a door on a given side of a room after one has been placed on that side. Defaults to 70. |
ushort | cancelConnectionPlacementChanceIncrease | The |
ushort | saveDeadEndChance | The chance out of 100 that a dead end is left alone during dead end trimming. Defaults to 40. |
int | maxTrimIterations | Maximum number of passes to make looking for dead ends per area during dead end trimming. Defaults to infinity. |
Returns
Type | Description |
---|---|
IEnumerable<GenerationStep> | A set of map generation steps that generate a map with rectangular rooms connected by a maze of tunnels. |
RectangleMapSteps()
Generates a simple map that is a hollowed-out rectangle surrounded by walls.
Declaration
public static IEnumerable<GenerationStep> RectangleMapSteps()
Returns
Type | Description |
---|---|
IEnumerable<GenerationStep> | A set of map generation steps that generate a simple map composed of a hollowed out rectangle surrounded by walls. |