Package squidpony.squidgrid.mapping
Class SerpentDeepMapGenerator
java.lang.Object
squidpony.squidgrid.mapping.SerpentDeepMapGenerator
public class SerpentDeepMapGenerator extends Object
Generate dungeons based on a random, winding, looping path through 3D space, requiring a character to move up and
down as well as north/south/east/west to get through the dungeon. Uses techniques from MixedGenerator.
Uses a Moore Curve, which is related to Hilbert Curves but loops back to its starting point, and stretches and
distorts the grid to make sure a visual correlation isn't obvious.
The name comes from a vivid dream I had about gigantic, multi-colored snakes that completely occupied a roguelike dungeon. Shortly after, I made the connection to the Australian mythology I'd heard about the Rainbow Serpent, which in some stories dug water-holes and was similarly gigantic. Created by Tommy Ettinger on 10/24/2015.
The name comes from a vivid dream I had about gigantic, multi-colored snakes that completely occupied a roguelike dungeon. Shortly after, I made the connection to the Australian mythology I'd heard about the Rainbow Serpent, which in some stories dug water-holes and was similarly gigantic. Created by Tommy Ettinger on 10/24/2015.
-
Constructor Summary
Constructors Constructor Description SerpentDeepMapGenerator(int width, int height, int depth, IRNG rng)
This prepares a map generator that will generate a map with the given width, height and depth, using the given IRNG.SerpentDeepMapGenerator(int width, int height, int depth, IRNG rng, double branchingChance)
This prepares a map generator that will generate a map with the given width, height and depth, using the given IRNG, and will branch out to other nearby rooms that (probably) do not have staircases between layers. -
Method Summary
Modifier and Type Method Description char[][][]
generate()
This generates a new map by stretching a 32x32x(multiple of 8) grid of potential rooms to fit the width, height, and depth passed to the constructor, randomly expanding columns and rows before contracting the whole to fit perfectly.int[][]
getEnvironment(int level)
Gets a 2D int array representing the environment for the requested level.int[][][]
getEnvironments()
Gets an array (length equals depth) of 2D int arrays representing the environments for levels.void
putBoxRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a box shape at the start and end, and a small room at the corner if there is one.void
putCaveCarvers(int count)
Changes the number of "carvers" that will create caves from one room to the next.void
putRoundRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a circle shape at the start and end, and a small circular room at the corner if there is one.void
putWalledBoxRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a box shape at the start and end, and a small room at the corner if there is one.void
putWalledRoundRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a circle shape at the start and end, and a small circular room at the corner if there is one.
-
Constructor Details
-
SerpentDeepMapGenerator
This prepares a map generator that will generate a map with the given width, height and depth, using the given IRNG. The intended purpose is to carve a long path that loops through the whole dungeon's 3D space, while hopefully maximizing the amount of rooms the player encounters. You call the different carver-adding methods to affect what the dungeon will look like, putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers(), defaulting to only caves if none are called. You call generate() after adding carvers, which returns a char[][][] for a map.- Parameters:
width
- the width of the final map in cellsheight
- the height of the final map in cellsdepth
- the number of levels deep to createrng
- an IRNG object to use for random choices; this make a lot of random choices.- See Also:
MixedGenerator
-
SerpentDeepMapGenerator
This prepares a map generator that will generate a map with the given width, height and depth, using the given IRNG, and will branch out to other nearby rooms that (probably) do not have staircases between layers. The intended purpose is to carve a long path that loops through the whole dungeon's 3D space, while hopefully maximizing the amount of rooms the player encounters. You call the different carver-adding methods to affect what the dungeon will look like, putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers(), defaulting to only caves if none are called. You call generate() after adding carvers, which returns a char[][][] for a map.- Parameters:
width
- the width of the final map in cellsheight
- the height of the final map in cellsdepth
- the number of levels deep to createrng
- an IRNG object to use for random choices; this make a lot of random choices.branchingChance
- the odds from 0.0 to 1.0 that a branch will be created near each necessary room.- See Also:
MixedGenerator
-
-
Method Details
-
putCaveCarvers
Changes the number of "carvers" that will create caves from one room to the next. If count is 0 or less, no caves will be made. If count is at least 1, caves are possible, and higher numbers relative to the other carvers make caves more likely. Carvers are shuffled when used, then repeat if exhausted during generation. Since typically about 30-40 rooms are carved, large totals for carver count aren't really needed; aiming for a total of 10 between the count of putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers() is reasonable.- Parameters:
count
- the number of carvers making caves between rooms; only matters in relation to other carvers- See Also:
MixedGenerator
-
putBoxRoomCarvers
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a box shape at the start and end, and a small room at the corner if there is one. If count is 0 or less, no box-shaped rooms will be made. If count is at least 1, box-shaped rooms are possible, and higher numbers relative to the other carvers make box-shaped rooms more likely. Carvers are shuffled when used, then repeat if exhausted during generation. Since typically about 30-40 rooms are carved, large totals for carver count aren't really needed; aiming for a total of 10 between the count of putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers() is reasonable.- Parameters:
count
- the number of carvers making box-shaped rooms and corridors between them; only matters in relation to other carvers- See Also:
MixedGenerator
-
putWalledBoxRoomCarvers
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a box shape at the start and end, and a small room at the corner if there is one. This also ensures walls will be placed around the room, only allowing corridors and small cave openings to pass. If count is 0 or less, no box-shaped rooms will be made. If count is at least 1, box-shaped rooms are possible, and higher numbers relative to the other carvers make box-shaped rooms more likely. Carvers are shuffled when used, then repeat if exhausted during generation. Since typically about 30-40 rooms are carved, large totals for carver count aren't really needed; aiming for a total of 10 between the count of putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers() is reasonable.- Parameters:
count
- the number of carvers making box-shaped rooms and corridors between them; only matters in relation to other carvers- See Also:
MixedGenerator
-
putRoundRoomCarvers
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a circle shape at the start and end, and a small circular room at the corner if there is one. If count is 0 or less, no circular rooms will be made. If count is at least 1, circular rooms are possible, and higher numbers relative to the other carvers make circular rooms more likely. Carvers are shuffled when used, then repeat if exhausted during generation. Since typically about 30-40 rooms are carved, large totals for carver count aren't really needed; aiming for a total of 10 between the count of putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers() is reasonable.- Parameters:
count
- the number of carvers making circular rooms and corridors between them; only matters in relation to other carvers- See Also:
MixedGenerator
-
putWalledRoundRoomCarvers
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms with a random size in a circle shape at the start and end, and a small circular room at the corner if there is one. This also ensures walls will be placed around the room, only allowing corridors and small cave openings to pass. If count is 0 or less, no circular rooms will be made. If count is at least 1, circular rooms are possible, and higher numbers relative to the other carvers make circular rooms more likely. Carvers are shuffled when used, then repeat if exhausted during generation. Since typically about 30-40 rooms are carved, large totals for carver count aren't really needed; aiming for a total of 10 between the count of putCaveCarvers(), putBoxRoomCarvers(), and putRoundRoomCarvers() is reasonable.- Parameters:
count
- the number of carvers making circular rooms and corridors between them; only matters in relation to other carvers- See Also:
MixedGenerator
-
generate
This generates a new map by stretching a 32x32x(multiple of 8) grid of potential rooms to fit the width, height, and depth passed to the constructor, randomly expanding columns and rows before contracting the whole to fit perfectly. This uses the Moore Curve, a space-filling curve that loops around on itself, to guarantee that the rooms will always have a long path through the dungeon, going up and down as well as north/south/east/west, that, if followed completely, will take you back to your starting room. Some small branches are possible, and large rooms may merge with other rooms nearby. This uses MixedGenerator.- Returns:
- a char[][][] where the outermost array is layers, then inside that are x and y in order (z x y)
- See Also:
MixedGenerator
-
getEnvironments
Gets an array (length equals depth) of 2D int arrays representing the environments for levels.- Returns:
- an array of 2D int arrays, where each 2D array is a level's environment
-
getEnvironment
Gets a 2D int array representing the environment for the requested level.- Parameters:
level
- the level to get from the generated dungeon; will be clamped between 0 and depth - 1- Returns:
- a 2D int array representing the requested level's environment
-