Class OrganicConnectingMapGenerator

java.lang.Object
com.github.yellowstonegames.place.OrganicConnectingMapGenerator
All Implemented Interfaces:
PlaceGenerator

public class OrganicConnectingMapGenerator extends Object implements 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:

################################################################################
####.#######.......##############################.#######.#################.####
##.....####.........#................###...####....#####...########.######....##
##.....###.................................###.....#####...########..####.....##
##.....###.........##......................###.....####....######.....###......#
##.....####........#####..................####.....####.....#####.....####....##
###....######.....#######.#########........###......###......###......####....##
##....##############################.......###......######...###......####.....#
###....##############################......###.......###.#....#.......###......#
###...###############################..##...#........###.#....#................#
##..#.#######.#######################...#......................................#
##....#####....####...###############.........................................##
##...######....#####...#####.....####.....................#...................##
##....####.....#####...#####......####........#...............................##
##...######....######...#####.....####.......####.............................##
###...#####.....####....#####.....#####################################.......##
###...######....####....#####.....#######################################.....##
###...#####.....####....######...########################################....###
##.....####....#####.....#####.....#######################################..####
#..............#####.....####.......#####.....########......##############....##
#...............####.....###.................................####...######...###
#...............####.....##..................................###.....####.....##
##..............####.....#......#............#...............###.....####.....##
###...#.........#####...........##...........##....#........####.....####.....##
#####.##........########.#.###.#######......####.#####.....######....####.....##
#########.......########################################....#####.....####....##
##########......########################################....#####.....####....##
##########.......#####################################......####......#####..###
##########.......#....########..........#########.###.......####........#.#...##
##....####.............#######...........#######............####...............#
##.....###..............#####.............#####......#..#...####...............#
##.....###..............#####.............#####......#......####...............#
##.....###..............####..............######............####......#........#
#......####...###.......#####...#.........##########........#####...####.......#
##.....###########.......###########.......###########......############.......#
#......############......############.....#############......###########.......#
#......#############.....###########......#############.......###########......#
#.....###########.......###########.......###############.......##.#####.......#
#.....#####...##........#####.............#####.#..########..........###.......#
#......####...##........#####.............####.....########....................#
#......###....#.........####..............####.....#####.......................#
#......####.............#####.............####.....#####......................##
##.....########.........###########......#####.....####........####.#.#.......##
##....############......###############...####..##.####.......###########.....##
##....#############....################...####..##..####.....#############.....#
##....#############.....##############.....###...#..####.....############.....##
##.#..#############.....##############......#.......####.....############.....##
####.#######..#####.....#####....####...............####.#...####....####.....##
###....######.######...######.....####..............######...#####....###.....##
##....#######.######...######....#####..............######...#####....####....##
#.....#####...######...######....##########.#......##############..#.#####....##
#.....#####...######...#####.....#############.....##############.....####...###
##....#####....#####...#####......############....##############.....#####..####
##......###....####....#####.....################..#############......####..####
###.....##...#.####....######....###############...#############.......###....##
#####..........####....######...###############.....#####.#######.............##
####...........#####....#####...#######..######.....####....#####.......#.....##
##.#............####....#####....#####....#####.....####....#####.......#.....##
##.............#####....######...####.....#####.....#####...####......####....##
##...#.........#####....######...####......####.....#####.#.#####....###.......#
###.######....######....######....###......####.....####....##############.....#
#########.....######.....####.....###......####....#####....##############.....#
##########....######.....####.....####....####.....#####....##############.....#
#########......####......#####...#####....###......####......###########.......#
#####....................####....#####..............#........#########........##
##........#..........##..####....#####.......................#######..........##
##...................#######......####.......................####.............##
###...#.........##....#######.....####..............#........####.............##
#########..............######.....#####.......##....#........####.............##
################........#####.....#####...#.######..#........##########......###
###################......####.....####################.......##########.......##
###################.......##......#####################......###########......##
####################..............####################........##########......##
##.#####...########...............#######.#######.###...............###......###
##.............###................##........#####.......................##....##
##..............#..............#........#.......#........................#....##
##............................###.......#......................................#
####..........................###......##........#............................##
#####.####...######..#############.#######.###..###...###..#######..##...#######
################################################################################

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.github.yellowstonegames.grid.CellularAutomaton
     
    final int[][]
     
     
    final int
     
    com.github.tommyettinger.random.EnhancedRandom
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default 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 Type
    Method
    Description
    char[][]
    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 that DungeonProcessor can 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 calling generate() or some similar method present in a specific implementation.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 generate
      height - 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 generate
      height - the height of the dungeon map(s) to generate
      roomWidth - defaults to 6
      roomHeight - defaults to 6
      wallThickness - defaults to 3; determines how many cells minimum there are between rooms
      rng - 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:
      generate in interface PlaceGenerator
      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. 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.
      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 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 PlaceGenerator.
      Specified by:
      getPlaceGrid in interface PlaceGenerator
      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 DungeonProcessor can use along with the normal 2D char array dungeon map to add dungeon features. This marks cells as either DungeonTools.UNTOUCHED (equal to 0), DungeonTools.NATURAL_FLOOR, or DungeonTools.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:
      getEnvironment in interface PlaceGenerator
      Returns:
      a 2D int array that can be used as an environment map
    • toString

      public String toString()
      Overrides:
      toString in class Object