Class SerpentDeepMapGenerator
java.lang.Object
com.github.yellowstonegames.place.SerpentDeepMapGenerator
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.
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.
-
Constructor Summary
ConstructorsConstructorDescriptionThis prepares a map generator that will generate a map with width 80, height 80, and depth 20, using a random seed.SerpentDeepMapGenerator(int width, int height, int depth, com.github.tommyettinger.random.EnhancedRandom rng) This prepares a map generator that will generate a map with the given width, height and depth, using the given EnhancedRandom.SerpentDeepMapGenerator(int width, int height, int depth, com.github.tommyettinger.random.EnhancedRandom rng, double branchingChance) This prepares a map generator that will generate a map with the given width, height and depth, using the given EnhancedRandom, and will branch out to other nearby rooms that (probably) do not have staircases between layers. -
Method Summary
Modifier and TypeMethodDescriptionchar[][][]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[][][]Gets an array (length equals depth) of 2D int arrays representing the environments for levels.voidputBoxRoomCarvers(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.voidputCaveCarvers(int count) Changes the number of "carvers" that will create caves from one room to the next.voidputRoundRoomCarvers(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.voidputWalledBoxRoomCarvers(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.voidputWalledRoundRoomCarvers(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.toString()
-
Constructor Details
-
SerpentDeepMapGenerator
public SerpentDeepMapGenerator()This prepares a map generator that will generate a map with width 80, height 80, and depth 20, using a random seed. 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.- See Also:
-
SerpentDeepMapGenerator
public SerpentDeepMapGenerator(int width, int height, int depth, com.github.tommyettinger.random.EnhancedRandom rng) This prepares a map generator that will generate a map with the given width, height and depth, using the given EnhancedRandom. 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 EnhancedRandom object to use for random choices; this make a lot of random choices.- See Also:
-
SerpentDeepMapGenerator
public SerpentDeepMapGenerator(int width, int height, int depth, com.github.tommyettinger.random.EnhancedRandom rng, double branchingChance) This prepares a map generator that will generate a map with the given width, height and depth, using the given EnhancedRandom, 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 EnhancedRandom 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:
-
-
Method Details
-
putCaveCarvers
public void putCaveCarvers(int count) 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:
-
putBoxRoomCarvers
public 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. 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:
-
putWalledBoxRoomCarvers
public 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. 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:
-
putRoundRoomCarvers
public 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. 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:
-
putWalledRoundRoomCarvers
public 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. 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:
-
generate
public 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. 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:
-
getEnvironments
public int[][][] 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
public int[][] getEnvironment(int level) 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
-
toString
-