Class BiomeMapper.UnrealisticBiomeMapper

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

public static class BiomeMapper.UnrealisticBiomeMapper extends Object implements BiomeMapper
Primarily useful for debugging, this makes every biome a wildly different color. It still blends between them, very much like how BiomeMapper.BlendedBiomeMapper works, but is meant to make discontinuities in the map easier to spot and then diagnose. It could also be useful for a psychedelic alien world, possibly.
  • 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.
    • colorDataOklab

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

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

      public final int[] colorTable
      The colors for each biome, with each as a packed oklab int. Always has 66 items, corresponding to the biomes in Biome.TABLE in order.
    • contrast

      public float contrast
    • coldestValueUpper

      public static final float coldestValueUpper
      See Also:
    • colderValueUpper

      public static final float colderValueUpper
      See Also:
    • coldValueUpper

      public static final float coldValueUpper
      See Also:
    • warmValueUpper

      public static final float warmValueUpper
      See Also:
    • warmerValueUpper

      public static final float warmerValueUpper
      See Also:
    • warmestValueUpper

      public static final float warmestValueUpper
      See Also:
    • driestValueUpper

      public static final float driestValueUpper
      See Also:
    • drierValueUpper

      public static final float drierValueUpper
      See Also:
    • dryValueUpper

      public static final float dryValueUpper
      See Also:
    • wetValueUpper

      public static final float wetValueUpper
      See Also:
    • wetterValueUpper

      public static final float wetterValueUpper
      See Also:
    • wettestValueUpper

      public static final float wettestValueUpper
      See Also:
    • HEAT_UPPER

      public static final float[] HEAT_UPPER
    • MOISTURE_UPPER

      public static final float[] MOISTURE_UPPER
    • HEAT_MID

      public static final float[] HEAT_MID
    • MOISTURE_MID

      public static final float[] MOISTURE_MID
  • Constructor Details

    • UnrealisticBiomeMapper

      public UnrealisticBiomeMapper()
      Simple constructor; pretty much does nothing. Make sure to call makeBiomes(WorldMapGenerator) before using fields like biomeCodeData.
    • UnrealisticBiomeMapper

      public UnrealisticBiomeMapper(String serialized)
      Creates a new generator from the given serialized String, produced by stringSerialize().
      Parameters:
      serialized - should have been produced by stringSerialize()
  • 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
    • 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 UnrealisticBiomeMapper(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.UnrealisticBiomeMapper 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 UnrealisticBiomeMapper(String) instead.
      Parameters:
      data - the output of stringSerialize()
      Returns:
      the map that was serialized, as a new generator
    • setColorTable

      public void setColorTable(int[] oklabColors)
    • initialize

      public void initialize()
    • initialize

      public void initialize(float hue, float saturation, float brightness, float contrast)
      Initializes the color tables this uses for all biomes, but allows rotating all hues and adjusting brightness/saturation/contrast to produce maps of non-Earth-like planets.
      Parameters:
      hue - hue rotation; 0.0 and 1.0 are no rotation, and 0.5 is maximum rotation
      saturation - added to the saturation of a biome color; usually close to 0.0, always between -1 and 1
      brightness - added to the lightness of a biome color; often close to 0.0, always between -1 and 1
      contrast - multiplied with the soft shading that applies to all land biomes
    • alter

      public void alter(com.github.tommyettinger.random.EnhancedRandom rng)
      Uses the current colors in colorTable to partly-randomize themselves, and also incorporates three random floats from the given rng. This should map similar colors in the input color table, like varieties of dark green forest, into similar output colors. It will not change color 60 (empty space), but will change everything else. Typically, colors like white ice will still map to white, and different shades of ocean blue will become different shades of some color (which could still be some sort of blue). This can be a useful alternative to initialize(float, float, float, float), because that method hue-rotates all colors by the same amount, while this method adjusts each input hue differently and based on their original value. You may want to call initialize() (either with no arguments or with four) before each call to this, because changes this makes to the color table would be read back the second time this is called without reinitialization.
      Parameters:
      rng - any non-null EnhancedRandom
    • match

      public void match(long seed, int... similarColors)
      Initializes the colors to use in some combination for all biomes, without regard for what the biome really is. There should be at least one packed int Oklab color given in similarColors, but there can be many of them. This type of color can be any of the color constants from DescriptiveColor, may be produced by DescriptiveColor.describeOklab(String), or might be made manually, in advanced cases, with DescriptiveColor.limitToGamut(int, int, int) and specifying the L, A, and B channels.
      Parameters:
      similarColors - an array or vararg of packed int Oklab colors with at least one element
    • getBiomeCode

      public int getBiomeCode(int x, int y)
      Gets the biome code for the dominant biome at a given x,y position.
      Specified by:
      getBiomeCode in interface BiomeMapper
      Parameters:
      x - the x-coordinate on the map
      y - 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: 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).
      Like with BiomeMapper.SimpleBiomeMapper, you can use a biome code directly from biomeCodeData as an index into this.
      Specified by:
      getBiomeTable in interface BiomeMapper
      Returns:
      a direct reference to Biome.TABLE, a Biome array with 66 items
    • 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 (packed Oklab int) colors from colorDataOklab.
      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