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 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 Details

  • Constructor Details

  • Method Details

    • generate

      public char[][] generate()
      Generates a flowing cave dungeon withthe same 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.
      Specified by:
      generate in interface IDungeonGenerator
      Returns:
      a 2D char array representing a cave system with '#' for walls and '.' for floors
    • generate

      public char[][] generate​(TilesetType type)
      Generates a flowing cave dungeon with a different TilesetType than this generator was made with. The default type is TilesetType.DEFAULT_DUNGEON if unspecified in the constructor.
      Parameters:
      type - a TilesetType enum value
      Returns:
      a 2D char array for the cave system
    • generate

      public 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. 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.
      Parameters:
      type - a TilesetType enum value
      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
    • getDungeon

      public 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. 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 interface IDungeonGenerator
      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 that 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.
      Returns:
      a 2D int array that can be used as an environment map with SectionDungeonGenerator.