Class TilingWorldMap

java.lang.Object
com.github.yellowstonegames.world.WorldMapGenerator
com.github.yellowstonegames.world.TilingWorldMap

public class TilingWorldMap extends WorldMapGenerator
A concrete implementation of WorldMapGenerator that tiles both east-to-west and north-to-south. It tends to not appear distorted like StretchWorldMap does in some areas, even though this is inaccurate for a rectangular projection of a spherical world (that inaccuracy is likely what players expect in a map, though). The map this makes wraps toroidally, which matches the behavior in many older games, but nothing in the real world. You may want LocalMap instead, for non-world maps that don't tile. Example map.
  • Field Details

    • terrainBasicFreq

      protected static final float terrainBasicFreq
      See Also:
    • terrainRidgedFreq

      protected static final float terrainRidgedFreq
      See Also:
    • heatFreq

      protected static final float heatFreq
      See Also:
    • moistureFreq

      protected static final float moistureFreq
      See Also:
    • otherFreq

      protected static final float otherFreq
      See Also:
    • minHeat0

      protected float minHeat0
    • maxHeat0

      protected float maxHeat0
    • minHeat1

      protected float minHeat1
    • maxHeat1

      protected float maxHeat1
    • minWet0

      protected float minWet0
    • maxWet0

      protected float maxWet0
    • terrainRidged

      public final com.github.yellowstonegames.grid.NoiseWrapper terrainRidged
    • heat

      public final com.github.yellowstonegames.grid.NoiseWrapper heat
    • moisture

      public final com.github.yellowstonegames.grid.NoiseWrapper moisture
    • otherRidged

      public final com.github.yellowstonegames.grid.NoiseWrapper otherRidged
    • terrainBasic

      public final com.github.yellowstonegames.grid.NoiseWrapper terrainBasic
  • Constructor Details

    • TilingWorldMap

      public TilingWorldMap()
      Constructs a concrete WorldMapGenerator for a map that can be used as a tiling, wrapping east-to-west as well as north-to-south. Always makes a 256x256 map. Uses Noise as its noise generator, with 1.0f as the octave multiplier affecting detail. If you were using TilingWorldMap(long, int, int, INoise, float), then this would be the same as passing the parameters 0x1337BABE1337D00DL, 256, 256, WorldMapGenerator.new Noise(DEFAULT_NOISE), 1.0f.
    • TilingWorldMap

      public TilingWorldMap(int mapWidth, int mapHeight)
      Constructs a concrete WorldMapGenerator for a map that can be used as a tiling, wrapping east-to-west as well as north-to-south. Takes only the width/height of the map. The initial seed is set to the same large long every time, and it's likely that you would set the seed when you call WorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Uses Noise as its noise generator, with 1.0f as the octave multiplier affecting detail.
      Parameters:
      mapWidth - the width of the map(s) to generate; cannot be changed later
      mapHeight - the height of the map(s) to generate; cannot be changed later
    • TilingWorldMap

      public TilingWorldMap(long initialSeed, int mapWidth, int mapHeight)
      Constructs a concrete WorldMapGenerator for a map that can be used as a tiling, wrapping east-to-west as well as north-to-south. Takes an initial seed and the width/height of the map. The initialSeed parameter may or may not be used, since you can specify the seed to use when you call WorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Uses Noise as its noise generator, with 1.0f as the octave multiplier affecting detail.
      Parameters:
      initialSeed - the seed for the FlowRandom this uses; this may also be set per-call to generate
      mapWidth - the width of the map(s) to generate; cannot be changed later
      mapHeight - the height of the map(s) to generate; cannot be changed later
    • TilingWorldMap

      public TilingWorldMap(long initialSeed, int mapWidth, int mapHeight, com.github.yellowstonegames.grid.INoise noiseGenerator)
      Constructs a concrete WorldMapGenerator for a map that can be used as a tiling, wrapping east-to-west as well as north-to-south. Takes an initial seed, the width/height of the map, and a noise generator (an INoise implementation, which is usually Noise.instance. The initialSeed parameter may or may not be used, since you can specify the seed to use when you call WorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Any seed supplied to the Noise given to this (if it takes one) will be ignored, and Noise.getNoiseWithSeed(float, float, float, float, int) will be used to specify the seed many times. The detail level, which is the octaveMultiplier parameter that can be passed to another constructor, is always 1.0f with this constructor.
      Parameters:
      initialSeed - the seed for the FlowRandom this uses; this may also be set per-call to generate
      mapWidth - the width of the map(s) to generate; cannot be changed later
      mapHeight - the height of the map(s) to generate; cannot be changed later
      noiseGenerator - an instance of a noise generator capable of 4D noise, recommended to be Noise.instance
    • TilingWorldMap

      public TilingWorldMap(long initialSeed, int mapWidth, int mapHeight, com.github.yellowstonegames.grid.INoise noiseGenerator, float octaveMultiplier)
      Constructs a concrete WorldMapGenerator for a map that can be used as a tiling, wrapping east-to-west as well as north-to-south. Takes an initial seed, the width/height of the map, and parameters for noise generation (an INoise implementation, which is usually Noise.instance, and a multiplier on how many octaves of noise to use, with 1.0f being normal (high) detail and higher multipliers producing even more detailed noise when zoomed-in). The initialSeed parameter may or may not be used, since you can specify the seed to use when you call WorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Any seed supplied to the Noise given to this will be ignored, and Noise.getNoiseWithSeed(float, float, float, float, int) will be used to specify the seed many times. The octaveMultiplier parameter should probably be no lower than 0.5f, but can be arbitrarily high if you're willing to spend much more time on generating detail only noticeable at very high zoom; normally 1.0f is fine and may even be too high for maps that don't require zooming.
      Parameters:
      initialSeed - the seed for the FlowRandom this uses; this may also be set per-call to generate
      mapWidth - the width of the map(s) to generate; cannot be changed later
      mapHeight - the height of the map(s) to generate; cannot be changed later
      noiseGenerator - an instance of a noise generator capable of 4D noise, almost always Noise
      octaveMultiplier - used to adjust the level of detail, with 0.5f at the bare-minimum detail and 1.0f normal
    • TilingWorldMap

      public TilingWorldMap(TilingWorldMap other)
      Copies the TilingWorldMap other to construct a new one that is exactly the same. References will only be shared to Noise classes.
      Parameters:
      other - a TilingWorldMap to copy
    • TilingWorldMap

      public TilingWorldMap(int width, int height, String serialized)
      Creates a new generator from the given serialized String, produced by stringSerialize(), but this also requires width and height that match the first two lines of the given String (in Base.BASE86). It is almost always easier to use recreateFromString(String) instead.
      Parameters:
      width - width of the map or maps to generate; must match the first line of the given String in Base.BASE86
      height - height of the map or maps to generate; must match the second line of the given String in Base.BASE86
      serialized - should have been produced by stringSerialize()
  • Method Details

    • 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 TilingWorldMap(int, int, String) or (preferably) 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 several 2D arrays and a Region as Strings.
      Overrides:
      stringSerialize in class WorldMapGenerator
      Returns:
      a String that stores the entire state of this generator
    • recreateFromString

      public static TilingWorldMap recreateFromString(String data)
      Creates a new instance of this class from a serialized String produced by stringSerialize(). This can get the width and height from the String, which makes this probably preferable to using the constructor TilingWorldMap(int, int, String). This stores the last-generated map in this WorldMapGenerator, where it can be used by other code like a WorldMapView.
      Parameters:
      data - the output of stringSerialize()
      Returns:
      the map that was serialized, as a new generator
    • regenerate

      protected void regenerate(int startX, int startY, int usedWidth, int usedHeight, float landMod, float heatMod, long stateA, long stateB)
      Specified by:
      regenerate in class WorldMapGenerator
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object