public class FantasyPoliticalMapper
extends java.lang.Object
implements java.io.Serializable
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.Modifier and Type | Class and Description |
---|---|
static class |
FantasyPoliticalMapper.Faction
Represents a group that claims territory on a world-map, such as a nation.
|
Modifier and Type | Field and Description |
---|---|
OrderedMap<java.lang.Character,FantasyPoliticalMapper.Faction> |
atlas
Maps chars, as found in the returned array from generate(), to Strings that store the full name of nations.
|
WorldMapGenerator.BiomeMapper |
biomeMapper |
int |
height |
java.lang.String |
name |
char[][] |
politicalMap |
StatefulRNG |
rng |
int |
width |
WorldMapGenerator |
wmg |
char[][] |
zoomedMap |
Constructor and Description |
---|
FantasyPoliticalMapper()
Constructs a FantasyPoliticalMapper, but doesn't do anything with a map; you need to call
generate(long, WorldMapGenerator, WorldMapGenerator.BiomeMapper, Collection, int, double) for results. |
Modifier and Type | Method and Description |
---|---|
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. |
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. |
char[][] |
generate(long seed,
WorldMapGenerator wmg,
WorldMapGenerator.BiomeMapper biomeMapper,
java.util.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. |
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. |
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. |
public int width
public int height
public StatefulRNG rng
public java.lang.String name
public char[][] politicalMap
public char[][] zoomedMap
public WorldMapGenerator wmg
public WorldMapGenerator.BiomeMapper biomeMapper
public OrderedMap<java.lang.Character,FantasyPoliticalMapper.Faction> atlas
public FantasyPoliticalMapper()
generate(long, WorldMapGenerator, WorldMapGenerator.BiomeMapper, Collection, int, double)
for results.public char[][] generate()
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.atlas
to find the Faction that claims itpublic char[][] generate(long seed, WorldMapGenerator wmg, WorldMapGenerator.BiomeMapper biomeMapper, int factionCount)
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.seed
- the seed that determines how Factions will randomly spread around the worldwmg
- a WorldMapGenerator, which must have produced a map by calling its generate() methodbiomeMapper
- a WorldMapGenerator.BiomeMapper, which must have been initialized with wmg and refer to the same worldfactionCount
- the number of factions to have claiming land; cannot be negative or more than 253atlas
to find the Faction that claims itpublic char[][] generate(long seed, WorldMapGenerator wmg, WorldMapGenerator.BiomeMapper biomeMapper, int factionCount, double controlledFraction)
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.seed
- the seed that determines how Factions will randomly spread around the worldwmg
- a WorldMapGenerator, which must have produced a map by calling its generate() methodbiomeMapper
- a WorldMapGenerator.BiomeMapper, which must have been initialized with wmg and refer to the same worldfactionCount
- the number of factions to have claiming land; cannot be negative or more than 253controlledFraction
- between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'atlas
to find the Faction that claims itpublic char[][] generate(long seed, WorldMapGenerator wmg, WorldMapGenerator.BiomeMapper biomeMapper, java.util.Collection<FantasyPoliticalMapper.Faction> factions, int factionCount, double controlledFraction)
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.seed
- the seed that determines how Factions will randomly spread around the worldwmg
- a WorldMapGenerator, which must have produced a map by calling its generate() methodbiomeMapper
- a WorldMapGenerator.BiomeMapper, which must have been initialized with wmg and refer to the same worldfactions
- a Collection of FantasyPoliticalMapper.Faction
that will be copied, shuffled and used before adding any random FactionsfactionCount
- the number of factions to have claiming land; cannot be negative or more than 253controlledFraction
- between 0.0 and 1.0 inclusive; higher means more land has a letter, lower has more '%'atlas
to find the Faction that claims itpublic char[][] adjustZoom()
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.zoomedMap
, which will hold the correctly-zoomed version of politicalMap
Copyright © Eben Howard 2012–2022. All rights reserved.