Class FantasyPoliticalMapper

java.lang.Object
squidpony.squidgrid.mapping.FantasyPoliticalMapper
All Implemented Interfaces:
Serializable

public class FantasyPoliticalMapper
extends Object
implements Serializable
When you have a world map as produced by WorldMapGenerator, you may want to fill it with claims by various factions, where each faction may be hand-made and may consist of humans or some fantasy species, such as goblins, elves, or demons. This can assign contiguous areas of land to various factions, while acknowledging any preferences some species may have for specific types of land (elves may strongly prefer forest terrain, or flying demons may be the ideal residents for difficult mountainous terrain). This needs both a WorldMapGenerator and a WorldMapGenerator.BiomeMapper to allocate biomes and height/moisture info. The WorldMapGenerator is commonly a WorldMapGenerator.SphereMap or a WorldMapGenerator.EllipticalMap for a world map because they are fairly familiar map projections (WorldMapGenerator.HyperellipticalMap can look better if important areas are in the corners of the rectangular area, but it's less familiar). If you're making a political map for an island or isolated area, then you may want WorldMapGenerator.LocalMap or WorldMapGenerator.LocalMimicMap instead, which don't have world-scale features like polar ice caps or a warm equator.
See Also:
Serialized Form
  • Field Details

  • Constructor Details

  • Method Details

    • generate

      public char[][] generate()
      For when you really don't care what arguments you give this, you can use this zero-parameter overload of generate() to produce a 128x128 WorldMapGenerator.TilingMap world map with a WorldMapGenerator.SimpleBiomeMapper biome mapper, filling it with 30 random Factions and trying to avoid unclaimed land. You may need to use atlas to make sense of the randomly generated Factions. The seed will be random here.
      Returns:
      a 2D char array where each char can be used as a key into atlas to find the Faction that claims it
    • generate

      public char[][] generate​(long seed, WorldMapGenerator wmg, WorldMapGenerator.BiomeMapper biomeMapper, int factionCount)
      Generates a 2D char array that represents the claims to the land described by the WorldMapGenerator wmg and the BiomeMapper biomeMapper by various Factions, where FantasyPoliticalMapper.Faction is an inner class. This starts with two default Factions for "Ocean" and "Wilderness" (unclaimed land) and adds randomly generated Factions to fill factionCount (the two default factions aren't counted against this limit). These Factions typically claim contiguous spans of land stretching out from a starting point that matches the Faction's preferences for biome, land height, heat, and moisture. If a Faction requires a biome (like "TropicalRainforest") and the world has none of that type, then that Faction won't claim any land. If the WorldMapGenerator zooms in or out, you should call adjustZoom() to get a different 2D char array that represents the zoomed-in area. This overload tries to claim all land that can be reached by an existing Faction, though islands will often be unclaimed.
      Parameters:
      seed - the seed that determines how Factions will randomly spread around the world
      wmg - a WorldMapGenerator, which must have produced a map by calling its generate() method
      biomeMapper - a WorldMapGenerator.BiomeMapper, which must have been initialized with wmg and refer to the same world
      factionCount - the number of factions to have claiming land; cannot be negative or more than 253
      Returns:
      a 2D char array where each char can be used as a key into atlas to find the Faction that claims it
    • generate

      public char[][] generate​(long seed, WorldMapGenerator wmg, WorldMapGenerator.BiomeMapper biomeMapper, int factionCount, double controlledFraction)
      Generates a 2D char array that represents the claims to the land described by the WorldMapGenerator wmg and the BiomeMapper biomeMapper by various Factions, where FantasyPoliticalMapper.Faction is an inner class. This starts with two default Factions for "Ocean" and "Wilderness" (unclaimed land) and adds randomly generated Factions to fill factionCount (the two default factions aren't counted against this limit). These Factions typically claim contiguous spans of land stretching out from a starting point that matches the Faction's preferences for biome, land height, heat, and moisture. If a Faction requires a biome (like "TropicalRainforest") and the world has none of that type, then that Faction won't claim any land. If the WorldMapGenerator zooms in or out, you should call adjustZoom() to get a different 2D char array that represents the zoomed-in area. This overload tries to claim the given controlledFraction of land in total, though 1.0 can rarely be reached unless there are many factions and few islands.
      Parameters:
      seed - the seed that determines how Factions will randomly spread around the world
      wmg - a WorldMapGenerator, which must have produced a map by calling its generate() method
      biomeMapper - a WorldMapGenerator.BiomeMapper, which must have been initialized with wmg and refer to the same world
      factionCount - the number of factions to have claiming land; cannot be negative or more than 253
      controlledFraction - between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'
      Returns:
      a 2D char array where each char can be used as a key into atlas to find the Faction that claims it
    • generate

      public char[][] generate​(long seed, WorldMapGenerator wmg, WorldMapGenerator.BiomeMapper biomeMapper, Collection<FantasyPoliticalMapper.Faction> factions, int factionCount, double controlledFraction)
      Generates a 2D char array that represents the claims to the land described by the WorldMapGenerator wmg and the BiomeMapper biomeMapper by various Factions, where FantasyPoliticalMapper.Faction is an inner class. This starts with two default Factions for "Ocean" and "Wilderness" (unclaimed land) and adds all of factions until factionCount is reached; if it isn't reached, random Factions will be generated to fill factionCount (the two default factions aren't counted against this limit). These Factions typically claim contiguous spans of land stretching out from a starting point that matches the Faction's preferences for biome, land height, heat, and moisture. If a Faction requires a biome (like "TropicalRainforest") and the world has none of that type, then that Faction won't claim any land. If the WorldMapGenerator zooms in or out, you should call adjustZoom() to get a different 2D char array that represents the zoomed-in area. This overload tries to claim the given controlledFraction of land in total, though 1.0 can rarely be reached unless there are many factions and few islands.
      Parameters:
      seed - the seed that determines how Factions will randomly spread around the world
      wmg - a WorldMapGenerator, which must have produced a map by calling its generate() method
      biomeMapper - a WorldMapGenerator.BiomeMapper, which must have been initialized with wmg and refer to the same world
      factions - a Collection of FantasyPoliticalMapper.Faction that will be copied, shuffled and used before adding any random Factions
      factionCount - the number of factions to have claiming land; cannot be negative or more than 253
      controlledFraction - between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'
      Returns:
      a 2D char array where each char can be used as a key into atlas to find the Faction that claims it
    • adjustZoom

      public char[][] adjustZoom()
      If the WorldMapGenerator used by generate(long, WorldMapGenerator, WorldMapGenerator.BiomeMapper, Collection, int, double) zooms in or out, you can call this method to make the zoomedMap 2D char array match its zoom. The world-scale map, politicalMap, will remain unchanged unless generate() is called again, but zoomedMap will change each time either generate() or adjustZoom() is called. This method isn't 100% precise on how it places borders; for aesthetic reasons, the borders are tattered with GreasedRegion.fray(double) so they don't look like a wall of angular bubbles. Using fray() at each level of zoom is quasi-random, so if you zoom in on the same sequence of points on two different occasions, the change from fray() will be the same, but it may be slightly different if any point of zoom is different.
      Returns:
      a direct reference to zoomedMap, which will hold the correctly-zoomed version of politicalMap