Class OrganicConnectingMapGenerator
java.lang.Object
com.github.yellowstonegames.place.OrganicConnectingMapGenerator
- All Implemented Interfaces:
PlaceGenerator
A PlaceGenerator that distorts and smooths a grid-based room map to make it appear like a cave complex.
An example map this can produce:
An example map this can produce:
################################################################################
####.#######.......##############################.#######.#################.####
##.....####.........#................###...####....#####...########.######....##
##.....###.................................###.....#####...########..####.....##
##.....###.........##......................###.....####....######.....###......#
##.....####........#####..................####.....####.....#####.....####....##
###....######.....#######.#########........###......###......###......####....##
##....##############################.......###......######...###......####.....#
###....##############################......###.......###.#....#.......###......#
###...###############################..##...#........###.#....#................#
##..#.#######.#######################...#......................................#
##....#####....####...###############.........................................##
##...######....#####...#####.....####.....................#...................##
##....####.....#####...#####......####........#...............................##
##...######....######...#####.....####.......####.............................##
###...#####.....####....#####.....#####################################.......##
###...######....####....#####.....#######################################.....##
###...#####.....####....######...########################################....###
##.....####....#####.....#####.....#######################################..####
#..............#####.....####.......#####.....########......##############....##
#...............####.....###.................................####...######...###
#...............####.....##..................................###.....####.....##
##..............####.....#......#............#...............###.....####.....##
###...#.........#####...........##...........##....#........####.....####.....##
#####.##........########.#.###.#######......####.#####.....######....####.....##
#########.......########################################....#####.....####....##
##########......########################################....#####.....####....##
##########.......#####################################......####......#####..###
##########.......#....########..........#########.###.......####........#.#...##
##....####.............#######...........#######............####...............#
##.....###..............#####.............#####......#..#...####...............#
##.....###..............#####.............#####......#......####...............#
##.....###..............####..............######............####......#........#
#......####...###.......#####...#.........##########........#####...####.......#
##.....###########.......###########.......###########......############.......#
#......############......############.....#############......###########.......#
#......#############.....###########......#############.......###########......#
#.....###########.......###########.......###############.......##.#####.......#
#.....#####...##........#####.............#####.#..########..........###.......#
#......####...##........#####.............####.....########....................#
#......###....#.........####..............####.....#####.......................#
#......####.............#####.............####.....#####......................##
##.....########.........###########......#####.....####........####.#.#.......##
##....############......###############...####..##.####.......###########.....##
##....#############....################...####..##..####.....#############.....#
##....#############.....##############.....###...#..####.....############.....##
##.#..#############.....##############......#.......####.....############.....##
####.#######..#####.....#####....####...............####.#...####....####.....##
###....######.######...######.....####..............######...#####....###.....##
##....#######.######...######....#####..............######...#####....####....##
#.....#####...######...######....##########.#......##############..#.#####....##
#.....#####...######...#####.....#############.....##############.....####...###
##....#####....#####...#####......############....##############.....#####..####
##......###....####....#####.....################..#############......####..####
###.....##...#.####....######....###############...#############.......###....##
#####..........####....######...###############.....#####.#######.............##
####...........#####....#####...#######..######.....####....#####.......#.....##
##.#............####....#####....#####....#####.....####....#####.......#.....##
##.............#####....######...####.....#####.....#####...####......####....##
##...#.........#####....######...####......####.....#####.#.#####....###.......#
###.######....######....######....###......####.....####....##############.....#
#########.....######.....####.....###......####....#####....##############.....#
##########....######.....####.....####....####.....#####....##############.....#
#########......####......#####...#####....###......####......###########.......#
#####....................####....#####..............#........#########........##
##........#..........##..####....#####.......................#######..........##
##...................#######......####.......................####.............##
###...#.........##....#######.....####..............#........####.............##
#########..............######.....#####.......##....#........####.............##
################........#####.....#####...#.######..#........##########......###
###################......####.....####################.......##########.......##
###################.......##......#####################......###########......##
####################..............####################........##########......##
##.#####...########...............#######.#######.###...............###......###
##.............###................##........#####.......................##....##
##..............#..............#........#.......#........................#....##
##............................###.......#......................................#
####..........................###......##........#............................##
#####.####...######..#############.#######.###..###...###..#######..##...#######
################################################################################
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.github.yellowstonegames.grid.CellularAutomatonfinal int[][]final intcom.github.tommyettinger.random.EnhancedRandomfinal int -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that makes a 80x80 cave map with a random seed.OrganicConnectingMapGenerator(int width, int height) Makes a cave map with the specified dimensions and a random seed.OrganicConnectingMapGenerator(int width, int height, int roomWidth, int roomHeight, int wallThickness, com.github.tommyettinger.random.EnhancedRandom rng) Makes a cave map with the specified dimensions and the given EnhancedRandom to generate random numbers. -
Method Summary
Modifier and TypeMethodDescriptionchar[][]generate()Generates an organic connecting cave complex.char[][]generate(double roomChance) Generates an organic connecting cave complex, while specifying a chance to keep the original walls of rooms before the flowing smoothing step is performed.int[][]Gets an environment map as a 2D int array thatDungeonProcessorcan use along with the normal 2D char array dungeon map to add dungeon features.char[][]Gets the most recently-produced dungeon as a 2D char array, usually produced by callinggenerate()or some similar method present in a specific implementation.toString()
-
Field Details
-
gen
-
width
public final int width -
height
public final int height -
rng
public com.github.tommyettinger.random.EnhancedRandom rng -
environment
public final int[][] environment -
ca
protected com.github.yellowstonegames.grid.CellularAutomaton ca
-
-
Constructor Details
-
OrganicConnectingMapGenerator
public OrganicConnectingMapGenerator()Default constructor that makes a 80x80 cave map with a random seed. -
OrganicConnectingMapGenerator
public OrganicConnectingMapGenerator(int width, int height) Makes a cave map with the specified dimensions and a random seed.- Parameters:
width- the width of the dungeon map(s) to generateheight- the height of the dungeon map(s) to generate
-
OrganicConnectingMapGenerator
public OrganicConnectingMapGenerator(int width, int height, int roomWidth, int roomHeight, int wallThickness, com.github.tommyettinger.random.EnhancedRandom rng) Makes a cave map with the specified dimensions and the given EnhancedRandom to generate random numbers.- Parameters:
width- the width of the dungeon map(s) to generateheight- the height of the dungeon map(s) to generateroomWidth- defaults to 6roomHeight- defaults to 6wallThickness- defaults to 3; determines how many cells minimum there are between roomsrng- a random number generator to use when generating the caves; if null this will use an unseeded AceRandom
-
-
Method Details
-
generate
public char[][] generate()Generates an organic connecting cave complex. This uses the convention of '#' representing a wall and '.' representing a bare floor.- Specified by:
generatein interfacePlaceGenerator- Returns:
- a 2D char array representing a cave system with '#' for walls and '.' for floors
-
generate
public char[][] generate(double roomChance) Generates an organic connecting cave complex, while specifying a chance to keep the original walls of rooms before the flowing smoothing step is performed.roomChancecan be between 0.0 and 1.0, and if a room (identified with a similar technique toRoomFinder, but not using it directly) is randomly selected to be preserved (the probability per room is roomChance), then most of its walls will be kept in-place, generally with more right angles than the caves will have. It may be best to keep roomChance above 0.5 if you want the effect to be noticeable.- Parameters:
roomChance- the chance, from 0.0 to 1.0, to preserve each room, keeping its walls where they start- Returns:
- a 2D char array for the cave system
-
getPlaceGrid
public char[][] getPlaceGrid()Gets the most recently-produced dungeon as a 2D char array, usually produced by callinggenerate()or some similar method present in a specific implementation. This normally passes a direct reference and not a copy, so you can normally modify the returned array to propagate changes back into this PlaceGenerator.- Specified by:
getPlaceGridin interfacePlaceGenerator- Returns:
- the most recently-produced dungeon/map as a 2D char array
-
getEnvironment
public int[][] getEnvironment()Gets an environment map as a 2D int array thatDungeonProcessorcan use along with the normal 2D char array dungeon map to add dungeon features. This marks cells as eitherDungeonTools.UNTOUCHED(equal to 0),DungeonTools.NATURAL_FLOOR, orDungeonTools.NATURAL_WALL. If the environment has not yet been retrieved since generate() was last called, this assigns the environment map to match the dungeon map; otherwise it uses the cached environment map.- Specified by:
getEnvironmentin interfacePlaceGenerator- Returns:
- a 2D int array that can be used as an environment map
-
toString
-