Class BiomeMapper.DetailedBiomeMapper
java.lang.Object
com.github.yellowstonegames.world.BiomeMapper.DetailedBiomeMapper
- All Implemented Interfaces:
BiomeMapper
- Enclosing interface:
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 Biomes using the extractBiome methods, or raw indices
into some (usually 66-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.5f, then biome B is the
"dominant" biome in the area.-
Nested Class Summary
Nested classes/interfaces inherited from interface BiomeMapper
BiomeMapper.BlendedBiomeMapper, BiomeMapper.DetailedBiomeMapper, BiomeMapper.SimpleBiomeMapper, BiomeMapper.UnrealisticBiomeMapper -
Field Summary
FieldsModifier and TypeFieldDescriptionint[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatint[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.int[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final float -
Constructor Summary
ConstructorsConstructorDescriptionSimple constructor; pretty much does nothing.DetailedBiomeMapper(String serialized) Creates a new generator from the given serialized String, produced bystringSerialize(). -
Method Summary
Modifier and TypeMethodDescriptionbooleancom.github.yellowstonegames.place.BiomeextractBiomeA(int biomeCode) Gets a String fromBiome.TABLEthat names the appropriate biome in part A of the given biome code.com.github.yellowstonegames.place.BiomeextractBiomeB(int biomeCode) Gets a String fromBiome.TABLEthat names the appropriate biome in part B of the given biome code.floatextractMixAmount(int biomeCode) This gets the portion of a biome code that represents the amount of mixing between two biomes.intextractPartA(int biomeCode) Gets the int stored in part A of the given biome code, which can be used as an index into other collections.intextractPartB(int biomeCode) Gets the int stored in part B of the given biome code, which can be used as an index into other collections.intgetBiomeCode(int x, int y) Gets the biome code for the dominant biome at a given x,y position.int[][]com.github.yellowstonegames.place.Biome[]Gets a String array where biome codes can be used as indices to look up a name for the biome they refer to.intgetHeatCode(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[][]intgetMoistureCode(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.int[][]inthashCode()voidmakeBiomes(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).recreateFromString(String data) Creates a new instance of this class from a serialized String produced bystringSerialize().Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type withDetailedBiomeMapper(String)orrecreateFromString(String).toString()
-
Field Details
-
heatCodeData
public int[][] heatCodeDataThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
moistureCodeData
public int[][] moistureCodeDataThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
biomeCodeData
public int[][] biomeCodeDataThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
coldestValueLower
public static final float coldestValueLower- See Also:
-
coldestValueUpper
public static final float coldestValueUpper- See Also:
-
colderValueLower
public static final float colderValueLower- See Also:
-
colderValueUpper
public static final float colderValueUpper- See Also:
-
coldValueLower
public static final float coldValueLower- See Also:
-
coldValueUpper
public static final float coldValueUpper- See Also:
-
warmValueLower
public static final float warmValueLower- See Also:
-
warmValueUpper
public static final float warmValueUpper- See Also:
-
warmerValueLower
public static final float warmerValueLower- See Also:
-
warmerValueUpper
public static final float warmerValueUpper- See Also:
-
warmestValueLower
public static final float warmestValueLower- See Also:
-
warmestValueUpper
public static final float warmestValueUpper- See Also:
-
driestValueLower
public static final float driestValueLower- See Also:
-
driestValueUpper
public static final float driestValueUpper- See Also:
-
drierValueLower
public static final float drierValueLower- See Also:
-
drierValueUpper
public static final float drierValueUpper- See Also:
-
dryValueLower
public static final float dryValueLower- See Also:
-
dryValueUpper
public static final float dryValueUpper- See Also:
-
wetValueLower
public static final float wetValueLower- See Also:
-
wetValueUpper
public static final float wetValueUpper- See Also:
-
wetterValueLower
public static final float wetterValueLower- See Also:
-
wetterValueUpper
public static final float wetterValueUpper- See Also:
-
wettestValueLower
public static final float wettestValueLower- See Also:
-
wettestValueUpper
public static final float wettestValueUpper- See Also:
-
-
Constructor Details
-
DetailedBiomeMapper
public DetailedBiomeMapper()Simple constructor; pretty much does nothing. Make sure to callmakeBiomes(WorldMapGenerator)before using fields likebiomeCodeData. -
DetailedBiomeMapper
Creates a new generator from the given serialized String, produced bystringSerialize().- Parameters:
serialized- should have been produced bystringSerialize()
-
-
Method Details
-
getHeatCodeData
public int[][] getHeatCodeData()- Specified by:
getHeatCodeDatain interfaceBiomeMapper
-
getMoistureCodeData
public int[][] getMoistureCodeData()- Specified by:
getMoistureCodeDatain interfaceBiomeMapper
-
getBiomeCodeData
public int[][] getBiomeCodeData()- Specified by:
getBiomeCodeDatain interfaceBiomeMapper
-
getBiomeCode
public int getBiomeCode(int x, int y) 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.5f (yielding part A) or higher (yielding part B).- Specified by:
getBiomeCodein interfaceBiomeMapper- 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
public int getHeatCode(int x, int y) Description copied from interface:BiomeMapperGets 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:
getHeatCodein interfaceBiomeMapper- 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
public int getMoistureCode(int x, int y) Description copied from interface:BiomeMapperGets 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:
getMoistureCodein interfaceBiomeMapper- 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
-
getBiomeTable
public com.github.yellowstonegames.place.Biome[] getBiomeTable()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 toBiome.TABLE, so modifying the returned array is discouraged (you should implementBiomeMapperusing this class as a basis if you want to change its size).
Unlike withBiomeMapper.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).- Specified by:
getBiomeTablein interfaceBiomeMapper- Returns:
- a direct reference to
Biome.TABLE, a Biome array with 66 items
-
extractPartA
public 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. This int should almost always range from 0 to 65 (both inclusive), so collections this is used as an index for should have a length of at least 66.- 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 65, inclusive.
-
extractBiomeA
public com.github.yellowstonegames.place.Biome extractBiomeA(int biomeCode) Gets a String fromBiome.TABLEthat 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 "Space" if none can be found
-
extractPartB
public 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. This int should almost always range from 0 to 65 (both inclusive), so collections this is used as an index for should have a length of at least 66.- 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 65, inclusive.
-
extractBiomeB
public com.github.yellowstonegames.place.Biome extractBiomeB(int biomeCode) Gets a String fromBiome.TABLEthat 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
public float extractMixAmount(int biomeCode) This gets the portion of a biome code that represents the amount of mixing between two biomes. Biome codes are normally obtained from thebiomeCodeDatafield, 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
-
stringSerialize
Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type withDetailedBiomeMapper(String)orrecreateFromString(String). UsesBase.BASE86to represent values very concisely, but not at all readably. The String this produces tends to be very long because it includes some 2D arrays as Strings.- Specified by:
stringSerializein interfaceBiomeMapper- Returns:
- a String that stores the entire state of this generator
-
recreateFromString
Creates a new instance of this class from a serialized String produced bystringSerialize(). This is here for compatibility with other classes that use String serialization, but you can just useDetailedBiomeMapper(String)instead.- Parameters:
data- the output ofstringSerialize()- Returns:
- the map that was serialized, as a new generator
-
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 frombiomeCodeDataand 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:
makeBiomesin interfaceBiomeMapper- Parameters:
world- a WorldMapGenerator that should have generated at least one map; it may be at any zoom
-
equals
- Specified by:
equalsin interfaceBiomeMapper- Overrides:
equalsin classObject
-
toString
-
hashCode
-