Class BiomeMapper.SimpleBiomeMapper

java.lang.Object
com.github.yellowstonegames.world.BiomeMapper.SimpleBiomeMapper
All Implemented Interfaces:
BiomeMapper
Enclosing interface:
BiomeMapper

public static class BiomeMapper.SimpleBiomeMapper extends Object implements BiomeMapper
A way to get biome information for the cells on a map when you only need a single value to describe a biome, such as "Grassland" or "TropicalRainforest".
To use: 1, Construct a SimpleBiomeMapper (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 as an index into Biome.TABLE to get a Biome instance, or used with an alternate Biome table of your design. Biome tables in this case are 66-element arrays organized into groups of 6 elements, with the last 6 elements reserved for unusual areas, like 60 for empty space where the map doesn't cover. Each group goes from the coldest temperature first to the warmest temperature last in the group. The first group of 6 contains the dryest biomes, the next 6 are medium-dry, the next are slightly-dry, the next slightly-wet, then medium-wet, then wettest. After this first block of dry-to-wet groups, there is a group of 6 for coastlines, a group of 6 for rivers, a group of 6 for lakes, a group of 6 for oceans, and then one element for space outside the map. The last 6 elements, starting with code 60, lead with the String "Space", and the rest after that are not expected to be encountered randomly on the surface of a world. This also assigns moisture codes and heat codes from 0 to 5 for each cell, which may be useful to simplify logic that deals with those factors.
  • Field Details

    • heatCodeData

      public int[][] heatCodeData
      The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.
    • moistureCodeData

      public int[][] moistureCodeData
      The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.
    • biomeCodeData

      public int[][] biomeCodeData
      The 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:
    • biomeTable

      public static final String[] biomeTable
      The default biome table to use with biome codes from biomeCodeData. Biomes are assigned based on heat and moisture for the first 36 of 66 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), then oceans (coldest to warmest), and lastly a row of unusual "biomes" such as empty space outside the map (meant for projections that don't fill a rectangle), underground biomes, volcanoes, and one for just any unknown terrain (called "Exotic").
  • Constructor Details

  • Method Details

    • getHeatCodeData

      public int[][] getHeatCodeData()
      Specified by:
      getHeatCodeData in interface BiomeMapper
    • getMoistureCodeData

      public int[][] getMoistureCodeData()
      Specified by:
      getMoistureCodeData in interface BiomeMapper
    • getBiomeCodeData

      public int[][] getBiomeCodeData()
      Specified by:
      getBiomeCodeData in interface BiomeMapper
    • getBiomeCode

      public int getBiomeCode(int x, int y)
      Description copied from interface: BiomeMapper
      Gets the most relevant biome code for a given x,y point on the map. Some mappers can store more than one biome at a location, but only the one with the highest influence will be returned by this method. Biome codes are always ints, and are typically between 0 and 60, both inclusive; they are meant to be used as indices into a table of names or other objects that identify a biome, accessible via BiomeMapper.getBiomeTable(). Although different classes may define biome codes differently, they should all be able to be used as indices into the String array returned by getBiomeNameTable().
      Specified by:
      getBiomeCode in interface BiomeMapper
      Parameters:
      x - the x-coordinate on the map
      y - the y-coordinate on the map
      Returns:
      an int that can be used as an index into the array returned by BiomeMapper.getBiomeTable()
    • getHeatCode

      public int getHeatCode(int x, int y)
      Description copied from interface: 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 interface BiomeMapper
      Parameters:
      x - the x-coordinate on the map
      y - 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: 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 interface BiomeMapper
      Parameters:
      x - the x-coordinate on the map
      y - 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 with getBiomeCode(int, int). This method returns a direct reference to Biome.TABLE, so modifying the returned array is discouraged (you should implement BiomeMapper using this class as a basis if you want to change its size).
      Specified by:
      getBiomeTable in interface BiomeMapper
      Returns:
      a direct reference to Biome.TABLE, a String array containing names of biomes
    • stringSerialize

      public String stringSerialize()
      Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type with SimpleBiomeMapper(String) or recreateFromString(String). Uses Base.BASE86 to 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:
      stringSerialize in interface BiomeMapper
      Returns:
      a String that stores the entire state of this generator
    • recreateFromString

      public static BiomeMapper.SimpleBiomeMapper recreateFromString(String data)
      Creates a new instance of this class from a serialized String produced by stringSerialize(). This is here for compatibility with other classes that use String serialization, but you can just use SimpleBiomeMapper(String) instead.
      Parameters:
      data - the output of stringSerialize()
      Returns:
      the map that was serialized, as a new generator
    • makeBiomes

      public 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). After calling this, biome codes can be taken from biomeCodeData and used as indices into Biome.TABLE or a custom biome table.
      Specified by:
      makeBiomes in interface BiomeMapper
      Parameters:
      world - a WorldMapGenerator that should have generated at least one map; it may be at any zoom
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface BiomeMapper
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object