Package squidpony.squidgrid.mapping
Class WildMap
java.lang.Object
squidpony.squidgrid.mapping.WildMap
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
WildMap.MixedWildMap
@Beta public class WildMap extends Object implements Serializable
A finite 2D area map for some kind of wilderness, adapting to different ecosystems by changing its output.
Regional maps for wilderness areas have very different requirements from mostly-artificial dungeons. This is intended
to work alongside
Using this code mostly involves constructing a WildMap with a width, height, biome, and optionally a random number generator, an ArrayList of floor types (as Strings) that can appear, and an ArrayList of terrain content that can appear (also as Strings). Then you can call
This is marked Beta because there's still some work to be done, and the actual output will change even if the API doesn't have any breaks. While the wilderness maps this produces are usable, they don't have paths or areas that a character would have to find a way around (like a cliff). This is meant to be added at some point, probably in conjunction with some system for connecting WildMaps.
Created by Tommy Ettinger on 10/16/2019.
WorldMapGenerator
and WorldMapGenerator.DetailedBiomeMapper
to produce, for
example, very sparse maps with an occasional cactus in a desert, or very dense maps with many trees and shrubs for a
forest.
Using this code mostly involves constructing a WildMap with a width, height, biome, and optionally a random number generator, an ArrayList of floor types (as Strings) that can appear, and an ArrayList of terrain content that can appear (also as Strings). Then you can call
generate()
, which assigns indices into content
and
floors
, where an index can look up a value from contentTypes
or floorTypes
. The biome is
usually an index into WorldMapGenerator.DetailedBiomeMapper.biomeTable
, but can
be some other index if you don't use DetailedBiomeMapper (you would probably use a subclass then). The
contentTypes
field is an ArrayList; you can have and are encouraged to have duplicates when an object should
appear more often. An index of -1 in content indicates nothing of note is present there. There is also a String array
of floorTypes
that is not typically user-set unless you subclass WildMap yourself; it is used to look up the
indices in floors
. The floors are set to reasonable values for the particular biome, so a forest has "dirt"
and "leaves" among others, while a desert might only have "sand". Again, only the indices matter, so you could change
the values in floorTypes
to match names of textures in a graphical game and make lookup easier, or to a char
followed by the name of a color (as in SColor in the display module) for a text-based game.
This is marked Beta because there's still some work to be done, and the actual output will change even if the API doesn't have any breaks. While the wilderness maps this produces are usable, they don't have paths or areas that a character would have to find a way around (like a cliff). This is meant to be added at some point, probably in conjunction with some system for connecting WildMaps.
Created by Tommy Ettinger on 10/16/2019.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WildMap.MixedWildMap
A subclass ofWildMap
that serves as a ragged edge between 2, 3, or 4 WildMaps in a square intersection. -
Field Summary
Fields Modifier and Type Field Description int
biome
int[][]
content
ArrayList<String>
contentTypes
int[][]
floors
ArrayList<String>
floorTypes
int
height
IStatefulRNG
rng
int
width
-
Constructor Summary
Constructors Constructor Description WildMap()
WildMap(int width, int height, int biome)
WildMap(int width, int height, int biome, int seedA, int seedB)
WildMap(int width, int height, int biome, IStatefulRNG rng)
WildMap(int width, int height, int biome, IStatefulRNG rng, ArrayList<String> contentTypes)
WildMap(int width, int height, int biome, IStatefulRNG rng, ArrayList<String> floorTypes, ArrayList<String> contentTypes)
-
Method Summary
Modifier and Type Method Description static ArrayList<String>
contentByBiome(int biome, IRNG rng)
Gets a list of Strings that are really just the names of types of terrain feature for wilderness areas.static ArrayList<String>
floorsByBiome(int biome, IRNG rng)
Gets a list of Strings that are really just the names of types of floor tile for wilderness areas.void
generate()
Produces a map by filling thefloors
2D array with indices intofloorTypes
, and similarly filling thecontent
2D array with indices intocontentTypes
.static ArrayList<String>
makeRepeats(Object... rest)
Meant for generating large ArrayLists of Strings where an individual String may occur quite a few times.static ArrayList<String>
makeShuffledRepeats(IRNG rng, Object... rest)
static ArrayList<String>
makeVegetation(IRNG rng, int size, double monoculture, FakeLanguageGen naming)
static ArrayList<String>
pathsByBiome(int biome)
Gets a list of Strings that are really just the names of types of path tile for wilderness areas.
-
Field Details
-
Constructor Details
-
Method Details
-
makeRepeats
Meant for generating large ArrayLists of Strings where an individual String may occur quite a few times. The rest parameter is a vararg (it may also be an Object array) of alternating String and Integer values, where an Integer is how many times to repeat the preceding String in the returned ArrayList.- Parameters:
rest
- a vararg (or Object array) of alternating String and Integer values- Returns:
- an ArrayList of Strings, probably with some or most of them repeated; you may want to shuffle this result
-
makeShuffledRepeats
-
makeVegetation
public static ArrayList<String> makeVegetation(IRNG rng, int size, double monoculture, FakeLanguageGen naming) -
floorsByBiome
Gets a list of Strings that are really just the names of types of floor tile for wilderness areas.- Parameters:
biome
- an index intoWorldMapGenerator.DetailedBiomeMapper.biomeTable
, or some other index if you don't use DetailedBiomeMapperrng
- an IRNG, likeRNG
orGWTRNG
- Returns:
- a shuffled ArrayList that typically contains repeats of the kinds of floor that can appear here
-
pathsByBiome
Gets a list of Strings that are really just the names of types of path tile for wilderness areas. Not currently used.- Parameters:
biome
- an index intoWorldMapGenerator.DetailedBiomeMapper.biomeTable
, or some other index if you don't use DetailedBiomeMapper- Returns:
- an ArrayList that typically contains just the one or few types of path that can appear here
-
contentByBiome
Gets a list of Strings that are really just the names of types of terrain feature for wilderness areas.- Parameters:
biome
- an index intoWorldMapGenerator.DetailedBiomeMapper.biomeTable
, or some other index if you don't use DetailedBiomeMapperrng
- an IRNG, likeRNG
orGWTRNG
- Returns:
- a shuffled ArrayList that typically contains repeats of the kinds of terrain feature that can appear here
-
generate
Produces a map by filling thefloors
2D array with indices intofloorTypes
, and similarly filling thecontent
2D array with indices intocontentTypes
. You only need to call this method when you first generate a map with the specific parameters you want, such as biome, and later if you want another map with the same parameters.
Virtually all of this method is a wrapper around functionality provided byBlueNoise
, adjusted to fit wilderness maps slightly.
-