public class FlowingCaveGenerator extends java.lang.Object implements IDungeonGenerator
TilesetType
like
TilesetType.DEFAULT_DUNGEON
have, but shouldn't have noticeable room/corridor areas, and should appear as
all one cave.
┌─────┐ ┌───────┬─┐ ┌───┐ ┌────┐ ┌────┐ ┌────┐ ┌──┐ ┌───┐ ┌─────┐
┌┘.....└─┘.......│.└─┘...└─┐ ┌─┐ ┌──┘....│ │....└──┬┘....└┬───┘..└──┐ ┌───┐ ┌┘...│ ┌┘.....└┐
│..........................└┐ ┌─┘.└┐ │.......└┐ │.......│......│.........└─┬┘...│ ┌───┬┘....│ │.......│
└┐.........┌┐...............└─┘....└┐ ┌┘........│ ┌┘....│.....................│...─┤┌─┘...│.....│ │.......│
│........┌┘│.......................└─┘.........└┐│.....│.....┌┐...................││...........│ │.......│
│........│┌┘...............................#....││.....│.....│└┐..................└┘...........│ │.......└┐
│.......┌┼┘.....┌┐............┌─┐..............┌┘│.....├─┐...│ │...............................│ │........│
│......┌┘│....┌─┘└┐.........┌─┘ └──────┐.......│ │....┌┘ │...└─┤......#.......│................│ └┐.......│
│.....┌┘ └┐.┌─┘ └┐.......┌┘ │......┌┘ │...┌┘ └─┐...│....│........┌┤........│.......│ ┌┘......┌┘
└┐...─┤ └─┘ │......─┤ ┌──┐ │......│ │...│ ┌┘.......─┘.......┌┘└─┐....─┬┤.......└┐ │.......│
┌┘....└┐ ┌─┐ ┌───┘.......└──┘..└┐ └┐.....│ ┌┘...└┐ ┌─┘.................│ ┌┘.....│└┐.......└─┘.......└┐
┌┘......└──┘.└┐┌┘......─┐..........└─┐ ┌┘.....└─┘.....│┌┘...................│ ┌┘......│ │..................│
┌┘.............└┘........│............└┬─┘..│...........└┘.....│.........───..└┬┘.......│ │....┌┐............│
│........................│......┌─┐....│....├┐...............──┘...............│........└─┘....│└┐...........│
│...┌─┐........................┌┘ └┐.......┌┘└┐................................................│ └┐..........│
│..┌┘ └┐.....................┌─┘ ┌┘.......│ │...............................................┌┘ │..........│
└──┘ └┐...................┌┘ ┌┘........│ └─┐...│...─┐...........│........................│ └┐.........│
│..................┌┘ │.........│ ┌─┐└───┴┐...│...........├─┐........│.............└─┐ │.........│
┌─┐ └──┐.....┌──┐......│ ┌┘...┌───┐.└─┘.└┐ └┐..├┐..........│ └┐......┌┤...............│ └─┐.......│
│.└─┐ └┐...┌┘ └┐.....└┐ │....│ ┌┘......└┐ │..│└───┐.....┌┘ └┐....┌┘├─.....┌──┐.....│ │......┌┘
│...└┐ └┐..│ ┌┘......└─┬─┘...─┤ │........└┐ ┌─┘.─┤ │.....│ │....│ │......└┐ └┐....│ └┐....─┤
└┐...│ ┌┘..│ │.........│......│ ┌┘.........└─┘....└─┐ ┌┘.....│ ┌┘....├─┘.......└┐ │....│ │.....│
└┐..│ ┌┘...│ │................│┌┘...................│ │......└───┘.....│..........│ │....└─┐ │...┌─┘
│..├─┘...─┤ ┌┘................├┘....................└─┘................│..........└┬┘......└─┐┌┘...│
├─.│......│ ┌┘..<........│...#.│...........................┌┬─......................│.........└┘...┌┘
│..│......│┌┘............│................................─┴┘......................................│
┌┘......┌──┘│....................┌─┐.....................................┌┐.........................│
│....┌──┘ └─┐..................│ └─┐.┌─┐....┌─┐....┌─┐.........┌─┐.....│└─┐......┌─┐....┌──┐......│
│...┌┘ └─┐...........┌────┘ └─┘┌┴─┬──┘ └────┘ │........┌┘ │....┌┘ │.....┌┘ └────┘ └──┐...│
│..┌┘ └┐.....┌─┐..└┐ │..│ ┌──┐ └┐......┌┘ ┌┘....└┐ └┐....│ ┌────┐ │...└┐
┌┘..└┐ ┌─────┐ ┌┘....┌┘ └┐..└┐ ┌┘..│ ┌─┘..└─┐ └┐.....│ │......└───┘....└┐ ┌┘....└┐ └┐...│
┌┘....└─┘.....└┐ ┌┘.....└┐ ┌┘...└┐ │...│┌┘......│ │.....│ └┐..........#....│ ┌┘......└┐ │...│
┌┘..........│...└┬┘.......└┐│.....└─┐ ┌─┘...││.......├─┐ │.....│ │...............└─┘........└┐ └┐..└┐
┌┘.......┌───┴┐...│.........││.......│ ┌┘....┌┘│.......│.└──┼┬─...│ ┌┘...........................└┐ │...│
┌┘.......┌┘ │.............└┘.......└┐ │...┌─┘ │...│.#......└┘....│ ┌┘........................│....└─┴─..└┐
│........│ ┌┘.......................│ │..┌┘ └┐..│..............└─┘......──.................│...........│
│........│ ┌┘..........┌─┐..........┌┘ │..│ └┐.............................┌─┐........................└┐
│........│ ┌┘.....┌─────┘ └──┐.......│ │..│ │.........................┌───┘ ├─...┌────┐...............│
│........│ │.....┌┘ └┐.....┌┘ └┐.└┐ └┐......┌─┬─┐....┌──┐.....│ ┌┘...┌┘ │....┌─┐........│
└┐......┌┘ │.....│ ┌────┐ │.....│ ┌┘..└┐ └┐....┌┘┌┘.│....│ └┐....│ ┌┘....│ │....│ │........│
│....┌─┘ │.....└┐ ┌─┘....│ └┐...─┤ ┌┘....│ └┐...└┬┘.......│ │....└┐ ┌┘.....│ ┌──┘....└┬┘........│
│....└─┐ └┐.....└─┘......└┐ │....└──┘.....└─┐ ┌─┬┘....│........└┐ ┌┘.....└┐│......└──┘........│.........│
└┐.....└┐ ┌─┴─..............│ ┌┘...............└──┘.│...............│┌┘.......└┘......................┌┐....│
│......└─┘.................└┐│.....................................└┘...............................─┤└┐...│
┌┘.........│.................└┘.........................│................┌──┐.#.#.....................│ └┐.┌┘
│..........│..........................................──┼──┐.....#......┌┘ │....................│....└┐ ├─┤
└┐.........│.....................┌─┐....................│ └─┐..........│ └─┐................#.├─┐...└─┘.└┐
│....┌┐.........┌─┐.........│..┌┘ └─┐..................│ │...┌───┐..└┐ │..................│ │........│
└┐...│└─┐.....┌─┘ └┐......┌─┴┐.└┐ └─┐..........│.....│ │...└┐ └┐..└─┐ └─┐....┌──┐.......┌┘ └┐.......│
┌┘..┌┘ └┐...┌┘ └┐.....│ │..│ ┌─┐ └┐.......┌─┤....┌┘ └┐...└─┬─┘....└─┐ └┐...└┐ └┐......│ │......┌┘
│...│ │...└───┐ │.....└┐┌┘..│┌┘.└┐ └┐.....┌┘ │....│ ├─....│........│ └┐...└┐ └┐.....└┐ ┌┘......│
┌┘..┌┘ ┌┘.......│ │......└┘...││...└┐ │.....└┐┌┘....└┐┌────┘.........┌─┐..└┐ └┐...└┐ └┐.....└─┘.......└┐
┌┘..┌┘ │........│ └┐..........└┘....└─┘......└┘......└┘..............│ └┐..└┐ │....│ ┌┘................│
│...│ ┌┘....┌───┘ └┐...............................................─┤ └┐..└┐ └┐...└─┤.................│
│..┌┘ ┌┘....┌┘ │..........................................┌┐....│ │...└┐ │.....│.................│
│.┌┘ ┌┘.....└┐ │..........................................│└─┐.┌┘ ┌┘....└─┐│.......................│
│.└┐ ┌┘.......└───┐ ┌┘.......┌┐......┌─┐..................│.....│ └─┘ │.......└┘.....>.........#.......│
│..└┬─┘............│┌──┘......┌─┘└┐.....│ └┐..─┐.............│.....│ │.............┌─┐...............┌┘
│...│..┌──┐........││........┌┘ └┐...┌┘ └┐..├───┐..............┌┘ │..┌─┐......┌─┘ ├─....┌┐........│
│......│ └┐......┌┘└┐......┌┘ └───┘ └──┘ └┐....┌──┐....┌┘ ┌─┴─┬┘ │.....┌┘ │....┌┘└┐......┌┘
└─┐....│ ├─.....└┐ │......└┐ ┌──┐ │....│ └┐..┌┘ ┌┘...└┐ │.....│ ┌┘....│ └┐.....│
├─..┌┘ ┌┘.......│ └┐......└┐ ┌┘..│ └┐...│ └──┘ ┌┘.....└─┘.....└─┐┌┘.....└┐ │.....│
┌─┘...└┐ ┌┘........└┐ │.......└───┘...│ │..┌┘ │................└┘.......│ └┐....└─┐
│......└─┘..........│ └─┐.............└─┬───┐ ┌┘.┌┘ │.........................└┐ ┌┘......│
│...................└┐ └───┐...........│...└───────┘..└┐ │.......┌─┐................│ │.......│
└┐...................│ │..........┌┴┐..............└┐ ├─......│ └┐...............└─┘.......│
└┐.#................│ │..........│ └┐..............└┐ ┌───┘.....┌─┘ │.........................│
└┐...............┌─┘ │.........┌┘ └┐.....┌───┐....│ │.........│ │......│....┌──────┐.....┌┘
└┐.┌───┐........│ └───┐....┌┘ └─┐.┌─┘ └─┐.┌┘ └┐......┌─┘ └─┐...┌┴────┘ └─┐..┌┘
└─┘ └────────┘ └────┘ └─┘ └─┘ └──────┘ └───┘ └──┘
Created by Tommy Ettinger on 8/18/2017.Modifier and Type | Field and Description |
---|---|
protected CellularAutomaton |
ca |
int[][] |
environment |
DungeonBoneGen |
gen |
int |
height |
IRNG |
rng |
TilesetType |
type |
int |
width |
Constructor and 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) |
Modifier and Type | Method and Description |
---|---|
char[][] |
generate()
Generates a flowing cave dungeon withthe same
TilesetType this was made with, or
TilesetType.DEFAULT_DUNGEON if none was specified. |
char[][] |
generate(TilesetType type)
Generates a flowing cave dungeon with a different
TilesetType than this generator was made with. |
char[][] |
generate(TilesetType type,
double roomChance)
Generates a flowing cave dungeon with a different
TilesetType 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 calling
generate() or
some similar method present in a specific implementation. |
int[][] |
getEnvironment()
Gets an environment map as a 2D int array that
SectionDungeonGenerator can use along with the normal
2D char array dungeon map to add dungeon features. |
public DungeonBoneGen gen
public final int width
public final int height
public TilesetType type
public IRNG rng
public final int[][] environment
protected CellularAutomaton ca
public FlowingCaveGenerator()
public FlowingCaveGenerator(int width, int height)
width
- the width of the dungeon map(s) to generateheight
- the height of the dungeon map(s) to generatepublic FlowingCaveGenerator(int width, int height, TilesetType type, IRNG rng)
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 RNGpublic char[][] generate()
TilesetType
this was made with, or
TilesetType.DEFAULT_DUNGEON
if none was specified. This uses the
convention of '#' representing a wall and '.' representing a bare floor.generate
in interface IDungeonGenerator
public char[][] generate(TilesetType type)
TilesetType
than this generator was made with.
The default type is TilesetType.DEFAULT_DUNGEON
if unspecified in the constructor.type
- a TilesetType enum valuepublic char[][] generate(TilesetType type, double roomChance)
TilesetType
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 to
RoomFinder
, 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 with
TilesetType.DEFAULT_DUNGEON
is a good choice for type
.type
- a TilesetType enum valueroomChance
- the chance, from 0.0 to 1.0, to preserve each room, keeping its walls where they startpublic char[][] getDungeon()
generate()
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.getDungeon
in interface IDungeonGenerator
public int[][] getEnvironment()
SectionDungeonGenerator
can use along with the normal
2D char array dungeon map to add dungeon features. This marks cells as either DungeonUtility.UNTOUCHED
(equal to 0), DungeonUtility.CAVE_FLOOR
(equal to 3), or DungeonUtility.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.Copyright © Eben Howard 2012–2022. All rights reserved.