Package squidpony.squidgrid.mapping
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
Preview: https://gist.github.com/tommyettinger/c711f8fc83fa9919245d88092444bf7f Created by Tommy Ettinger on 4/2/2016.
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 Summary
Fields Modifier and Type Field Description OrderedMap<Coord,MapModule>
displacement
protected int[][]
environment
protected int
height
RegionMap<MapModule>
layout
protected char[][]
map
OrderedMap<Integer,ArrayList<MapModule>>
modules
protected long
rebuildSeed
IStatefulRNG
rng
DungeonUtility
utility
protected int
width
-
Constructor Summary
Constructors Constructor Description ModularMapGenerator()
Make a ModularMapGenerator with a GWTRNG using a random seed, height 30, and width 60.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.ModularMapGenerator(int width, int height, IRNG rng)
Make a ModularMapGenerator with the given height, width, and RNG.ModularMapGenerator(ModularMapGenerator copying)
Copies all fields from copying and makes a new DungeonGenerator. -
Method Summary
Modifier and Type Method Description char[][]
generate()
Generates a dungeon or other map as a 2D char array.char[][]
getBareMap()
Get the most recently generated char[][] map out of this class without any chars other than '#' or '.', for walls and floors respectively.char[][]
getDungeon()
Get the most recently generated char[][] map out of this class.int[][]
getEnvironment()
Gets the environment int 2D array for use with classes like RoomFinder.int
getHeight()
Height of the map in cells.char[][]
getMap()
Get the most recently generated char[][] map out of this class.int
getWidth()
Width of the map in cells.void
setEnvironment(int[][] environment)
Sets the environment int 2D array.void
setMap(char[][] map)
Change the underlying char[][]; only affects the toString method, and of course getMap
-
Field Details
-
Constructor Details
-
ModularMapGenerator
public ModularMapGenerator()Make a ModularMapGenerator with a GWTRNG using a random seed, height 30, and width 60. -
ModularMapGenerator
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 cellsheight
- The height of the dungeon in cells
-
ModularMapGenerator
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 cellsheight
- The height of the dungeon in cellsrng
- 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
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
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 interfaceIDungeonGenerator
- Returns:
- a char[][] map, or null.
-
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
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 interfaceIDungeonGenerator
- Returns:
- a 2D char array representing some kind of map, probably using standard conventions for walls/floors
-
setMap
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
Height of the map in cells.- Returns:
- Height of the map in cells.
-
getWidth
Width of the map in cells.- Returns:
- Width of the map in cells.
-
getEnvironment
Gets the environment int 2D array for use with classes like RoomFinder.- Returns:
- the environment int 2D array
-
setEnvironment
Sets the environment int 2D array.- Parameters:
environment
- a 2D array of int, where each int corresponds to a constant in MixedGenerator.
-