Package squidpony.squidgrid.mapping
Class PoliticalMapper
java.lang.Object
squidpony.squidgrid.mapping.PoliticalMapper
public class PoliticalMapper extends Object
When you have a world map as produced by
WorldMapGenerator
or some other source, you may want to fill it with
claims by various nations/factions, possibly procedural or possibly hand-made. This can assign contiguous areas of
land to various factions, while ignoring some amount of "wild" land if desired, and keeping oceans unclaimed.
The factions can be 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 nation shapes. Stores an atlas
that can be
used to figure out what a char in a produced 2D char array means for its claiming nation, a briefAtlas
that
will have short, identifiable parts of generated names corresponding to the same chars as in atlas, and an OrderedMap
of spokenLanguages
that contains any randomly generated languages produced for nations.
Example output of a related class.-
Field Summary
Fields Modifier and Type Field Description OrderedMap<Character,String>
atlas
Maps chars, as found in the returned array from generate(), to Strings that store the full name of nations.OrderedMap<Character,String>
briefAtlas
Maps chars, as found in the returned array from generate(), to Strings that store the short name of nations.int
height
static char[]
letters
String
name
char[][]
politicalMap
StatefulRNG
rng
OrderedMap<Character,List<FakeLanguageGen>>
spokenLanguages
Maps chars, as found in the returned array from generate(), to Strings that store the languages spoken in those nations, which could be user-assigned, unassigned, or randomly-generated.int
width
-
Constructor Summary
Constructors Constructor Description PoliticalMapper()
PoliticalMapper(String worldName)
Constructs a SpillWorldMap using the given world name, and uses the world name as the basis for all future random generation in this object.PoliticalMapper(IRNG random)
Constructs a SpillWorldMap using the given 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(WorldMapGenerator wmg, int factionCount, double controlledFraction)
Produces a political map for the land stored in the given WorldMapGenerator, with the given number of factions trying to take land in the world (essentially, nations).char[][]
generate(WorldMapGenerator wmg, Map<Character,String> existingAtlas, double controlledFraction)
Produces a political map for the land stored in the given WorldMapGenerator, with the given number of factions trying to take land in the world (essentially, nations).char[][]
generate(WorldMapGenerator wmg, OrderedMap<Character,FakeLanguageGen> atlasLanguages, double controlledFraction)
Produces a political map for the land stored in the given WorldMapGenerator, with the given number of factions trying to take land in the world (essentially, nations).char[][]
generate(GreasedRegion land, int factionCount, double controlledFraction)
Produces a political map for the land stored in the "on" cells of the given GreasedRegion, with the given number of factions trying to take land in the world (essentially, nations).char[][]
generate(GreasedRegion land, Map<Character,String> existingAtlas, double controlledFraction)
Produces a political map for the land stored in the "on" cells of the given GreasedRegion, with the given number of factions trying to take land in the world (essentially, nations).char[][]
generate(GreasedRegion land, OrderedMap<Character,FakeLanguageGen> atlasLanguages, double controlledFraction)
Produces a political map for the land stored in the "on" cells of the given GreasedRegion, with the given number of factions trying to take land in the world (essentially, nations).
-
Field Details
-
width
-
height
-
rng
-
name
-
politicalMap
-
letters
-
atlas
Maps chars, as found in the returned array from generate(), to Strings that store the full name of nations. -
briefAtlas
Maps chars, as found in the returned array from generate(), to Strings that store the short name of nations. -
spokenLanguages
Maps chars, as found in the returned array from generate(), to Strings that store the languages spoken in those nations, which could be user-assigned, unassigned, or randomly-generated.
-
-
Constructor Details
-
PoliticalMapper
public PoliticalMapper() -
PoliticalMapper
Constructs a SpillWorldMap using the given world name, and uses the world name as the basis for all future random generation in this object.- Parameters:
worldName
- a String name for the world that will be used as a seed for all random generation here
-
PoliticalMapper
Constructs a SpillWorldMap using the given world name, and uses the world name as the basis for all future random generation in this object.- Parameters:
random
- an RNG to generate the name for the world in a random language, which will also serve as a seed
-
-
Method Details
-
generate
Produces a political map for the land stored in the given WorldMapGenerator, 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. This version 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 theatlas
member of this object. For every Character key in atlas, there will be a String value in atlas that is the name of the nation, and for the same key inspokenLanguages
, there will be a non-empty List ofFakeLanguageGen
languages (usually one, sometimes two) that should match any names generated for the nation. Ocean and Wilderness get the default FakeLanguageGen instances "ELF" and "DEMONIC", in case you need languages for those areas for some reason.- Parameters:
wmg
- a WorldMapGenerator that has produced a map; this gets the land parts of the map to assign claims to, including rivers and lakes as part of nations but not oceansfactionCount
- the number of factions to have claiming land, cannot be negative or more than 255controlledFraction
- 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
Produces a political map for the land stored in the "on" cells of the given GreasedRegion, 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. This version 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 theatlas
member of this object. For every Character key in atlas, there will be a String value in atlas that is the name of the nation, and for the same key inspokenLanguages
, there will be a non-empty List ofFakeLanguageGen
languages (usually one, sometimes two) that should match any names generated for the nation. Ocean and Wilderness get the default FakeLanguageGen instances "ELF" and "DEMONIC", in case you need languages for those areas for some reason.- Parameters:
land
- a GreasedRegion that stores "on" cells for land and "off" cells for anything un-claimable, like oceanfactionCount
- the number of factions to have claiming land, cannot be negative or more than 255controlledFraction
- 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(WorldMapGenerator wmg, Map<Character,String> existingAtlas, double controlledFraction)Produces a political map for the land stored in the given WorldMapGenerator, 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. This version uses an existing atlas and does not assign tospokenLanguages
; it does not alter the existingAtlas parameter but uses it to determine what should be in this class'atlas
field. The atlas field will always contain '~' as the first key in its ordering (with value "Ocean" if no value was already assigned in existingAtlas to that key), and '%' as the second key (with value "Wilderness" if not already assigned); later entries will be taken from existingAtlas (not duplicating '~' or '%', but using the rest).- Parameters:
wmg
- a WorldMapGenerator that has produced a map; this gets the land parts of the map to assign claims to, including rivers and lakes as part of nations but not oceansexistingAtlas
- a Map (ideally an OrderedMap) of Character keys to be used in the 2D array, to String values that are the names of nations; should not have size greater than 255controlledFraction
- 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(GreasedRegion land, Map<Character,String> existingAtlas, double controlledFraction)Produces a political map for the land stored in the "on" cells of the given GreasedRegion, 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. This version uses an existing atlas and does not assign tospokenLanguages
; it does not alter the existingAtlas parameter but uses it to determine what should be in this class'atlas
field. The atlas field will always contain '~' as the first key in its ordering (with value "Ocean" if no value was already assigned in existingAtlas to that key), and '%' as the second key (with value "Wilderness" if not already assigned); later entries will be taken from existingAtlas (not duplicating '~' or '%', but using the rest).- Parameters:
land
- a GreasedRegion that stores "on" cells for land and "off" cells for anything un-claimable, like oceanexistingAtlas
- a Map (ideally an OrderedMap) of Character keys to be used in the 2D array, to String values that are the names of nations; should not have size greater than 255controlledFraction
- 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(WorldMapGenerator wmg, OrderedMap<Character,FakeLanguageGen> atlasLanguages, double controlledFraction)Produces a political map for the land stored in the given WorldMapGenerator, 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. This version uses a "recipe for an atlas" instead of a complete atlas; this is an OrderedMap of Character keys to FakeLanguageGen values, where each key represents a faction and each value is the language to use to generate names for that faction. This does assign tospokenLanguages
, but it doesn't change the actual FakeLanguageGen objects, since they are immutable. It may add some "factions" if not present to represent oceans and unclaimed land. The atlas field will always contain '~' as the first key in its ordering (with value "Ocean" if no value was already assigned in existingAtlas to that key, or a random nation name in the language that was mapped if there is one), and '%' as the second key (with value "Wilderness" if not already assigned, or a similar random nation name if there is one); later entries will be taken from existingAtlas (not duplicating '~' or '%', but using the rest).- Parameters:
wmg
- a WorldMapGenerator that has produced a map; this gets the land parts of the map to assign claims to, including rivers and lakes as part of nations but not oceansatlasLanguages
- an OrderedMap of Character keys to be used in the 2D array, to FakeLanguageGen objects that will be used to generate names; should not have size greater than 255controlledFraction
- 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(GreasedRegion land, OrderedMap<Character,FakeLanguageGen> atlasLanguages, double controlledFraction)Produces a political map for the land stored in the "on" cells of the given GreasedRegion, 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. This version uses a "recipe for an atlas" instead of a complete atlas; this is an OrderedMap of Character keys to FakeLanguageGen values, where each key represents a faction and each value is the language to use to generate names for that faction. This does assign tospokenLanguages
, but it doesn't change the actual FakeLanguageGen objects, since they are immutable. It may add some "factions" if not present to represent oceans and unclaimed land. The atlas field will always contain '~' as the first key in its ordering (with value "Ocean" if no value was already assigned in existingAtlas to that key, or a random nation name in the language that was mapped if there is one), and '%' as the second key (with value "Wilderness" if not already assigned, or a similar random nation name if there is one); later entries will be taken from existingAtlas (not duplicating '~' or '%', but using the rest).- Parameters:
land
- a GreasedRegion that stores "on" cells for land and "off" cells for anything un-claimable, like oceanatlasLanguages
- an OrderedMap of Character keys to be used in the 2D array, to FakeLanguageGen objects that will be used to generate names; should not have size greater than 255controlledFraction
- 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
-