MapRegions

class MapRegions(ruleset: Ruleset)

Types

Companion
Link copied to clipboard
object Companion
ImpactType
Link copied to clipboard
enum ImpactType : Enum<MapRegions.ImpactType>
MapGenTileData
Link copied to clipboard
class MapGenTileData(tile: TileInfo, region: Region?)

Functions

anonymizeUnique
Link copied to clipboard
private fun anonymizeUnique(unique: Unique): Unique
assignCivToRegion
Link copied to clipboard
private fun assignCivToRegion(civInfo: CivilizationInfo, region: Region)
assignLuxuries
Link copied to clipboard
private fun assignLuxuries()

Assigns a luxury to each region. No luxury can be assigned to too many regions. Some luxuries are earmarked for city states. The rest are randomly distributed or don't occur att all in the map

assignRegions
Link copied to clipboard
fun assignRegions(tileMap: TileMap, civilizations: List<CivilizationInfo>)
canPlaceMinorCiv
Link copied to clipboard
private fun canPlaceMinorCiv(tile: TileInfo): Boolean
divideRegion
Link copied to clipboard
private fun divideRegion(region: Region, numDivisions: Int)

Recursive function, divides a region into numDivisions pars of equal-ish fertility

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
evaluateTileForStart
Link copied to clipboard
private fun evaluateTileForStart(tile: TileInfo)

Evaluates a tile for starting position, setting isGoodStart and startScore in MapGenTileData. Assumes that all tiles have corresponding MapGenTileData.

findStart
Link copied to clipboard
private fun findStart(region: Region)

Attempts to find a good start close to the center of region. Calls setRegionStart with the position

generateRegions
Link copied to clipboard
fun generateRegions(tileMap: TileMap, numRegions: Int)

Creates numRegions number of balanced regions for civ starting locations.

getCentralRectangle
Link copied to clipboard
private fun getCentralRectangle(originalRect: Rectangle, proportion: Float): Rectangle
getFallbackRegion
Link copied to clipboard
private fun getFallbackRegion(type: String, candidates: List<Region>): Region
getPotentialYield
Link copied to clipboard
private fun getPotentialYield(tile: TileInfo, stat: Stat, unimproved: Boolean = false): Float
getRegionPriority
Link copied to clipboard
private fun getRegionPriority(terrain: Terrain?): Int?
getTerrainRule
Link copied to clipboard
private fun getTerrainRule(terrain: Terrain): Unique
hashCode
Link copied to clipboard
open fun hashCode(): Int
isWaterOnlyResource
Link copied to clipboard
private fun isWaterOnlyResource(resource: TileResource): Boolean
normalizeStart
Link copied to clipboard
private fun normalizeStart(startTile: TileInfo, tileMap: TileMap, minorCiv: Boolean)

Attempts to improve the start on startTile as needed to make it decent. Relies on startPosition having been set previously. Assumes unchanged baseline values ie citizens eat 2 food each, similar production costs If minorCiv is true, different weightings will be used.

placeImpact
Link copied to clipboard
private fun placeImpact(type: MapRegions.ImpactType, tile: TileInfo, radius: Int)

Adds numbers to tileData in a similar way to closeStartPenalty, but for different types

placeLuxuries
Link copied to clipboard
private fun placeLuxuries(tileMap: TileMap)

Places all Luxuries onto tileMap. Assumes that assignLuxuries and placeMinorCivs have been called.

placeMajorDeposits
Link copied to clipboard
private fun placeMajorDeposits(tileList: List<TileInfo>, terrain: Terrain, fallbackWeightings: Boolean, baseImpact: Int, randomImpact: Int): Map<TileResource, Int>

Attempts to place major deposits in a tileList consisting exclusively of terrain tiles. Lifted out of the main function to allow postponing water resources.

placeMinorCiv
Link copied to clipboard
private fun placeMinorCiv(civ: CivilizationInfo, tileMap: TileMap, tile: TileInfo)
placeMinorCivs
Link copied to clipboard
private fun placeMinorCivs(tileMap: TileMap, civs: List<CivilizationInfo>)

Assigns civs to regions or "uninhabited" land and places them. Depends on assignLuxuries having been called previously. Note: can silently fail to place all city states if there is too little room. Currently our GameStarter fills out with random city states, Civ V behavior is to forget about the discarded city states entirely.

placeResourcesAndMinorCivs
Link copied to clipboard
fun placeResourcesAndMinorCivs(tileMap: TileMap, minorCivs: List<CivilizationInfo>)
placeResourcesInTiles
Link copied to clipboard
private fun placeResourcesInTiles(frequency: Int, tileList: List<TileInfo>, resourceOptions: List<TileResource>, baseImpact: Int = 0, randomImpact: Int = 0, majorDeposit: Boolean = false, forcePlacement: Boolean = false): Map<TileResource, Int>

Given a tileList and possible resourceOptions, will place a resource on every frequency tiles. Tries to avoid impacts, but falls back to lowest impact otherwise. Goes through the list in order, so pre-shuffle it! Assumes all tiles in the list are of the same terrain type when generating weightings, irrelevant if only one option. Respects terrainsCanBeFoundOn when there is only one option, unless forcePlacement is true.

placeStrategicAndBonuses
Link copied to clipboard
private fun placeStrategicAndBonuses(tileMap: TileMap)
setCloseStartPenalty
Link copied to clipboard
private fun setCloseStartPenalty(tile: TileInfo)
setRegionStart
Link copied to clipboard
private fun setRegionStart(region: Region, position: Vector2)
splitRegion
Link copied to clipboard
private fun splitRegion(regionToSplit: Region, firstPercent: Int): Pair<Region, Region>

Splits a region in 2, with the first having firstPercent of total fertility

toString
Link copied to clipboard
open fun toString(): String
tryAddingResourceToTiles
Link copied to clipboard
private fun tryAddingResourceToTiles(resource: TileResource, amount: Int, tiles: Sequence<TileInfo>, ratio: Float = 1f, respectImpacts: Boolean = false, baseImpact: Int = -1, randomImpact: Int = 0, majorDeposit: Boolean = false): Int

Attempts to place amount on tiles, checking tiles in order. A ratio below 1 means skipping some tiles, ie ratio = 0.25 will put a resource on every 4th eligible tile. Can optionally respect impact flags, and places impact if baseImpact>= 0. Returns number of placed resources.

tryPlaceMinorCivsInTiles
Link copied to clipboard
private fun tryPlaceMinorCivsInTiles(civsToPlace: MutableList<CivilizationInfo>, tileMap: TileMap, tileList: MutableList<TileInfo>)

Attempts to randomly place civs from civsToPlace in tiles from tileList. Assumes that tileList is pre-vetted and only contains habitable land tiles. Will modify both civsToPlace and tileList as it goes!

Properties

cityStateLuxuries
Link copied to clipboard
private val cityStateLuxuries: ArrayList<String>
randomLuxuries
Link copied to clipboard
private val randomLuxuries: ArrayList<String>
regions
Link copied to clipboard
private val regions: ArrayList<Region>
ruleset
Link copied to clipboard
val ruleset: Ruleset
tileData
Link copied to clipboard
private val tileData: HashMap<Vector2, MapRegions.MapGenTileData>
usingArchipelagoRegions
Link copied to clipboard
private var usingArchipelagoRegions: Boolean = false

Sources

jvm source
Link copied to clipboard