Class ModularMapGenerator

java.lang.Object
squidpony.squidgrid.mapping.ModularMapGenerator
All Implemented Interfaces:
IDungeonGenerator

@Beta
public class ModularMapGenerator
extends Object
implements IDungeonGenerator
Generator for maps of high-tech areas like space stations or starships, with repeated modules laid out in random ways. Different from traditional fantasy dungeon generation in that it should seem generally less chaotic in how it's laid out, and repeated elements with minor tweaks should be especially common. May also be useful in fantasy games for regimented areas built by well-organized military forces.
This is marked Beta because both MapModule and ModularMapGenerator need improvement to be actually usable, but it might be a while before there's a clear pathway towards how they can be improved.
Preview: https://gist.github.com/tommyettinger/c711f8fc83fa9919245d88092444bf7f Created by Tommy Ettinger on 4/2/2016.
  • Field Details

  • Constructor Details

    • ModularMapGenerator

      Make a ModularMapGenerator with a GWTRNG using a random seed, height 30, and width 60.
    • ModularMapGenerator

      public ModularMapGenerator​(int width, int height)
      Make a ModularMapGenerator with the given height and width; the RNG used for generating a dungeon and adding features will be a GWTRNG using a random seed.
      Parameters:
      width - The width of the dungeon in cells
      height - The height of the dungeon in cells
    • ModularMapGenerator

      public ModularMapGenerator​(int width, int height, IRNG rng)
      Make a ModularMapGenerator with the given height, width, and RNG. Use this if you want to seed the RNG.
      Parameters:
      width - The width of the dungeon in cells
      height - The height of the dungeon in cells
      rng - The RNG to use for all purposes in this class; if it is any kind of IStatefulRNG, then it will be used as-is; otherwise, a new GWTRNG will be used, randomly seeded by this parameter
    • ModularMapGenerator

      Copies all fields from copying and makes a new DungeonGenerator.
      Parameters:
      copying - the DungeonGenerator to copy
  • Method Details

    • getMap

      public char[][] getMap()
      Get the most recently generated char[][] map out of this class. The map may be null if generate() or setMap() have not been called.
      Returns:
      a char[][] map, or null.
    • getDungeon

      public char[][] getDungeon()
      Get the most recently generated char[][] map out of this class. The map may be null if generate() or setMap() have not been called.
      Specified by:
      getDungeon in interface IDungeonGenerator
      Returns:
      a char[][] map, or null.
    • getBareMap

      public char[][] getBareMap()
      Get the most recently generated char[][] map out of this class without any chars other than '#' or '.', for walls and floors respectively. The map may be null if generate() or setMap() have not been called.
      Returns:
      a char[][] map with only '#' for walls and '.' for floors, or null.
    • generate

      public char[][] generate()
      Description copied from interface: IDungeonGenerator
      Generates a dungeon or other map as a 2D char array. Any implementation may allow its own configuration and customization of how dungeons are generated, but each must provide this as a sane default. Most implementations should use the convention of '#' representing a wall and '.' representing a bare floor, but beyond that, anything could be present in the char array.
      Specified by:
      generate in interface IDungeonGenerator
      Returns:
      a 2D char array representing some kind of map, probably using standard conventions for walls/floors
    • setMap

      public void setMap​(char[][] map)
      Change the underlying char[][]; only affects the toString method, and of course getMap
      Parameters:
      map - a char[][], probably produced by an earlier call to this class and then modified.
    • getHeight

      public int getHeight()
      Height of the map in cells.
      Returns:
      Height of the map in cells.
    • getWidth

      public int getWidth()
      Width of the map in cells.
      Returns:
      Width of the map in cells.
    • getEnvironment

      public int[][] getEnvironment()
      Gets the environment int 2D array for use with classes like RoomFinder.
      Returns:
      the environment int 2D array
    • setEnvironment

      public void setEnvironment​(int[][] environment)
      Sets the environment int 2D array.
      Parameters:
      environment - a 2D array of int, where each int corresponds to a constant in MixedGenerator.