public class PoliticalMapper
extends java.lang.Object
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.Modifier and Type | Field and Description |
---|---|
OrderedMap<java.lang.Character,java.lang.String> |
atlas
Maps chars, as found in the returned array from generate(), to Strings that store the full name of nations.
|
OrderedMap<java.lang.Character,java.lang.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 |
java.lang.String |
name |
char[][] |
politicalMap |
StatefulRNG |
rng |
OrderedMap<java.lang.Character,java.util.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 and Description |
---|
PoliticalMapper() |
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.
|
PoliticalMapper(java.lang.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.
|
Modifier and Type | Method and Description |
---|---|
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,
java.util.Map<java.lang.Character,java.lang.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<java.lang.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).
|
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,
java.util.Map<java.lang.Character,java.lang.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<java.lang.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).
|
public int width
public int height
public StatefulRNG rng
public java.lang.String name
public char[][] politicalMap
public static final char[] letters
public final OrderedMap<java.lang.Character,java.lang.String> atlas
public final OrderedMap<java.lang.Character,java.lang.String> briefAtlas
public final OrderedMap<java.lang.Character,java.util.List<FakeLanguageGen>> spokenLanguages
public PoliticalMapper()
public PoliticalMapper(java.lang.String worldName)
worldName
- a String name for the world that will be used as a seed for all random generation herepublic PoliticalMapper(IRNG random)
random
- an RNG to generate the name for the world in a random language, which will also serve as a seedpublic char[][] generate(WorldMapGenerator wmg, int factionCount, double controlledFraction)
atlas
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 in spokenLanguages
, there will be a non-empty List of FakeLanguageGen
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.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 '%'public char[][] generate(GreasedRegion land, int factionCount, double controlledFraction)
atlas
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 in spokenLanguages
, there will be a non-empty List of FakeLanguageGen
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.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 '%'public char[][] generate(WorldMapGenerator wmg, java.util.Map<java.lang.Character,java.lang.String> existingAtlas, double controlledFraction)
spokenLanguages
; 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).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 '%'public char[][] generate(GreasedRegion land, java.util.Map<java.lang.Character,java.lang.String> existingAtlas, double controlledFraction)
spokenLanguages
; 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).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 '%'public char[][] generate(WorldMapGenerator wmg, OrderedMap<java.lang.Character,FakeLanguageGen> atlasLanguages, double controlledFraction)
spokenLanguages
, 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).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 '%'public char[][] generate(GreasedRegion land, OrderedMap<java.lang.Character,FakeLanguageGen> atlasLanguages, double controlledFraction)
spokenLanguages
, 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).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 '%'Copyright © Eben Howard 2012–2022. All rights reserved.