Package squidpony.squidgrid.mapping
Class FlowingCaveGenerator
java.lang.Object
squidpony.squidgrid.mapping.FlowingCaveGenerator
- All Implemented Interfaces:
IDungeonGenerator
public class FlowingCaveGenerator extends Object implements IDungeonGenerator
An IDungeonGenerator that distorts and smooths an ordinary dungeon map to make it appear like a cave complex.
This usually exhibits the complex connectivity that dungeons made with a
An example map this can produce:
TilesetType
like
TilesetType.DEFAULT_DUNGEON
have, but shouldn't have noticeable room/corridor areas, and should appear as
all one cave.
An example map this can produce:
┌─────┐ ┌───────┬─┐ ┌───┐ ┌────┐ ┌────┐ ┌────┐ ┌──┐ ┌───┐ ┌─────┐
┌┘.....└─┘.......│.└─┘...└─┐ ┌─┐ ┌──┘....│ │....└──┬┘....└┬───┘..└──┐ ┌───┐ ┌┘...│ ┌┘.....└┐
│..........................└┐ ┌─┘.└┐ │.......└┐ │.......│......│.........└─┬┘...│ ┌───┬┘....│ │.......│
└┐.........┌┐...............└─┘....└┐ ┌┘........│ ┌┘....│.....................│...─┤┌─┘...│.....│ │.......│
│........┌┘│.......................└─┘.........└┐│.....│.....┌┐...................││...........│ │.......│
│........│┌┘...............................#....││.....│.....│└┐..................└┘...........│ │.......└┐
│.......┌┼┘.....┌┐............┌─┐..............┌┘│.....├─┐...│ │...............................│ │........│
│......┌┘│....┌─┘└┐.........┌─┘ └──────┐.......│ │....┌┘ │...└─┤......#.......│................│ └┐.......│
│.....┌┘ └┐.┌─┘ └┐.......┌┘ │......┌┘ │...┌┘ └─┐...│....│........┌┤........│.......│ ┌┘......┌┘
└┐...─┤ └─┘ │......─┤ ┌──┐ │......│ │...│ ┌┘.......─┘.......┌┘└─┐....─┬┤.......└┐ │.......│
┌┘....└┐ ┌─┐ ┌───┘.......└──┘..└┐ └┐.....│ ┌┘...└┐ ┌─┘.................│ ┌┘.....│└┐.......└─┘.......└┐
┌┘......└──┘.└┐┌┘......─┐..........└─┐ ┌┘.....└─┘.....│┌┘...................│ ┌┘......│ │..................│
┌┘.............└┘........│............└┬─┘..│...........└┘.....│.........───..└┬┘.......│ │....┌┐............│
│........................│......┌─┐....│....├┐...............──┘...............│........└─┘....│└┐...........│
│...┌─┐........................┌┘ └┐.......┌┘└┐................................................│ └┐..........│
│..┌┘ └┐.....................┌─┘ ┌┘.......│ │...............................................┌┘ │..........│
└──┘ └┐...................┌┘ ┌┘........│ └─┐...│...─┐...........│........................│ └┐.........│
│..................┌┘ │.........│ ┌─┐└───┴┐...│...........├─┐........│.............└─┐ │.........│
┌─┐ └──┐.....┌──┐......│ ┌┘...┌───┐.└─┘.└┐ └┐..├┐..........│ └┐......┌┤...............│ └─┐.......│
│.└─┐ └┐...┌┘ └┐.....└┐ │....│ ┌┘......└┐ │..│└───┐.....┌┘ └┐....┌┘├─.....┌──┐.....│ │......┌┘
│...└┐ └┐..│ ┌┘......└─┬─┘...─┤ │........└┐ ┌─┘.─┤ │.....│ │....│ │......└┐ └┐....│ └┐....─┤
└┐...│ ┌┘..│ │.........│......│ ┌┘.........└─┘....└─┐ ┌┘.....│ ┌┘....├─┘.......└┐ │....│ │.....│
└┐..│ ┌┘...│ │................│┌┘...................│ │......└───┘.....│..........│ │....└─┐ │...┌─┘
│..├─┘...─┤ ┌┘................├┘....................└─┘................│..........└┬┘......└─┐┌┘...│
├─.│......│ ┌┘..<........│...#.│...........................┌┬─......................│.........└┘...┌┘
│..│......│┌┘............│................................─┴┘......................................│
┌┘......┌──┘│....................┌─┐.....................................┌┐.........................│
│....┌──┘ └─┐..................│ └─┐.┌─┐....┌─┐....┌─┐.........┌─┐.....│└─┐......┌─┐....┌──┐......│
│...┌┘ └─┐...........┌────┘ └─┘┌┴─┬──┘ └────┘ │........┌┘ │....┌┘ │.....┌┘ └────┘ └──┐...│
│..┌┘ └┐.....┌─┐..└┐ │..│ ┌──┐ └┐......┌┘ ┌┘....└┐ └┐....│ ┌────┐ │...└┐
┌┘..└┐ ┌─────┐ ┌┘....┌┘ └┐..└┐ ┌┘..│ ┌─┘..└─┐ └┐.....│ │......└───┘....└┐ ┌┘....└┐ └┐...│
┌┘....└─┘.....└┐ ┌┘.....└┐ ┌┘...└┐ │...│┌┘......│ │.....│ └┐..........#....│ ┌┘......└┐ │...│
┌┘..........│...└┬┘.......└┐│.....└─┐ ┌─┘...││.......├─┐ │.....│ │...............└─┘........└┐ └┐..└┐
┌┘.......┌───┴┐...│.........││.......│ ┌┘....┌┘│.......│.└──┼┬─...│ ┌┘...........................└┐ │...│
┌┘.......┌┘ │.............└┘.......└┐ │...┌─┘ │...│.#......└┘....│ ┌┘........................│....└─┴─..└┐
│........│ ┌┘.......................│ │..┌┘ └┐..│..............└─┘......──.................│...........│
│........│ ┌┘..........┌─┐..........┌┘ │..│ └┐.............................┌─┐........................└┐
│........│ ┌┘.....┌─────┘ └──┐.......│ │..│ │.........................┌───┘ ├─...┌────┐...............│
│........│ │.....┌┘ └┐.....┌┘ └┐.└┐ └┐......┌─┬─┐....┌──┐.....│ ┌┘...┌┘ │....┌─┐........│
└┐......┌┘ │.....│ ┌────┐ │.....│ ┌┘..└┐ └┐....┌┘┌┘.│....│ └┐....│ ┌┘....│ │....│ │........│
│....┌─┘ │.....└┐ ┌─┘....│ └┐...─┤ ┌┘....│ └┐...└┬┘.......│ │....└┐ ┌┘.....│ ┌──┘....└┬┘........│
│....└─┐ └┐.....└─┘......└┐ │....└──┘.....└─┐ ┌─┬┘....│........└┐ ┌┘.....└┐│......└──┘........│.........│
└┐.....└┐ ┌─┴─..............│ ┌┘...............└──┘.│...............│┌┘.......└┘......................┌┐....│
│......└─┘.................└┐│.....................................└┘...............................─┤└┐...│
┌┘.........│.................└┘.........................│................┌──┐.#.#.....................│ └┐.┌┘
│..........│..........................................──┼──┐.....#......┌┘ │....................│....└┐ ├─┤
└┐.........│.....................┌─┐....................│ └─┐..........│ └─┐................#.├─┐...└─┘.└┐
│....┌┐.........┌─┐.........│..┌┘ └─┐..................│ │...┌───┐..└┐ │..................│ │........│
└┐...│└─┐.....┌─┘ └┐......┌─┴┐.└┐ └─┐..........│.....│ │...└┐ └┐..└─┐ └─┐....┌──┐.......┌┘ └┐.......│
┌┘..┌┘ └┐...┌┘ └┐.....│ │..│ ┌─┐ └┐.......┌─┤....┌┘ └┐...└─┬─┘....└─┐ └┐...└┐ └┐......│ │......┌┘
│...│ │...└───┐ │.....└┐┌┘..│┌┘.└┐ └┐.....┌┘ │....│ ├─....│........│ └┐...└┐ └┐.....└┐ ┌┘......│
┌┘..┌┘ ┌┘.......│ │......└┘...││...└┐ │.....└┐┌┘....└┐┌────┘.........┌─┐..└┐ └┐...└┐ └┐.....└─┘.......└┐
┌┘..┌┘ │........│ └┐..........└┘....└─┘......└┘......└┘..............│ └┐..└┐ │....│ ┌┘................│
│...│ ┌┘....┌───┘ └┐...............................................─┤ └┐..└┐ └┐...└─┤.................│
│..┌┘ ┌┘....┌┘ │..........................................┌┐....│ │...└┐ │.....│.................│
│.┌┘ ┌┘.....└┐ │..........................................│└─┐.┌┘ ┌┘....└─┐│.......................│
│.└┐ ┌┘.......└───┐ ┌┘.......┌┐......┌─┐..................│.....│ └─┘ │.......└┘.....>.........#.......│
│..└┬─┘............│┌──┘......┌─┘└┐.....│ └┐..─┐.............│.....│ │.............┌─┐...............┌┘
│...│..┌──┐........││........┌┘ └┐...┌┘ └┐..├───┐..............┌┘ │..┌─┐......┌─┘ ├─....┌┐........│
│......│ └┐......┌┘└┐......┌┘ └───┘ └──┘ └┐....┌──┐....┌┘ ┌─┴─┬┘ │.....┌┘ │....┌┘└┐......┌┘
└─┐....│ ├─.....└┐ │......└┐ ┌──┐ │....│ └┐..┌┘ ┌┘...└┐ │.....│ ┌┘....│ └┐.....│
├─..┌┘ ┌┘.......│ └┐......└┐ ┌┘..│ └┐...│ └──┘ ┌┘.....└─┘.....└─┐┌┘.....└┐ │.....│
┌─┘...└┐ ┌┘........└┐ │.......└───┘...│ │..┌┘ │................└┘.......│ └┐....└─┐
│......└─┘..........│ └─┐.............└─┬───┐ ┌┘.┌┘ │.........................└┐ ┌┘......│
│...................└┐ └───┐...........│...└───────┘..└┐ │.......┌─┐................│ │.......│
└┐...................│ │..........┌┴┐..............└┐ ├─......│ └┐...............└─┘.......│
└┐.#................│ │..........│ └┐..............└┐ ┌───┘.....┌─┘ │.........................│
└┐...............┌─┘ │.........┌┘ └┐.....┌───┐....│ │.........│ │......│....┌──────┐.....┌┘
└┐.┌───┐........│ └───┐....┌┘ └─┐.┌─┘ └─┐.┌┘ └┐......┌─┘ └─┐...┌┴────┘ └─┐..┌┘
└─┘ └────────┘ └────┘ └─┘ └─┘ └──────┘ └───┘ └──┘
Created by Tommy Ettinger on 8/18/2017.-
Field Summary
Fields Modifier and Type Field Description protected CellularAutomaton
ca
int[][]
environment
DungeonBoneGen
gen
int
height
IRNG
rng
TilesetType
type
int
width
-
Constructor Summary
Constructors Constructor Description FlowingCaveGenerator()
Default constructor that makes a 60x60 cave map with a random seed.FlowingCaveGenerator(int width, int height)
Makes a cave map with the specified dimensions and a random seed.FlowingCaveGenerator(int width, int height, TilesetType type, IRNG rng)
-
Method Summary
Modifier and Type Method Description char[][]
generate()
Generates a flowing cave dungeon withthe sameTilesetType
this was made with, orTilesetType.DEFAULT_DUNGEON
if none was specified.char[][]
generate(TilesetType type)
Generates a flowing cave dungeon with a differentTilesetType
than this generator was made with.char[][]
generate(TilesetType type, double roomChance)
Generates a flowing cave dungeon with a differentTilesetType
than this generator was made with, and specifying a chance to keep the original walls of rooms before the flowing smoothing step is performed.char[][]
getDungeon()
Gets the most recently-produced dungeon as a 2D char array, usually produced by callinggenerate()
or some similar method present in a specific implementation.int[][]
getEnvironment()
Gets an environment map as a 2D int array thatSectionDungeonGenerator
can use along with the normal 2D char array dungeon map to add dungeon features.
-
Field Details
-
Constructor Details
-
FlowingCaveGenerator
public FlowingCaveGenerator()Default constructor that makes a 60x60 cave map with a random seed. -
FlowingCaveGenerator
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
-
FlowingCaveGenerator
- Parameters:
width
- the width of the dungeon map(s) to generateheight
- the height of the dungeon map(s) to generatetype
- a TilesetType enum value;TilesetType.DEFAULT_DUNGEON
is used if null or unspecifiedrng
- a random number generator to use when generating the caves; if null this will use a default RNG
-
-
Method Details
-
generate
Generates a flowing cave dungeon withthe sameTilesetType
this was made with, orTilesetType.DEFAULT_DUNGEON
if none was specified. This uses the convention of '#' representing a wall and '.' representing a bare floor.- Specified by:
generate
in interfaceIDungeonGenerator
- Returns:
- a 2D char array representing a cave system with '#' for walls and '.' for floors
-
generate
Generates a flowing cave dungeon with a differentTilesetType
than this generator was made with. The default type isTilesetType.DEFAULT_DUNGEON
if unspecified in the constructor.- Parameters:
type
- a TilesetType enum value- Returns:
- a 2D char array for the cave system
-
generate
Generates a flowing cave dungeon with a differentTilesetType
than this generator was made with, and specifying a chance to keep the original walls of rooms before the flowing smoothing step is performed.roomChance
can 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. Starting withTilesetType.DEFAULT_DUNGEON
is a good choice fortype
.- Parameters:
type
- a TilesetType enum valueroomChance
- 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
-
getDungeon
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 IDungeonGenerator.- Specified by:
getDungeon
in interfaceIDungeonGenerator
- Returns:
- the most recently-produced dungeon/map as a 2D char array
-
getEnvironment
Gets an environment map as a 2D int array thatSectionDungeonGenerator
can use along with the normal 2D char array dungeon map to add dungeon features. This marks cells as eitherDungeonUtility.UNTOUCHED
(equal to 0),DungeonUtility.CAVE_FLOOR
(equal to 3), orDungeonUtility.CAVE_WALL
(equal to 4). 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.- Returns:
- a 2D int array that can be used as an environment map with SectionDungeonGenerator.
-