Package squidpony.squidgrid.mapping
Class WorldMapGenerator.DetailedBiomeMapper
java.lang.Object
squidpony.squidgrid.mapping.WorldMapGenerator.DetailedBiomeMapper
- All Implemented Interfaces:
WorldMapGenerator.BiomeMapper
- Enclosing class:
- WorldMapGenerator
public static class WorldMapGenerator.DetailedBiomeMapper extends Object implements WorldMapGenerator.BiomeMapper
A way to get biome information for the cells on a map when you want an area's biome to be a combination of two
main biome types, such as "Grassland" or "TropicalRainforest", with the biomes varying in weight between areas.
To use: 1, Construct a DetailedBiomeMapper (constructor takes no arguments). 2, call
To use: 1, Construct a DetailedBiomeMapper (constructor takes no arguments). 2, call
makeBiomes(WorldMapGenerator)
with a WorldMapGenerator that has already produced at least one world map.
3, get biome codes from the biomeCodeData
field, where a code is an int that can be used with the
extract methods in this class to get various information from it (these are extractBiomeA(int)
,
extractBiomeB(int)
, extractPartA(int)
, extractPartB(int)
, and
extractMixAmount(int)
). You can get predefined names for biomes using the extractBiome methods (these
names can be changed in biomeTable
), or raw indices into some (usually 61-element) collection or array
with the extractPart methods. The extractMixAmount() method gets a float that is the amount by which biome B
affects biome A; if this is higher than 0.5, then biome B is the "dominant" biome in the area.-
Field Summary
Fields Modifier and Type Field Description int[][]
biomeCodeData
The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static String[]
biomeTable
The default biome table to use with parts of biome codes frombiomeCodeData
.static double
colderValueLower
static double
colderValueUpper
static double
coldestValueLower
static double
coldestValueUpper
static double
coldValueLower
static double
coldValueUpper
static double
drierValueLower
static double
drierValueUpper
static double
driestValueLower
static double
driestValueUpper
static double
dryValueLower
static double
dryValueUpper
int[][]
heatCodeData
The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.int[][]
moistureCodeData
The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static double
warmerValueLower
static double
warmerValueUpper
static double
warmestValueLower
static double
warmestValueUpper
static double
warmValueLower
static double
warmValueUpper
static double
wetterValueLower
static double
wetterValueUpper
static double
wettestValueLower
static double
wettestValueUpper
static double
wetValueLower
static double
wetValueUpper
-
Constructor Summary
Constructors Constructor Description DetailedBiomeMapper()
Simple constructor; pretty much does nothing. -
Method Summary
Modifier and Type Method Description String
extractBiomeA(int biomeCode)
Gets a String frombiomeTable
that names the appropriate biome in part A of the given biome code.String
extractBiomeB(int biomeCode)
Gets a String frombiomeTable
that names the appropriate biome in part B of the given biome code.float
extractMixAmount(int biomeCode)
This gets the portion of a biome code that represents the amount of mixing between two biomes.int
extractPartA(int biomeCode)
Gets the int stored in part A of the given biome code, which can be used as an index into other collections.int
extractPartB(int biomeCode)
Gets the int stored in part B of the given biome code, which can be used as an index into other collections.int
getBiomeCode(int x, int y)
Gets the biome code for the dominant biome at a given x,y position.String[]
getBiomeNameTable()
Gets a String array where biome codes can be used as indices to look up a name for the biome they refer to.int
getHeatCode(int x, int y)
Gets a heat code for a given x,y point on a map, usually as an int between 0 and 5 inclusive.int
getMoistureCode(int x, int y)
Gets a moisture code for a given x,y point on a map, usually as an int between 0 and 5 inclusive.void
makeBiomes(WorldMapGenerator world)
Analyzes the last world produced by the given WorldMapGenerator and uses all of its generated information to assign biome codes for each cell (along with heat and moisture codes).
-
Field Details
-
heatCodeData
The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
moistureCodeData
The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
biomeCodeData
The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
coldestValueLower
- See Also:
- Constant Field Values
-
coldestValueUpper
- See Also:
- Constant Field Values
-
colderValueLower
- See Also:
- Constant Field Values
-
colderValueUpper
- See Also:
- Constant Field Values
-
coldValueLower
- See Also:
- Constant Field Values
-
coldValueUpper
- See Also:
- Constant Field Values
-
warmValueLower
- See Also:
- Constant Field Values
-
warmValueUpper
- See Also:
- Constant Field Values
-
warmerValueLower
- See Also:
- Constant Field Values
-
warmerValueUpper
- See Also:
- Constant Field Values
-
warmestValueLower
- See Also:
- Constant Field Values
-
warmestValueUpper
- See Also:
- Constant Field Values
-
driestValueLower
- See Also:
- Constant Field Values
-
driestValueUpper
- See Also:
- Constant Field Values
-
drierValueLower
- See Also:
- Constant Field Values
-
drierValueUpper
- See Also:
- Constant Field Values
-
dryValueLower
- See Also:
- Constant Field Values
-
dryValueUpper
- See Also:
- Constant Field Values
-
wetValueLower
- See Also:
- Constant Field Values
-
wetValueUpper
- See Also:
- Constant Field Values
-
wetterValueLower
- See Also:
- Constant Field Values
-
wetterValueUpper
- See Also:
- Constant Field Values
-
wettestValueLower
- See Also:
- Constant Field Values
-
wettestValueUpper
- See Also:
- Constant Field Values
-
biomeTable
The default biome table to use with parts of biome codes frombiomeCodeData
. Biomes are assigned by heat and moisture for the first 36 of 61 elements (coldest to warmest for each group of 6, with the first group as the dryest and the last group the wettest), then the next 6 are for coastlines (coldest to warmest), then rivers (coldest to warmest), then lakes (coldest to warmest). The last is reserved for empty space.
Unlike withWorldMapGenerator.SimpleBiomeMapper
, you cannot use a biome code directly from biomeCodeData as an index into this in almost any case; you should pass the biome code to one of the extract methods.extractBiomeA(int)
orextractBiomeB(int)
will work if you want a biome name, orextractPartA(int)
orextractPartB(int)
should be used if you want a non-coded int that represents one of the biomes' indices into something like this. You can also get the amount by which biome B is affecting biome A withextractMixAmount(int)
.
-
-
Constructor Details
-
DetailedBiomeMapper
public DetailedBiomeMapper()Simple constructor; pretty much does nothing. Make sure to callmakeBiomes(WorldMapGenerator)
before using fields likebiomeCodeData
.
-
-
Method Details
-
getBiomeCode
Gets the biome code for the dominant biome at a given x,y position. This is equivalent to getting the raw biome code frombiomeCodeData
, callingextractMixAmount(int)
on that raw biome code, and chooosing whether to callextractPartA(int)
orextractPartB(int)
based on whether the mix amount is lower than 0.5 (yielding part A) or higher (yielding part B).- Specified by:
getBiomeCode
in interfaceWorldMapGenerator.BiomeMapper
- Parameters:
x
- the x-coordinate on the mapy
- the y-coordinate on the map- Returns:
- the biome code for the dominant biome part at the given location
-
getHeatCode
Description copied from interface:WorldMapGenerator.BiomeMapper
Gets a heat code for a given x,y point on a map, usually as an int between 0 and 5 inclusive. Some implementations may use more or less detail for heat codes, but 0 is always the coldest code used, and the highest value this can return for a given implementation refers to the hottest code used.- Specified by:
getHeatCode
in interfaceWorldMapGenerator.BiomeMapper
- Parameters:
x
- the x-coordinate on the mapy
- the y-coordinate on the map- Returns:
- an int that can be used to categorize how hot an area is, with 0 as coldest
-
getMoistureCode
Description copied from interface:WorldMapGenerator.BiomeMapper
Gets a moisture code for a given x,y point on a map, usually as an int between 0 and 5 inclusive. Some implementations may use more or less detail for moisture codes, but 0 is always the driest code used, and the highest value this can return for a given implementation refers to the wettest code used. Some implementations may allow seasonal change in moisture, e.g. monsoon seasons, to be modeled differently from average precipitation in an area, but the default assumption is that this describes the average amount of moisture (rain, humidity, and possibly snow/hail or other precipitation) that an area receives annually.- Specified by:
getMoistureCode
in interfaceWorldMapGenerator.BiomeMapper
- Parameters:
x
- the x-coordinate on the mapy
- the y-coordinate on the map- Returns:
- an int that can be used to categorize how much moisture an area tends to receive, with 0 as driest
-
getBiomeNameTable
Gets a String array where biome codes can be used as indices to look up a name for the biome they refer to. This table uses 6 levels of heat and 6 levels of moisture, and tracks rivers, coastlines, lakes, and oceans as potentially different types of terrain. Biome codes can be obtained withgetBiomeCode(int, int)
. This method returns a direct reference tobiomeTable
, so modifying the returned array is discouraged (you should implementWorldMapGenerator.BiomeMapper
using this class as a basis if you want to change its size).- Specified by:
getBiomeNameTable
in interfaceWorldMapGenerator.BiomeMapper
- Returns:
- a direct reference to
biomeTable
, a String array containing names of biomes
-
extractPartA
Gets the int stored in part A of the given biome code, which can be used as an index into other collections. This int should almost always range from 0 to 60 (both inclusive), so collections this is used as an index for should have a length of at least 61.- Parameters:
biomeCode
- a biome code that was probably received frombiomeCodeData
- Returns:
- an int stored in the biome code's part A; almost always between 0 and 60, inclusive.
-
extractBiomeA
Gets a String frombiomeTable
that names the appropriate biome in part A of the given biome code.- Parameters:
biomeCode
- a biome code that was probably received frombiomeCodeData
- Returns:
- a String that names the biome in part A of biomeCode, or "Empty" if none can be found
-
extractPartB
Gets the int stored in part B of the given biome code, which can be used as an index into other collections. This int should almost always range from 0 to 60 (both inclusive), so collections this is used as an index for should have a length of at least 61.- Parameters:
biomeCode
- a biome code that was probably received frombiomeCodeData
- Returns:
- an int stored in the biome code's part B; almost always between 0 and 60, inclusive.
-
extractBiomeB
Gets a String frombiomeTable
that names the appropriate biome in part B of the given biome code.- Parameters:
biomeCode
- a biome code that was probably received frombiomeCodeData
- Returns:
- a String that names the biome in part B of biomeCode, or "Ocean" if none can be found
-
extractMixAmount
This gets the portion of a biome code that represents the amount of mixing between two biomes. Biome codes are normally obtained from thebiomeCodeData
field, and aren't very usable on their own without calling methods like this,extractBiomeA(int)
, andextractBiomeB(int)
. This returns a float between 0.0f (inclusive) and 1.0f (exclusive), with 0.0f meaning biome B has no effect on an area and biome A is the only one used, 0.5f meaning biome A and biome B have equal effect, and 0.75f meaning biome B has most of the effect, three-fourths of the area, and biome A has less, one-fourth of the area.- Parameters:
biomeCode
- a biome code that was probably received frombiomeCodeData
- Returns:
- a float between 0.0f (inclusive) and 1.0f (exclusive) representing mixing of biome B into biome A
-
makeBiomes
Analyzes the last world produced by the given WorldMapGenerator and uses all of its generated information to assign biome codes for each cell (along with heat and moisture codes). After calling this, biome codes can be taken frombiomeCodeData
and used with methods in this class likeextractBiomeA(int)
,extractBiomeB(int)
, andextractMixAmount(int)
to find the two dominant biomes in an area, called biome A and biome B, and the mix amount, for finding how much biome B affects biome A.- Specified by:
makeBiomes
in interfaceWorldMapGenerator.BiomeMapper
- Parameters:
world
- a WorldMapGenerator that should have generated at least one map; it may be at any zoom
-