# 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.

**Namespace**: GoRogue.MapGeneration

**Assembly**: GoRogue.dll

##### Syntax

`public static class DefaultAlgorithms : Object`

**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

#### BasicRandomRoomsMapSteps(IEnhancedRandom, Int32, Int32, Int32, Int32, Single, Single, Int32, Int32, 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 = 1F, float roomSizeRatioY = 1F, int maxCreationAttempts = 10, int maxPlacementAttempts = 10, IConnectionPointSelector connectionPointSelector = null, ITunnelCreator tunnelCreator = null)`

##### Parameters

Type | Name | Description |
---|---|---|

ShaiRandom.Generators.IEnhancedRandom | rng | The RNG to use for map generation. Defaults to DefaultRNG. |

Int32 | minRooms | Minimum amount of rooms to generate on the map. Defaults to 4. |

Int32 | maxRooms | Maximum amount of rooms to generate on the map. Defaults to 10. |

Int32 | roomMinSize | The minimum size allowed for generated rooms. Rounded up to an odd number. Defaults to 3. |

Int32 | roomMaxSize | The maximum size allowed for generated rooms. Rounded up to an odd number. Defaults to 7. |

Single | roomSizeRatioX | The ratio of the room width to the height for generated rooms. Defaults to 1.0. |

Single | roomSizeRatioY | The ratio of the room height to the width for generated rooms. Defaults to 1.0. |

Int32 | 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. |

Int32 | 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, UInt16, Int32, Int32, 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 |
---|---|---|

ShaiRandom.Generators.IEnhancedRandom | rng | The RNG to use. Defaults to DefaultRNG. |

UInt16 | 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]. |

Int32 | totalIterations | Total number of times the cellular automata-based smoothing algorithm is executed. Recommended to be in range [2, 10]. |

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. 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, Int32, Int32, Int32, Int32, Single, Single, Int32, Int32, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, 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<GenerationStep> DungeonMazeMapSteps(IEnhancedRandom rng = null, int minRooms = 4, int maxRooms = 10, int roomMinSize = 3, int roomMaxSize = 7, float roomSizeRatioX = 1F, float roomSizeRatioY = 1F, 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 |
---|---|---|

ShaiRandom.Generators.IEnhancedRandom | rng | The RNG to use for map generation. Defaults to DefaultRNG. |

Int32 | minRooms | Minimum amount of rooms to generate on the map. Defaults to 4. |

Int32 | maxRooms | Maximum amount of rooms to generate on the map. Defaults to 10. |

Int32 | roomMinSize | The minimum size allowed for generated rooms. Rounded up to an odd number. Defaults to 3. |

Int32 | roomMaxSize | The maximum size allowed for generated rooms. Rounded up to an odd number. Defaults to 7. |

Single | roomSizeRatioX | The ratio of the room width to the height for generated rooms. Defaults to 1.0. |

Single | roomSizeRatioY | The ratio of the room height to the width for generated rooms. Defaults to 1.0. |

Int32 | 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. |

Int32 | 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. |

UInt16 | 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. |

UInt16 | minSidesToConnect | Minimum sides of each room to connect to the maze. Defaults to 1. |

UInt16 | maxSidesToConnect | Maximum sides of each room to connect to the maze. Defaults to 4. |

UInt16 | cancelSideConnectionSelectChance | A chance out of 100 to cancel selecting sides to connect to the maze (per room). Defaults to 50. |

UInt16 | 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. |

UInt16 | cancelConnectionPlacementChanceIncrease | The |

UInt16 | saveDeadEndChance | The chance out of 100 that a dead end is left alone during dead end trimming. Defaults to 40. |

Int32 | 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. |