Class SpillWorldMap

java.lang.Object
squidpony.squidgrid.mapping.SpillWorldMap

public class SpillWorldMap
extends Object
Generates a procedural world map and fills it with the requested number of factions, keeping some land unclaimed. The factions are given procedural names in an atlas that is linked to the chars used by the world map. Uses MultiSpill internally to produce the semi-random land and water shapes, hence the name.
This class is probably fine for a lot of roguelike usage, but if you want a more realistic map and still want to distribute factions across it, consider WorldMapGenerator's inner classes and PoliticalMapper or FantasyPoliticalMapper to place claims by factions. Most of the WorldMapGenerator maps allow wrapping around one axis (or both for WorldMapGenerator.TilingMap), and allow calculating data for the ecosystems on the world map with WorldMapGenerator.DetailedBiomeMapper. This class doesn't compute the height or moisture levels that DetailedBiomeMapper needs to figure out ecosystems.
Example output. Created by Tommy Ettinger on 9/12/2016.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    OrderedMap<Character,​String> atlas  
    int height  
    int[][] heightMap  
    static char[] letters  
    Coord[] mountains  
    String name  
    char[][] politicalMap  
    StatefulRNG rng  
    int width  
  • Constructor Summary

    Constructors 
    Constructor Description
    SpillWorldMap()  
    SpillWorldMap​(int width, int height, String worldName)
    Constructs a SpillWorldMap using the given width, height, and world name, and uses the world name as the basis for all future random generation in this object.
  • Method Summary

    Modifier and Type Method Description
    char[][] generate​(int factionCount)
    Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations).
    char[][] generate​(int factionCount, boolean makeAtlas)
    Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations).
    char[][] generate​(int factionCount, boolean makeAtlas, boolean makeHeight, double controlledFraction, double waterStrength)
    Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations).
    char[][] generate​(int factionCount, boolean makeAtlas, double controlledFraction)
    Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations).
    char[][] generate​(int factionCount, boolean makeAtlas, double controlledFraction, double waterStrength)
    Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SpillWorldMap

      public SpillWorldMap()
    • SpillWorldMap

      public SpillWorldMap​(int width, int height, String worldName)
      Constructs a SpillWorldMap using the given width, height, and world name, and uses the world name as the basis for all future random generation in this object.
      Parameters:
      width - the width of the map in cells
      height - the height of the map in cells
      worldName - a String name for the world that will be used as a seed for all random generation here
  • Method Details

    • generate

      public char[][] generate​(int factionCount, boolean makeAtlas)
      Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations). The output is a 2D char array where each letter char is tied to a different faction, while '~' is always water, and '%' is always wilderness or unclaimed land. A random amount, up to 10% of all land, will be unclaimed wilderness with this method; for more precise control, use the overload that takes a controlledFraction parameter and give it a value between 0.0 and 1.0, inclusive. If makeAtlas is true, this also generates an atlas with the procedural names of all the factions and a mapping to the chars used in the output; the atlas will be in the atlas member of this object but will be empty if makeAtlas has never been true in a call to this.
      If width or height is larger than 256, consider enlarging the Coord pool before calling this with Coord.expandPoolTo(width, height);. This will have no effect if width and height are both less than or equal to 256, but if you expect to be using maps that are especially large (which makes sense for world maps), expanding the pool will use more memory initially and then (possibly) much less over time, easing pressure on the garbage collector as well, as re-allocations of large Coords that would otherwise be un-cached are avoided.
      Parameters:
      factionCount - the number of factions to have claiming land, cannot be negative or more than 255
      makeAtlas - if true, this will assign random names to factions, accessible via atlas
      Returns:
      a 2D char array where letters represent the claiming faction, '~' is water, and '%' is unclaimed
    • generate

      public char[][] generate​(int factionCount, boolean makeAtlas, double controlledFraction)
      Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations). The output is a 2D char array where each letter char is tied to a different faction, while '~' is always water, and '%' is always wilderness or unclaimed land. The amount of unclaimed land is determined by the controlledFraction parameter, which will be clamped between 0.0 and 1.0, with higher numbers resulting in more land owned by factions and lower numbers meaning more wilderness. If makeAtlas is true, it also generates an atlas with the procedural names of all the factions and a mapping to the chars used in the output; the atlas will be in the atlas member of this object but will be empty if makeAtlas has never been true in a call to this.
      If width or height is larger than 256, consider enlarging the Coord pool before calling this with Coord.expandPoolTo(width, height);. This will have no effect if width and height are both less than or equal to 256, but if you expect to be using maps that are especially large (which makes sense for world maps), expanding the pool will use more memory initially and then (possibly) much less over time, easing pressure on the garbage collector as well, as re-allocations of large Coords that would otherwise be un-cached are avoided.
      Parameters:
      factionCount - the number of factions to have claiming land, cannot be negative or more than 255
      makeAtlas - if true, this will assign random names to factions, accessible via atlas
      controlledFraction - between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'
      Returns:
      a 2D char array where letters represent the claiming faction, '~' is water, and '%' is unclaimed
    • generate

      public char[][] generate​(int factionCount, boolean makeAtlas, double controlledFraction, double waterStrength)
      Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations). The output is a 2D char array where each letter char is tied to a different faction, while '~' is always water, and '%' is always wilderness or unclaimed land. The amount of unclaimed land is determined by the controlledFraction parameter, which will be clamped between 0.0 and 1.0, with higher numbers resulting in more land owned by factions and lower numbers meaning more wilderness. If makeAtlas is true, it also generates an atlas with the procedural names of all the factions and a mapping to the chars used in the output; the atlas will be in the atlas member of this object but will be empty if makeAtlas has never been true in a call to this.
      If width or height is larger than 256, consider enlarging the Coord pool before calling this with Coord.expandPoolTo(width, height);. This will have no effect if width and height are both less than or equal to 256, but if you expect to be using maps that are especially large (which makes sense for world maps), expanding the pool will use more memory initially and then (possibly) much less over time, easing pressure on the garbage collector as well, as re-allocations of large Coords that would otherwise be un-cached are avoided.
      Parameters:
      factionCount - the number of factions to have claiming land, cannot be negative or more than 255
      makeAtlas - if true, this will assign random names to factions, accessible via atlas
      controlledFraction - between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'
      waterStrength - a non-negative multiplier that affects ocean size; 1 is more land than water
      Returns:
      a 2D char array where letters represent the claiming faction, '~' is water, and '%' is unclaimed
    • generate

      public char[][] generate​(int factionCount, boolean makeAtlas, boolean makeHeight, double controlledFraction, double waterStrength)
      Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations). The output is a 2D char array where each letter char is tied to a different faction, while '~' is always water, and '%' is always wilderness or unclaimed land. The amount of unclaimed land is determined by the controlledFraction parameter, which will be clamped between 0.0 and 1.0, with higher numbers resulting in more land owned by factions and lower numbers meaning more wilderness. If makeAtlas is true, it also generates an atlas with the procedural names of all the factions and a mapping to the chars used in the output; the atlas will be in the atlas member of this object but will be empty if makeAtlas has never been true in a call to this. If makeHeight is true, this will generate a height map in an organic way (though it isn't especially fast on very large maps), assigning the height map as an int[][] to heightMap and the potential mountains, hills, or peaks to the Coord[] mountains. The first Coord in mountains is usually the tallest point on the map, though two or more small peaks that are very close to one another might fuse into one larger mountain range, with higher int values than those for the first mountain on its own.
      If width or height is larger than 256, consider enlarging the Coord pool before calling this with Coord.expandPoolTo(width, height);. This will have no effect if width and height are both less than or equal to 256, but if you expect to be using maps that are especially large (which makes sense for world maps), expanding the pool will use more memory initially and then (possibly) much less over time, easing pressure on the garbage collector as well, as re-allocations of large Coords that would otherwise be un-cached are avoided.
      Parameters:
      factionCount - the number of factions to have claiming land, cannot be negative or more than 255
      makeAtlas - if true, this will assign random names to factions, accessible via atlas
      makeHeight - if true, this will generate a height map, accessible via heightMap, with -1 for water
      controlledFraction - between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'
      waterStrength - a non-negative multiplier that affects ocean size; 1 is more land than water
      Returns:
      a 2D char array where letters represent the claiming faction, '~' is water, and '%' is unclaimed
    • generate

      public char[][] generate​(int factionCount)
      Generates a basic physical map for this world, then overlays a more involved political map with the given number of factions trying to take land in the world (essentially, nations). The output is a 2D char array where each letter char is tied to a different faction, while '~' is always water, and '%' is always wilderness or unclaimed land. Does not generate an atlas, so you should come up with meanings for the letters yourself.
      Parameters:
      factionCount - the number of factions to have claiming land
      Returns:
      a 2D char array where letters represent the claiming faction, '~' is water, and '%' is unclaimed