temperature affected by latitude, non-linearly
This commit is contained in:
@@ -23,4 +23,7 @@ Using the heightmap generator from here: https://github.com/TangentFoxy/heightma
|
||||
- [ ] Do all terrain generation within a radius check so unnecessary work isn't done and discarded.
|
||||
- [ ] Terrain generation steps should happen within a single loop wherever possible?
|
||||
|
||||
## Reference
|
||||
- Out of 52 seeds randomly tested, the current code creates a temperature range between -80.64 and 33.78 C.
|
||||
|
||||
(Tasks/Issues are stored in the ReadMe instead of using a webUI issue tracker due to how using such a tracker negatively influences portability of the project.)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
local running_average = {
|
||||
trackers = {}
|
||||
}
|
||||
|
||||
local trackers = running_average.trackers
|
||||
|
||||
running_average.track = function(name, value)
|
||||
if not trackers[name] then
|
||||
trackers[name] = { running_total = 0, count = 0, }
|
||||
end
|
||||
local track = trackers[name]
|
||||
|
||||
track.running_total = track.running_total + value
|
||||
track.count = track.count + 1
|
||||
|
||||
return track.running_total / track.count
|
||||
end
|
||||
|
||||
running_average.average = function(name)
|
||||
return trackers[name] and trackers[name].running_total / trackers[name].count
|
||||
end
|
||||
|
||||
running_average.count = function(name)
|
||||
return trackers[name] and trackers[name].count
|
||||
end
|
||||
|
||||
return running_average
|
||||
+3
-1
@@ -3,6 +3,7 @@ math.randomseed(os.time())
|
||||
local map_generator = require "map_nextgen"
|
||||
local lovebird = require "lib.lovebird"
|
||||
local lume = require "lib.lume"
|
||||
local running_average = require "lib.running_average"
|
||||
local simplex_map = require "lib.simplex_map"
|
||||
|
||||
local map
|
||||
@@ -11,7 +12,8 @@ love.load = function()
|
||||
map = map_generator.generate()
|
||||
map.temperature.min = simplex_map.min(map.temperature)
|
||||
map.temperature.max = simplex_map.max(map.temperature)
|
||||
print("Temperature Range", map.temperature.min, map.temperature.max)
|
||||
print("Min Temperature", map.temperature.min, "Average", running_average.track("minT", map.temperature.min))
|
||||
print("Max Temperature", map.temperature.max, "Average", running_average.track("maxT", map.temperature.max))
|
||||
|
||||
-- if true then return end
|
||||
|
||||
|
||||
@@ -102,6 +102,11 @@ local generate = function()
|
||||
else
|
||||
temperature = temperature + altitude / 1000 -- -1 C / km (deep water adjustment)
|
||||
end
|
||||
-- modify temperature by latitude
|
||||
local polar_distance = math.abs(y - (map.size / 2))^1.1 -- experimenting with slight non-linearity
|
||||
local max_temperature_delta = 40
|
||||
temperature = temperature - (polar_distance / map.size * 2 * max_temperature_delta)
|
||||
-- 'save' temperature changes
|
||||
map.temperature[x][y] = temperature
|
||||
|
||||
-- choose biome
|
||||
|
||||
Reference in New Issue
Block a user