geo

package
v0.0.0-...-17a2a95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	FloodVariant1 = 0
	FloodVariant2 = 1
)
View Source
const (
	FeatureTypeOcean     = "ocean"
	FeatureTypeSea       = "sea"
	FeatureTypeLake      = "lake"
	FeatureTypeGulf      = "gulf"
	FeatureTypeIsle      = "isle"
	FeatureTypeContinent = "continent"
)

Landmark feature types.

View Source
const (
	CellTypeDeepWaters   = -2
	CellTypeCoastalWater = -1
	CellTypeCoastalLand  = 1
	CellTypeInland       = 2
)

CellType is the type of a cell indicating the distance to the shore.

View Source
const (
	ResourceTypeMetal = iota
	ResourceTypeGem
	ResourceTypeStone
)
View Source
const (
	ResMetIron = 1 << iota
	ResMetCopper
	ResMetLead
	ResMetTin
	ResMetSilver
	ResMetGold
	ResMetPlatinum
)

Metal resource flags starting with the cheapest metal.

View Source
const (
	ResGemAmethyst = 1 << iota
	ResGemTopaz
	ResGemSapphire
	ResGemEmerald
	ResGemRuby
	ResGemDiamond
)

Gemstone resource flags starting with the cheapest gem.

View Source
const (
	ResStoSandstone = 1 << iota
	ResStoLimestone
	ResStoChalk
	ResStoSlate
	ResStoMarble
	ResStoGranite
	ResStoBasalt
	ResStoObsidian
)

Stone resource flags starting with the most common stone. NOTE: Clay?

View Source
const (
	ResVarClay = 1 << iota
	ResVarSulfur
	ResVarSalt
	ResVarCoal
	ResVarOil
	ResVarGas
)
View Source
const (
	ResWoodOak = 1 << iota
	ResWoodBirch
	ResWoodPine
	ResWoodSpruce
	ResWoodCedar
	ResWoodShrub
	ResWoodFir
	ResWoodPalm
)

The 8 most important types of wood.

View Source
const (
	FluxVolVariantBasic           = 0
	FluxVolVariantBasicWithDrains = 1
	FluxVolVariantWalk1           = 2
	FluxVolVariantWalk2           = 3
)
View Source
const (
	SeasonSpring = iota
	SeasonSummer
	SeasonAutumn
	SeasonWinter
)
View Source
const (
	SpringEquinoxDayOfYear  = 80
	SummerSolsticeDayOfYear = 172
	AutumnEquinoxDayOfYear  = 263
	WinterSolsticeDayOfYear = 355
)
View Source
const (
	MinTemp          = genbiome.MinTemperatureC
	MaxTemp          = genbiome.MaxTemperatureC
	RangeTemp        = MaxTemp - MinTemp
	MaxPrecipitation = genbiome.MaxPrecipitationDM // 450cm
)
View Source
const MaxAltitudeFactor = gameconstants.EarthMaxElevation // How tall is the tallest mountain with an elevation of 1.0?
View Source
const ResMaxGems = 6
View Source
const ResMaxMetals = 7
View Source
const ResMaxStones = 7
View Source
const ResMaxVarious = 6
View Source
const ResMaxWoods = 8

Variables

View Source
var (
	DisNone       = Disaster{"None", 0, 0}
	DisStorm      = Disaster{"Storm", 0.99, 0.01}
	DisFire       = Disaster{"Fire", 0.98, 0.02}
	DisRockslide  = Disaster{"Rockslide", 0.97, 0.03}
	DisCaveIn     = Disaster{"Cave In", 0.95, 0.05}
	DisWildfire   = Disaster{"Wildfire", 0.93, 0.07}
	DisDrought    = Disaster{"Drought", 0.9, 0.1}
	DisFamine     = Disaster{"Famine", 0.85, 0.15}
	DisDisease    = Disaster{"Disease", 0.75, 0.25}
	DisEarthquake = Disaster{"Earthquake", 0.7, 0.3}
	DisFlood      = Disaster{"Flood", 0.65, 0.35}
	DisVolcano    = Disaster{"Volcanic Eruption", 0.4, 0.6}
	DisPlague     = Disaster{"Plague", 0.2, 0.8}
	DisSandstorm  = Disaster{"Sandstorm", 0.9, 0.1}
)

TODO: Move non-geographical disasters to a separate file or move this code to a more genericly named file.

Functions

func CalcSolarRadiation

func CalcSolarRadiation(latRad float64, dayOfYear int) float64

Calculate incoming solar (or shortwave) radiation, *Rs* (radiation hitting a horizontal plane after scattering by the atmosphere) from latitude, and day of year.

'latitude': Latitude [radians]. 'dayOfYear': Day of year integer between 1 and 365 or 366).

Returns incoming solar (or shortwave) radiation [MJ m-2 day-1]

func GemToString

func GemToString(gemsID int) string

func GenerateFlavorText

func GenerateFlavorText(desc BiomeDescription) string

func GenerateFlavorTextForBiome

func GenerateFlavorTextForBiome(seed int64, biome int) string

func GetMeanAnnualTemp

func GetMeanAnnualTemp(lat float64) float64

GetMeanAnnualTemp returns the temperature at a given latitude within the range of -15 °C to +30°C because that's the range in which the Whittaker biomes are defined. For this I assume that light hits the globe exactly from a 90° angle with respect to the planitary axis. See: https://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-shading/shading-normals (facing ratio) See: http://www-das.uwyo.edu/~geerts/cwx/notes/chap16/geo_clim.html NOTE: -35 °C to +31 °C would be ideally the temp gradient (according to real-life data), but we don't have (yet) any biomes defined for this.

func GetTempFalloffFromAltitude

func GetTempFalloffFromAltitude(height float64) float64

GetTempFalloffFromAltitude returns the temperature falloff at a given altitude in meters above sea level. (approx. 9.8 °C per 1000 m) NOTE: This is definitely not correct :) Source: https://www.quora.com/At-what-rate-does-temperature-drop-with-altitude

func GetWhittakerModBiomeColor

func GetWhittakerModBiomeColor(latitude, elevation, moisture, intensity float64) color.NRGBA

func MetalToString

func MetalToString(metalID int) string

func StoneToString

func StoneToString(stoneID int) string

func SumResources

func SumResources(r byte) int

SumResources returns the sum of the resource flag IDs in the byte. This is a convenience function for determining the approximate value of local resources. NOTE: In theory one could just cast the int to a byte and use the value like that, but the value would be a power of 2, which might be too stark a difference.

func VariousToString

func VariousToString(v int) string

func WoodToString

func WoodToString(v int) string

Types

type AscPriorityQueue

type AscPriorityQueue []*QueueEntry

AscPriorityQueue implements heap.Interface and holds Items. Priority is ascending (lowest score first).

func (AscPriorityQueue) Len

func (pq AscPriorityQueue) Len() int

func (AscPriorityQueue) Less

func (pq AscPriorityQueue) Less(i, j int) bool

func (*AscPriorityQueue) Pop

func (pq *AscPriorityQueue) Pop() interface{}

func (*AscPriorityQueue) Push

func (pq *AscPriorityQueue) Push(x interface{})

func (AscPriorityQueue) Swap

func (pq AscPriorityQueue) Swap(i, j int)

type BaseObject

type BaseObject struct {
	Seed int64      // Seed for random number generators
	Rand *rand.Rand // Rand initialized with above seed

	*spheremesh.SphereMesh // Triangle mesh containing the sphere information

	// Elevation related stuff
	Elevation         []float64       // Point / region elevation
	RegionCompression map[int]float64 // Point / region compression factor

	// Derived elevation related stuff
	Downhill         []int        // Point / region mapping to its lowest neighbor
	Landmasses       []int        // Point / region mapping of regions that are part of the same landmass
	LandmassSize     map[int]int  // Landmass ID to size mapping
	RegionIsMountain map[int]bool // Point / region is a mountain
	RegionIsVolcano  map[int]bool // Point / region is a volcano

	// Moisture related stuff
	Moisture          []float64    // Point / region moisture
	Rainfall          []float64    // Point / region rainfall
	Flux              []float64    // Point / region hydrology: throughflow of rainfall
	Waterbodies       []int        // Point / region mapping of pool to waterbody ID
	WaterbodySize     map[int]int  // Waterbody ID to size mapping
	LakeSize          map[int]int  // Lake ID to size mapping
	RegionIsWaterfall map[int]bool // Point / region is a waterfall

	// Temperature related stuff
	OceanTemperature []float64   // Ocean temperatures (yearly average)
	AirTemperature   []float64   // Air temperatures (yearly average)
	BiomeRegions     []int       // Point / region mapping of regions with the same biome
	BiomeRegionSize  map[int]int // Biome region ID to size mapping

	// Triangle stuff (purely derived from regions)
	TriElevation []float64 // Triangle elevation
	TriMoisture  []float64 // Triangle moisture

	// Currently unused:
	TriPool         []float64 // Triangle water pool depth
	TriFlow         []float64 // Triangle flow intensity (rainfall)
	TriDownflowSide []int     // Triangle mapping to side through which water flows downhill.
	OrderTri        []int     // Triangles in uphill order of elevation.
	SideFlow        []float64 // Flow intensity through sides

	// Currently unused:
	Waterpool []float64 // Point / region hydrology: water pool depth
	Drainage  []int     // Point / region mapping of pool to its drainage region
	// contains filtered or unexported fields
}

func (*BaseObject) AssignDistanceField

func (m *BaseObject) AssignDistanceField(seedRegs []int, stopReg map[int]bool) []float64

AssignDistanceField calculates the distance from any point in seedRegs to all other points, but don't go past any point in stopReg.

func (*BaseObject) AssignDownflow

func (m *BaseObject) AssignDownflow()

AssignDownflow starts with triangles that are considered "ocean" and works its way uphill to build a graph of child/parents that will allow us later to determine water flux and whatnot.

NOTE: This is the original code that Amit uses in his procedural planets project. He uses triangle centroids for his river generation, where I prefer to use the regions directly.

func (*BaseObject) AssignDownhill

func (m *BaseObject) AssignDownhill(usePool bool)

AssignDownhill will populate r_downhill with a mapping of region to lowest neighbor region. NOTE: This is based on mewo2's terrain generation code See: https://github.com/mewo2/terrain

func (*BaseObject) AssignFlow

func (m *BaseObject) AssignFlow()

AssignFlow calculates the water flux by traversing the graph generated with assignDownflow in reverse order (so, downhill?) and summing up the moisture.

NOTE: This is the original code that Amit uses in his procedural planets project. He uses triangle centroids for his river generation, where I prefer to use the regions directly.

func (*BaseObject) DirVecFromToRegs

func (m *BaseObject) DirVecFromToRegs(from, to int) [2]float64

DirVecFromToRegs returns the direction vector from region r1 to r2.

func (*BaseObject) FillSinks

func (m *BaseObject) FillSinks(randEpsilon bool) []float64

FillSinks is an implementation of the algorithm described in https://www.researchgate.net/publication/240407597_A_fast_simple_and_versatile_algorithm_to_fill_the_depressions_of_digital_elevation_models and a partial port of the implementation in: https://github.com/Rob-Voss/Learninator/blob/master/js/lib/Terrain.js

If randEpsilon is true, a randomized epsilon value is added to the elevation during each iteration. This is to prevent the algorithm from being too uniform.

NOTE: This algorithm produces a too uniform result at the moment, resulting in very artificially looking rivers. It lacks some kind of variation like noise. It's very fast and less destructive than my other, home-grown algorithm. Maybe it's worth to combine the two in some way?

func (*BaseObject) GetClosestNeighbor

func (m *BaseObject) GetClosestNeighbor(outregs []int, r int, vec [2]float64) int

GetClosestNeighbor returns the closest neighbor of r in the given direction.

func (*BaseObject) GetDistance

func (m *BaseObject) GetDistance(r1, r2 int) float64

GetDistance calculate the distance between two regions using the lat long and haversine.

func (*BaseObject) GetDownhill

func (m *BaseObject) GetDownhill(usePool bool) []int

GetDownhill will return a mapping of region to lowest neighbor region.

If usePool is true, then the lowest neighbor will be calculated using the water pool depth plus the elevation of the region.

func (*BaseObject) GetLowestRegNeighbor

func (m *BaseObject) GetLowestRegNeighbor(r int) int

GetLowestRegNeighbor returns the lowest neighbor region of a region.

func (*BaseObject) GetRegArea

func (m *BaseObject) GetRegArea(r int) float64

GetRegArea returns the surface area of a region on a unit sphere.

func (*BaseObject) GetRegLakeOrWaterBodySize

func (m *BaseObject) GetRegLakeOrWaterBodySize(r int) int

GetRegLakeOrWaterBodySize returns the size of the lake or waterbody that the provided region is part of.

func (*BaseObject) GetRegNeighbors

func (m *BaseObject) GetRegNeighbors(r int) []int

GetRegNeighbors returns the neighbor regions of a region.

func (*BaseObject) GetRivers

func (m *BaseObject) GetRivers(limit float64) [][]int

getRivers returns the merged river segments whose flux exceeds the provided limit. Each river is represented as a sequence of region indices.

func (*BaseObject) GetRiversInLatLonBB

func (m *BaseObject) GetRiversInLatLonBB(limit float64, minLat, minLon, maxLat, maxLon float64) [][]int

func (*BaseObject) GetSinks

func (m *BaseObject) GetSinks(skipSinksBelowSea, usePool bool) []int

GetSinks returns all regions that do not have a downhill neighbor. If 'skipSinksBelowSea' is true, regions below sea level are excluded. If 'usePool' is true, water pool data is used to determine if the sink is a lake.

func (*BaseObject) GetSlope

func (m *BaseObject) GetSlope() []float64

GetSlope returns the region slope by averaging the slopes of the triangles around a given region.

NOTE: This is based on mewo2's erosion code but uses rPolySlope instead of rSlope, which determines the slope based on all neighbors.

See: https://github.com/mewo2/terrain

func (*BaseObject) GetSteepness

func (m *BaseObject) GetSteepness() []float64

GetSteepness returns the steepness of every region to their downhill neighbor.

NOTE: We define steepness as the angle to a region from its downhill neighbor expressed as a value between 0.0 to 1.0 (representing an angle from 0° to 90°).

func (*BaseObject) Interpolate

func (m *BaseObject) Interpolate(regions []int) (*Interpolated, error)

Interpolate adds for each neighboring region pair one intermediate, interpolated region, increasing the "resolution" for the given regions.

func (*BaseObject) IsRegBelowOrAtSeaLevelOrPool

func (m *BaseObject) IsRegBelowOrAtSeaLevelOrPool(r int) bool

func (*BaseObject) IsRegBigRiver

func (m *BaseObject) IsRegBigRiver(r int) bool

func (*BaseObject) IsRegLake

func (m *BaseObject) IsRegLake(r int) bool

func (*BaseObject) IsRegLakeOrWaterBody

func (m *BaseObject) IsRegLakeOrWaterBody(r int) bool

func (*BaseObject) IsRegRiver

func (m *BaseObject) IsRegRiver(r int) bool

func (*BaseObject) IsRegWaterBody

func (m *BaseObject) IsRegWaterBody(r int) bool

func (*BaseObject) PickRandomRegions

func (m *BaseObject) PickRandomRegions(n int, useLatLon bool) []int

PickRandomRegions picks n random points/regions from the given mesh. 'n': The number of random regions to pick. 'useLatLon': Use lat/lon coordinates to pick random regions. This will allow us to get stable results even if the number of mesh regions changes. Like a result? Save the seed and you can get the same result again, even with higher mesh resolutions.

func (*BaseObject) PickRandomRegions2

func (m *BaseObject) PickRandomRegions2(n int) []GenRegion

func (*BaseObject) PropagateCompression

func (m *BaseObject) PropagateCompression(compression map[int]float64) []float64

PropagateCompression propagates the compression values from the seed regions to all other regions.

func (*BaseObject) RegSlope

func (m *BaseObject) RegSlope(i int) [2]float64

RegSlope returns the x/y vector for a given region by averaging the x/y vectors of the neighbor triangle centers.

func (*BaseObject) RegTriNormal

func (m *BaseObject) RegTriNormal(t int, nbs []int) vectors.Vec3

RegTriNormal calculates the surface normal of a triangle.

func (*BaseObject) RegTriSlope

func (m *BaseObject) RegTriSlope(t int, nbs []int) [2]float64

RegTriSlope calculates the slope based on three regions.

NOTE: This is based on mewo2's erosion code See: https://github.com/mewo2/terrain

WARNING: This only takes in account 3 neighbors!! Our implementation however has at times more than 3!

func (*BaseObject) ResetRand

func (m *BaseObject) ResetRand()

ResetRand resets the random number generator to its initial state.

func (*BaseObject) TestAreas

func (m *BaseObject) TestAreas()

TestAreas essentially sums up the surface area of all the regions and prints the total.. which shows that we're pretty close to the surface area of a unit sphere. :) Yay!

func (*BaseObject) UpdateDistanceField

func (m *BaseObject) UpdateDistanceField(regDistance []float64, seedRegs []int, stopReg map[int]bool) []float64

UpdateDistanceField updates the distance field for the given regions, given the new seed points.

type BiomeDescription

type BiomeDescription struct {
	Adjectives []string
	Nouns      []string
	Part1      []string
	Part2      []string
	Part3      []string
	Part4      []string
}

type BoundingBoxResult

type BoundingBoxResult struct {
	Regions   []int // Regions withi the bounding box.
	Triangles []int // Triangles within the bounding box.
}

BoundingBoxResult contains the results of a bounding box query.

type Calendar

type Calendar struct {
	// contains filtered or unexported fields
}

TODO: Create struct that tracks date and time.

func NewCalendar

func NewCalendar() *Calendar

func (*Calendar) GetDayOfYear

func (c *Calendar) GetDayOfYear() int

GetDayOfYear returns the current day of the year.

func (*Calendar) GetYear

func (c *Calendar) GetYear() int64

GetYear returns the current year.

func (*Calendar) GetYearProgress

func (c *Calendar) GetYearProgress() float64

GetYearProgress returns the progress of the current year in 0.0-1.0.

func (*Calendar) SetYear

func (c *Calendar) SetYear(year int64)

SetYear sets the year of the calendar.

func (*Calendar) Tick

func (c *Calendar) Tick()

Tick advances the calendar by one day.

func (*Calendar) TickYear

func (c *Calendar) TickYear()

TickYear advances the calendar by one year.

type Disaster

type Disaster struct {
	Name           string  // Name of the disaster
	Probability    float64 // Probability of the disaster occurring
	PopulationLoss float64 // Percentage of the population that will be lost
}

Disaster represents a Disaster that can occur in a region.

func RandDisaster

func RandDisaster(dis []Disaster) Disaster

type GenRegion

type GenRegion struct {
	Region   int
	Lat, Lon float64
}

type Geo

type Geo struct {
	*GeoConfig // Geo configuration
	*Calendar
	*BaseObject
	*Resources                          // Natural resources.
	PlateToVector        []vectors.Vec3 // Plate tectonics / movement vectors
	PlateIsOcean         map[int]bool   // Plate was chosen to be an ocean plate
	PlateRegs            []int          // Plate seed points / regions
	RegionToWindVec      [][2]float64   // Point / region wind vector
	RegionToWindVecLocal [][2]float64   // Point / region wind vector (local)
	RegionToOceanVec     [][2]float64   // Point / region ocean current vector
	RegionToPlate        []int          // Point / region to plate mapping
	Ocean_r              []int          // Ocean regions
	Mountain_r           []int          // Mountain regions
	Coastline_r          []int          // Coastline regions
	AvgInsolation        []float64      // Average daily insolation values
	QuadGeom             *QuadGeometry  // Quad geometry generated from the mesh (?)
}

func NewGeo

func NewGeo(seed int64, cfg *GeoConfig) (*Geo, error)

func (*Geo) CalcCurrentPressure

func (m *Geo) CalcCurrentPressure(currentVecs [][2]float64) []float64

func (*Geo) CalcFitnessScore

func (m *Geo) CalcFitnessScore(sf func(int) float64, distSeedFunc func() []int) []float64

CalcFitnessScore calculates the fitness value for all regions based on the given fitness function.

- 'sf' is the fitness function for scoring a region. - 'distSeedFunc' returns a number of regions from which we maximize the distance when calculating the fitness score.

func (*Geo) CalcFitnessScoreWithDistanceField

func (m *Geo) CalcFitnessScoreWithDistanceField(sf func(int) float64, regDistanceC []float64) []float64

func (*Geo) CalcSolarRadiation

func (m *Geo) CalcSolarRadiation(dayOfYear int) []float64

func (*Geo) Erode

func (m *Geo) Erode(amount float64) []float64

Erode erodes all region by the given amount and returns the resulting heightmap.

NOTE: This is based on mewo2's erosion code but limits the eroded height to a fraction of the height difference to the downhill neighbor, which prevents extreme sinks from forming.

See: https://github.com/mewo2/terrain

func (*Geo) GenerateGeology

func (m *Geo) GenerateGeology()

func (*Geo) GenerateRegPropertyDescription

func (m *Geo) GenerateRegPropertyDescription(p RegProperty) string

func (*Geo) GetAverageInsolation

func (m *Geo) GetAverageInsolation(day int) []float64

func (*Geo) GetAzgaarRegionBiome

func (m *Geo) GetAzgaarRegionBiome(r int, elev, maxElev float64) int

GetAzgaarRegionBiome returns the biome for a given region as per Azgaar's map generator.

func (*Geo) GetCustomContour

func (m *Geo) GetCustomContour(f func(idxA, idxB int) bool) [][]int

GetCustomContour returns a countour by tracing the region borders determined by the function. The result is a list of sequential triangle center points. Each sequence represents a continous border around regions of the same type.

The function returns true if the region borders should be traced / if the regions do not belong to the same group of regions.

func (*Geo) GetEarthquakeChance

func (m *Geo) GetEarthquakeChance() []float64

func (*Geo) GetErosionRate

func (m *Geo) GetErosionRate() []float64

GetErosionRate returns the erosion rate per region. NOTE: This is based on mewo2's erosion code See: https://github.com/mewo2/terrain

func (*Geo) GetErosionRate2

func (m *Geo) GetErosionRate2() []float64

GetErosionRate2 is an alternative erosion calculation which takes in account the steepness and flux of each region to determine the shape of eroded riverbeds and valleys.

func (*Geo) GetFitnessArableLand

func (m *Geo) GetFitnessArableLand() func(int) float64

func (*Geo) GetFitnessClimate

func (m *Geo) GetFitnessClimate() func(int) float64

GetFitnessClimate returns a fitness function that returns high scores for regions with high rainfall high temperatures, and alternatively high flux.

func (*Geo) GetFitnessInlandValleys

func (m *Geo) GetFitnessInlandValleys() func(int) float64

GetFitnessInlandValleys returns a fitness function with high scores for terrain that is not steep and far away from coastlines, mountains, and oceans.

func (*Geo) GetFitnessProximityToWater

func (m *Geo) GetFitnessProximityToWater() func(int) float64

getFitnessProximityToWater returns a fitness function with high scores for terrain close to water.

func (*Geo) GetFitnessSteepMountains

func (m *Geo) GetFitnessSteepMountains() func(int) float64

GetFitnessSteepMountains returns a fitness function with high scores for steep terrain close to mountains.

func (*Geo) GetFloodChance

func (m *Geo) GetFloodChance() []float64

func (*Geo) GetGeoDisasterFunc

func (m *Geo) GetGeoDisasterFunc() func(int) GeoDisasterChance

func (*Geo) GetInsolationShadowDistance

func (m *Geo) GetInsolationShadowDistance(region, day int, hour float64, outTri, outRegs []int) float64

GetInsolationShadowDistance returns the distance to the first region that blocks the sun for the given region, day and hour.

func (*Geo) GetMinMaxTemperature

func (m *Geo) GetMinMaxTemperature(lat float64) (min, max float64)

GetMinMaxTemperature returns the minimum and maximum temperature for the current day of the year and the given latitude.

func (*Geo) GetMinMaxTemperatureOfDay

func (m *Geo) GetMinMaxTemperatureOfDay(lat float64, dayOfYear int) (min, max float64)

func (*Geo) GetRegCellTypes

func (m *Geo) GetRegCellTypes() []int

GetRegCellTypes maps the region to its cell type.

NOTE: Currently this depends on the region graph, which will break things once we increas or decrease the number of regions on the map as the distance between regions will change with the region density.

Value meanings:

-2: deep ocean or large lake -1: region is a water cell next to a land cell (lake shore/coastal water) +1: region is a land cell next to a water cell (lake shore/coastal land) +2: region is a land cell next to a coastal land cell >2: region is inland

func (*Geo) GetRegHaven

func (m *Geo) GetRegHaven(reg int) (int, int)

GetRegHaven returns the closest neighbor region that is a water cell, which can be used as a haven, and returns the number of water neighbors, indicating the harbor size.

If no haven is found, -1 is returned.

func (*Geo) GetRegPropertyFunc

func (m *Geo) GetRegPropertyFunc() func(int) RegProperty

GetRegPropertyFunc returns a function that returns the properties of a region. NOTE: This is probably a very greedy function.

func (*Geo) GetRegTemperature

func (m *Geo) GetRegTemperature(r int, maxElev float64) float64

GetRegTemperature returns the average yearly temperature of the given region at the surface.

func (*Geo) GetRegWhittakerModBiomeFunc

func (m *Geo) GetRegWhittakerModBiomeFunc() func(r int) int

GetRegWhittakerModBiomeFunc returns a function that returns the Whittaker biome for a given region.

func (*Geo) GetRegionFeatureTypeFunc

func (m *Geo) GetRegionFeatureTypeFunc() func(int) string

GetRegionFeatureTypeFunc returns a function that returns the feature type of a given region.

func (*Geo) GetRockSlideAvalancheChance

func (m *Geo) GetRockSlideAvalancheChance() []float64

func (*Geo) GetSeason

func (m *Geo) GetSeason(lat float64) int

GetSeason returns the season for the current day of the year and the given latitude.

func (*Geo) GetSolarRadiation

func (m *Geo) GetSolarRadiation(lat float64) float64

GetSolarRadiation returns the solar radiation for the current day of the year and the given latitude.

func (*Geo) GetStats

func (m *Geo) GetStats(rr []int) *Stats

func (*Geo) GetTriTemperature

func (m *Geo) GetTriTemperature(t int, maxElev float64) float64

GetTriTemperature returns the average yearly temperature of the given triangle at the surface.

func (*Geo) GetVectorSortOrder

func (m *Geo) GetVectorSortOrder(vecs [][2]float64, reverse bool) ([]float64, []int)

GetVectorSortOrder returns a list of regions sorted by their vector order. This allows us to sort regions "up wind" or "down wind", for example.

func (*Geo) GetVolcanoEruptionChance

func (m *Geo) GetVolcanoEruptionChance() []float64

func (*Geo) GetWindSortOrder

func (m *Geo) GetWindSortOrder() ([]float64, []int)

func (*Geo) IdentifyLandmasses

func (m *Geo) IdentifyLandmasses() []int

IdentifyLandmasses returns a mapping from region to landmass ID. A landmass is a connected number of regions above sealevel.

func (*Geo) Tick

func (m *Geo) Tick()

func (*Geo) TriangulateElevation

func (m *Geo) TriangulateElevation(lat, lon float64, outTri, outRegs []int) float64

type GeoConfig

type GeoConfig struct {
	NumPlates               int     // Number of generated plates
	OceanPlatesFraction     float64 // Fraction of ocean plates
	OceanPlatesAltSelection bool    // Use alternative selection of ocean plates
	NumVolcanoes            int     // Number of generated volcanoes
	NumPoints               int     // Number of generated points / regions
	TectonicFalloff         bool    // Use square falloff to make mountains more peaky and flatlands more flat.
	NormalizeElevation      bool    // Normalize elevation to 0-1 range
	MultiplyNoise           bool    // Multiply noise instead of adding
	Jitter                  float64 // Jitter factor (randomness in point distribution)
}

GeoConfig is a struct that holds all configuration options for the geography / geology / climate generation.

func NewGeoConfig

func NewGeoConfig() *GeoConfig

NewGeoConfig returns a new config for geography / geology / climate generation.

type GeoDisasterChance

type GeoDisasterChance struct {
	Earthquake float64 // 0.0-1.0
	Flood      float64 // 0.0-1.0
	Volcano    float64 // 0.0-1.0
	RockSlide  float64 // 0.0-1.0
}

GeoDisasterChance is the chance of a disaster in a region based on the geographical properties of the region.

func (GeoDisasterChance) GetDisasters

func (c GeoDisasterChance) GetDisasters() []Disaster

type Interpolated

type Interpolated struct {
	NumRegions int
	BaseObject
}

type QuadGeometry

type QuadGeometry struct {
	// contains filtered or unexported fields
}

func NewQuadGeometry

func NewQuadGeometry(mesh *spheremesh.TriangleMesh) *QuadGeometry

type QueueEntry

type QueueEntry struct {
	Index       int     // index of the item in the heap.
	Score       float64 // priority of the item in the queue.
	Origin      int     // origin region / ID
	Destination int     // destination region / ID
}

QueueEntry is a single entry in the priority queue.

type RegProperty

type RegProperty struct {
	ID                  int
	Elevation           float64 // 0.0-1.0
	Steepness           float64 // 0.0-1.0
	Biome               int     // biome of the region
	DistanceToCoast     float64 // graph distance to the nearest coast
	DistanceToMountain  float64 // graph distance to the nearest mountain
	DistanceToRiver     float64 // graph distance to the nearest river
	DistanceToVolcano   float64 // graph distance to the nearest volcano
	DistanceToFaultline float64 // graph distance to the nearest faultline
	Temperature         float64 // in °C
	Rainfall            float64 // in dm
	Danger              GeoDisasterChance
	HasWaterfall        bool // true if the region has a waterfall
	IsValley            bool // true if the region is a valley
	OnIsland            bool // true if the region is on an island
}

type Resources

type Resources struct {
	Metals  []byte // Metal ores
	Gems    []byte // Gemstones
	Stones  []byte // Rocks or minerals
	Various []byte // Other resources
	Wood    []byte // Wood
}

Resources maps regions to natural resources.

type Stats

type Stats struct {
	NumRegions int
	ResMetal   [ResMaxMetals]int
	ResGems    [ResMaxGems]int
	ResStones  [ResMaxStones]int
	ResWood    [ResMaxWoods]int
	TotalArea  float64
	Biomes     map[int]int
	Desert     int
	Forest     int
	RainForest int
	Snow       int
	Swamp      int
	Wetlands   int
}

func (*Stats) Log

func (s *Stats) Log()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL