Class MimicWorldMap


public class MimicWorldMap extends EllipticalWorldMap
An unusual map generator that imitates an existing map (such as a map of Earth, which it can do by default). It uses the Mollweide projection (an elliptical map projection, the same as what EllipticalWorldMap uses) for both its input and output; an example can be seen here, imitating Earth using a 512x256 world map as a Region for input.
  • Field Details

    • earth

      public com.github.yellowstonegames.grid.Region earth
    • shallow

      public com.github.yellowstonegames.grid.Region shallow
    • coast

      public com.github.yellowstonegames.grid.Region coast
    • earthOriginal

      public com.github.yellowstonegames.grid.Region earthOriginal
    • buffer

      protected final transient com.github.yellowstonegames.grid.Region buffer
    • EARTH_ENCODED

      public static final String EARTH_ENCODED
      Stores a 512x256 Region that shows an Earth map with elliptical (Mollweide) projection, in a format that can be read back with Region.decompress(String). By using Region's compression, this takes up a lot less room than it would with most text-based formats, and even beats uncompressed binary storage of the map by a factor of 5.8f. The map data won't change here, so this should stay compatible.
      This was flipped twice, once early in 2023, and once to undo that in late 2025.
      See Also:
  • Constructor Details

    • MimicWorldMap

      public MimicWorldMap()
      Constructs a concrete WorldMapGenerator for a map that should look like Earth using an elliptical projection (specifically, a Mollweide projection). Always makes a 512x256 map. Uses Noise as its noise generator, with 1f as the octave multiplier affecting detail. If you were using MimicWorldMap(long, INoise, float), then this would be the same as passing the parameters 0x1337BABE1337D00DL, new Noise(DEFAULT_NOISE), 1f.
    • MimicWorldMap

      public MimicWorldMap(com.github.yellowstonegames.grid.Region toMimic)
      Constructs a concrete WorldMapGenerator for a map that should have land in roughly the same places as the given Region's "on" cells, using an elliptical projection (specifically, a Mollweide projection). 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. Uses Noise as its noise generator, with 1f as the octave multiplier affecting detail.
      Parameters:
      toMimic - the world map to imitate, as a Region with land as "on"; the height and width will be copied
    • MimicWorldMap

      public MimicWorldMap(long initialSeed, com.github.yellowstonegames.grid.Region toMimic)
      Constructs a concrete WorldMapGenerator for a map that should have land in roughly the same places as the given Region's "on" cells, using an elliptical projection (specifically, a Mollweide projection). Takes an initial seed and the Region containing land positions. 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. Uses Noise as its noise generator, with 1f as the octave multiplier affecting detail.
      Parameters:
      initialSeed - the seed for the FlowRandom this uses; this may also be set per-call to generate
      toMimic - the world map to imitate, as a Region with land as "on"; the height and width will be copied
    • MimicWorldMap

      public MimicWorldMap(long initialSeed, com.github.yellowstonegames.grid.Region toMimic, float octaveMultiplier)
      Constructs a concrete WorldMapGenerator for a map that should have land in roughly the same places as the given Region's "on" cells, using an elliptical projection (specifically, a Mollweide projection). Takes an initial seed, the Region containing land positions, and a multiplier that affects the level of detail by increasing or decreasing the number of octaves of noise used. 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. Uses Noise as its noise generator, with the given octave multiplier affecting detail.
      Parameters:
      initialSeed - the seed for the FlowRandom this uses; this may also be set per-call to generate
      toMimic - the world map to imitate, as a Region with land as "on"; the height and width will be copied
      octaveMultiplier - used to adjust the level of detail, with 0.5f at the bare-minimum detail and 1f normal
    • MimicWorldMap

      public MimicWorldMap(long initialSeed, com.github.yellowstonegames.grid.Region toMimic, com.github.yellowstonegames.grid.INoise noiseGenerator)
      Constructs a concrete WorldMapGenerator for a map that should have land in roughly the same places as the given Region's "on" cells, using an elliptical projection (specifically, a Mollweide projection). Takes an initial seed, the Region containing land positions, and parameters for noise generation (a Noise 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. Both Noise and Noise make sense to use for noiseGenerator, and the seed it's constructed with doesn't matter because this will change the seed several times at different scales of noise (it's fine to use the static Noise.instance or Noise.instance because they have no changing state between runs of the program). Uses the given noise generator, with 1f as the octave multiplier affecting detail.
      Parameters:
      initialSeed - the seed for the FlowRandom this uses; this may also be set per-call to generate
      toMimic - the world map to imitate, as a Region with land as "on"; the height and width will be copied
      noiseGenerator - an instance of a noise generator capable of 3D noise, usually Noise but can be any INoise
    • MimicWorldMap

      public MimicWorldMap(long initialSeed, com.github.yellowstonegames.grid.Region toMimic, com.github.yellowstonegames.grid.INoise noiseGenerator, float octaveMultiplier)
      Constructs a concrete WorldMapGenerator for a map that should have land in roughly the same places as the given Region's "on" cells, using an elliptical projection (specifically, a Mollweide projection). Takes an initial seed, the Region containing land positions, parameters for noise generation (a Noise implementation, which is usually Noise.instance, and a multiplier on how many octaves of noise to use, with 1f 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. Noise will be the fastest 3D generator to use for noiseGenerator, and the seed it's constructed with doesn't matter because this will change the seed several times at different scales of noise (it's fine to use the static Noise.instance because it has no changing state between runs of the program). 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 1f 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
      toMimic - the world map to imitate, as a Region with land as "on"; the height and width will be copied
      noiseGenerator - an instance of a noise generator capable of 3D noise, usually Noise or Noise
      octaveMultiplier - used to adjust the level of detail, with 0.5f at the bare-minimum detail and 1f normal
    • MimicWorldMap

      public MimicWorldMap(long initialSeed)
      Constructs a 512x256 elliptical world map that will use land forms with a similar shape to Earth.
      Parameters:
      initialSeed -
    • MimicWorldMap

      public MimicWorldMap(long initialSeed, com.github.yellowstonegames.grid.INoise noiseGenerator, float octaveMultiplier)
      Constructs a 512x256 elliptical world map that will use land forms with a similar shape to Earth.
      Parameters:
      initialSeed -
      noiseGenerator -
      octaveMultiplier -
    • MimicWorldMap

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

      public MimicWorldMap(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 MimicWorldMap(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 EllipticalWorldMap
      Returns:
      a String that stores the entire state of this generator
    • recreateFromString

      public static MimicWorldMap 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 MimicWorldMap(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
    • reprojectToElliptical

      public static com.github.yellowstonegames.grid.Region reprojectToElliptical(com.github.yellowstonegames.grid.Region rectangular)
      Meant for making maps conform to the Mollweide (elliptical) projection that MimicWorldMap uses.
      Parameters:
      rectangular - A Region where "on" represents land and "off" water, using any rectangular projection
      Returns:
      a reprojected version of rectangular that uses an elliptical projection
    • wrapX

      public int wrapX(int x, int y)
      Overrides:
      wrapX in class EllipticalWorldMap
    • wrapY

      public int wrapY(int x, int y)
      Overrides:
      wrapY in class EllipticalWorldMap
    • regenerate

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

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

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

      public String toString()
      Overrides:
      toString in class EllipticalWorldMap