|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.server.generator.TerrainGenerator
public class TerrainGenerator
Class for making a Map based upon a land map.
| Field Summary | |
|---|---|
private TileImprovementType |
fishBonusLandType
|
private TileImprovementType |
fishBonusRiverType
|
private TileType |
lake
|
static int |
LAND_REGION_MAX_SIZE
|
static int |
LAND_REGION_MIN_SCORE
|
static int |
LAND_REGIONS_SCORE_VALUE
|
private static java.util.logging.Logger |
logger
|
private OptionGroup |
mapGeneratorOptions
|
private java.util.ArrayList<TileType> |
oceanTileTypes
|
static int |
PACIFIC_SCORE_VALUE
|
private java.util.Random |
random
|
private TileImprovementType |
riverType
|
private java.util.ArrayList<TileType> |
terrainTileTypes
|
| Constructor Summary | |
|---|---|
TerrainGenerator(OptionGroup mapGeneratorOptions,
java.util.Random random)
Creates a new TerrainGenerator. |
|
| Method Summary | |
|---|---|
private void |
createHighSeas(Map map)
Places "high seas"-tiles on the border of the given map. |
private static void |
createHighSeas(Map map,
int distToLandFromHighSeas,
int maxDistanceToEdge)
Places "high seas"-tiles on the border of the given map. |
(package private) void |
createLandRegions(Map map)
Creates land map regions in the given Map. |
void |
createMap(Game game,
boolean[][] landMap)
Creates a Map for the given Game. |
void |
createMap(Game game,
Game importGame,
boolean[][] landMap)
Creates a Map for the given Game. |
private void |
createMountains(Map map)
Creates mountain ranges on the given map. |
(package private) void |
createOceanRegions(Map map)
Creates ocean map regions in the given Map. |
Resource |
createResource(Tile tile)
|
private void |
createRivers(Map map)
Creates rivers on the given map. |
private Tile |
createTile(Game game,
int x,
int y,
boolean[][] landMap,
int latitude)
|
static void |
determineHighSeas(Map map,
int distToLandFromHighSeas,
int maxDistanceToEdge)
Places "high seas"-tiles on the border of the given map. |
static void |
encodeStyle(Tile ocean)
|
private void |
fillOcean(Map map,
Map.Position p,
Region region,
java.awt.Rectangle bounds)
Flood fill ocean regions. |
private void |
findLakes(Map map)
|
private boolean[][] |
floodFill(boolean[][] boolmap,
Map.Position p)
|
private boolean[][] |
floodFill(boolean[][] boolmap,
Map.Position p,
int limit)
Floodfills from a given Position p,
based on connectivity information encoded in boolmap |
private int |
getLand()
Returns the approximate number of land tiles. |
private OptionGroup |
getMapGeneratorOptions()
Gets the MapGeneratorOptions. |
Map.Position |
getRandomLandPosition(Map map,
java.util.Random random)
Select a random land position on the map. |
private TileType |
getRandomLandTileType(Game game,
int latitude)
Gets a random land tile type based on the given percentage. |
private TileType |
getRandomOceanTileType(Game game,
int latitude)
|
private TileType |
getRandomTileType(Game game,
java.util.List<TileType> candidates,
int latitude)
Returns a TileType, that fits to the regional requirements. |
private int |
limitToRange(int value,
int lower,
int upper)
|
private void |
perhapsAddBonus(Tile t,
boolean generateBonus)
Adds a terrain bonus with a probability determined by the MapGeneratorOptions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
public static final int LAND_REGIONS_SCORE_VALUE
public static final int LAND_REGION_MIN_SCORE
public static final int PACIFIC_SCORE_VALUE
public static final int LAND_REGION_MAX_SIZE
private final OptionGroup mapGeneratorOptions
private final java.util.Random random
private TileType lake
private TileImprovementType riverType
private TileImprovementType fishBonusLandType
private TileImprovementType fishBonusRiverType
private java.util.ArrayList<TileType> terrainTileTypes
private java.util.ArrayList<TileType> oceanTileTypes
| Constructor Detail |
|---|
public TerrainGenerator(OptionGroup mapGeneratorOptions,
java.util.Random random)
TerrainGenerator.
mapGeneratorOptions - The options.random - A Random number source.createMap(net.sf.freecol.common.model.Game, boolean[][])| Method Detail |
|---|
private int limitToRange(int value,
int lower,
int upper)
public Map.Position getRandomLandPosition(Map map,
java.util.Random random)
map - The Map to search in.random - A Random number source.
public void createMap(Game game,
boolean[][] landMap)
Map for the given Game.
The Map is added to the Game after
it is created.
game - The game.landMap - Determines whether there should be land
or ocean on a given tile. This array also
specifies the size of the map that is going
to be created.Map
public void createMap(Game game,
Game importGame,
boolean[][] landMap)
Map for the given Game.
The Map is added to the Game after
it is created.
game - The game.importGame - The game to import information form.landMap - Determines whether there should be land
or ocean on a given tile. This array also
specifies the size of the map that is going
to be created.Mappublic static void encodeStyle(Tile ocean)
private Tile createTile(Game game,
int x,
int y,
boolean[][] landMap,
int latitude)
private void perhapsAddBonus(Tile t,
boolean generateBonus)
MapGeneratorOptions.
t - a Tile valuegenerateBonus - a boolean valuepublic Resource createResource(Tile tile)
private OptionGroup getMapGeneratorOptions()
MapGeneratorOptions.
MapGeneratorOptions being used
when creating terrain.
private TileType getRandomOceanTileType(Game game,
int latitude)
game - latitude -
private TileType getRandomLandTileType(Game game,
int latitude)
game - the Gamelatitude - The location of the tile relative to the north/south
poles and equator:
0 is the mid-section of the map (equator)
+/-90 is on the bottom/top of the map (poles).
private TileType getRandomTileType(Game game,
java.util.List<TileType> candidates,
int latitude)
game - The game.candidates - A list of TileTypes to use for calculations.latitude - The latitude.
void createOceanRegions(Map map)
map - a Map value
private void fillOcean(Map map,
Map.Position p,
Region region,
java.awt.Rectangle bounds)
map - The Map to fill in.p - A valid starting Position.region - A Region to fill with.bounds - A Rectangle that bounds the filling.void createLandRegions(Map map)
LandGenerator.POLAR_HEIGHT
For the remaining land tiles, one region per contiguous landmass is created.
map - a Map valueprivate void createHighSeas(Map map)
map - The Map to create high seas on.
public static void determineHighSeas(Map map,
int distToLandFromHighSeas,
int maxDistanceToEdge)
map - The Map to create high seas on.distToLandFromHighSeas - The distance between the land
and the high seas (given in tiles).maxDistanceToEdge - The maximum distance a high sea tile
can have from the edge of the map.
private static void createHighSeas(Map map,
int distToLandFromHighSeas,
int maxDistanceToEdge)
map - The Map to create high seas on.distToLandFromHighSeas - The distance between the land
and the high seas (given in tiles).maxDistanceToEdge - The maximum distance a high sea tile
can have from the edge of the map.private int getLand()
private void createMountains(Map map)
map - The map to use.private void createRivers(Map map)
map - The map to create rivers on.private void findLakes(Map map)
private boolean[][] floodFill(boolean[][] boolmap,
Map.Position p,
int limit)
Position p,
based on connectivity information encoded in boolmap
boolmap - The connectivity information for this floodfillp - The starting positionlimit - Limit to stop floodfill at
private boolean[][] floodFill(boolean[][] boolmap,
Map.Position p)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||