Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Science Report: Temperature Parameters in Worldgen  (Read 5767 times)

ArrowThunder

  • Bay Watcher
    • View Profile
Science Report: Temperature Parameters in Worldgen
« on: December 02, 2017, 10:47:26 pm »

The Backstory
Recently, I have been trying to tweak the advanced worldgen parameters to get a somewhat catered game experience.
A pet peeve of mine with smaller worlds is the options for poles in worldgen. I'm not a fan of how there isn't really any option that respects the size of the continent. What I'd really love a range of [random latitude] to [random latitude] in addition to the [north pole] to [equator], [equator] to [south pole], or [north pole] to [north pole] options we have now, but it is what it is. So instead, I wanted to go with no poles, use the 2x2 temperature mesh with temperature extremes, and chalk up the wild temperatures as just another way the world was magical. However, I was having trouble picking temperature minimums and maximums, and since I couldn't find anyone else who had done anything like this, I decided to do it myself.

Preliminary Findings

My preliminary research told me a few things:
  • The default min-max is 25-75, which on a non-polar map seemed to only make temperate and warm climates.
  • Temperature Min/Max of 0 - 100 (with no poles) did not result in freezing temperatures, but did result in scorching ones.
  • The data in the temperature maps output by legends is stored in the pixels of a greyscale .bmp
  • The greyscale pixel values have fixed temperature representations. This is important because it means that if one map has a pixel with an RGB of 170 ea. and another map has a pixel with that same RGB value, they represent the same temperature. The alternative would be that white & black represented the minimum and maximum temperatures for one world, which doesn't tell us much.
  • The range value (HSV, 0 = white, 100 = full color (in this case, black)) for non-polar worlds with Min/Max of 0-100 was about 24ish to 72ish. This told me that the range of recordable values was significantly wider than from 0-100.

The Experiment
My goal with this experiment was to understand the relationships between the climates reported in embark, the parameter values selected (for temp min and max), and the legends temperature map output value.

To do this, I created worlds with advanced worldgen, each with identical parameters, save for a few things. I tried to minimize world generation time and make the generation times consistent. To summarize, the worlds:
  • are pocket worlds (17x17)
  • have no megabeasts, monsters, the like
  • have minimum temperature equal to maximum temperature
  • have no temperature variance
  • have no poles
  • have world names equal to their temperature preset
  • use a painted preset for terrain, with oceans on all sides, a medium elevation shoreline, and some mountain regions (so dwarves can spawn)
  • have 5 civilizations
  • have a history length of 2 years

Spoiler: example parameters (click to show/hide)

I made 41 one of them: temperature values range from -50 to 150, spaced 5 apart.

The climate data was collected via embarking, the value and rgb data from exported temperature maps via legends.
For all cases, if multiple temperatures were available, the highest one available was used to collect data from (for all data). The reason for this will be explained in the section labeled "Additional Observations & Conclusions".

The Data
Spoiler (click to show/hide)

Additional Observations & Conclusion

The fact that my trials perfectly encompassed the entire grayscale is due to my preliminary research. In fact, when choosing the values I actually thought I'd be going above and below the range where the grayscale maps could provide insight into the temperature (colder than 0v, 0rgb and hotter than 100v, 255rgb). For those curious, I did create a few extra worlds above and below the temperatures (and made some adventurers to die in them). There, I was able to confirm that yes, temperature presets above 150 still result in 100v and 255rgb, while presets below -50 still result in 0v and 0rgb.

It seems to me that generated temperatures are subtracted from, rather than added to. Allow me to explain.
For one, it seems the elevation from mountains shave off, at their peak, about 8 RGB or so, which is just a hair more than a -5 change in temperature parameter. However, some worlds, especially hotter ones, go even further. While their highest temperature is perfectly in line with a linear trend, they vary drastically. It'll be easiest to show you visually. The numbers labeling the images indicate the minimum and maximum parameters the world shown was generated at.

Most of the data is much like these images below. Note the center (where the mountains are) are slightly darker than the surrounding area, but there is no difference between low-lying (elevation 150) and oceanic (elevation 1) temperatures.
Spoiler (click to show/hide)

There are some minor anomalies starting in as early as 70, 75 and 85, but nothing compared to what happens later.
Spoiler (click to show/hide)

The crazier anomalies start where it gets scorching
Spoiler (click to show/hide)

They get more pronounced as it gets hotter.
Spoiler: the real anomalies (click to show/hide)

That said, some of the highest temps have little or no anomalies at all!

While I don't have an explanation for the anomalies (maybe something to do with the orthographic rain projections?), I can say with confidence that they are the reason why I recorded only the hottest temperatures from each world.

I hope this helps provide some insight into how you might want to set your temperature parameters in the future. I've uploaded all the files I used to perform the experiment, including the auto-it scripts, here: http://dffd.bay12games.com/file.php?id=13267. I highly encourage those interested to take a gander at the full collection of maps there, and play around with the test worlds.

Thank you for reading, and feel free to ask any questions and/or make comments about my process.
Logged

Jimmy

  • Bay Watcher
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #1 on: December 03, 2017, 02:37:53 am »

Nice work! Based on your research, would you recommend a "sweet spot" range for world gen values that result in large areas of the map that freeze in winter but remain unfrozen in other months?
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #2 on: December 03, 2017, 03:31:31 am »

Yes, temperatures for a given PSV value are decreased with rising elevation. I haven't gotten a real formula out of it, though. Similarly, temperatures are adjusted from the PSV values based on latitude (provided you have poles in the world, which you don't). Again, I haven't been able to get a real formula out of it (although there seems to actually be two formulae: one for small worlds and another for large ones).
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #3 on: December 03, 2017, 03:47:05 am »

Hm, neat!

The min-max of -50 to 150 of exported grayscale maps or specificially quantifying mountain lowering is definitely new to me. Haven't paid much attention to those things, in part because it is difficult to line them up with what I'm curious about - I prefer embarking instead. Still, the anomalies do somewhat fit in with not getting wholly tropical worlds even with over 85 min temperature.


Worth of note: iirc biome is dependent on the summer temperature, which is around +20 over the ...average, maybe? It's been a long time since I read that research, so don't call me on this. Anyway, this is why you can get freezing grasslands and such.



Also worth nothing: Like elevation, rainfall also cools down - hot areas in particular, as those have more rainwater to boil. You can see this in the differences between 75 and 100 rainfall forests with 85+ temperature. Interestingly, the worlds seem to generate wholly the same within even so grand rainfall range as long as the biome doesn't change, something that often isn't true for options like volcanism, savagery or elevation. I suspect part of the disrepencies was tied to your 0-100 randomized rainfall cooling hotness in addition to the orographic precipitation.

(Which ties well in with them showing up as hot areas started showing up.)


The 85 temperature also makes more sense now, given the 67% grayscale value. This makes it fit in better with the drainage and rainfall cutoffs biome generation uses.


PS: Some notes regarding your pre-set values: Consider them like a really fine mesh size. This means your lack of seeds and elevation variances are both going to alter the resultant geography a bit. Also, you could have just set volcanism to min-max 50 and ditched it's map, since you never varied it.

@Jimmy: I'd say that is somewhere in warmer cold ranges at a guess, though haven't done research (and of course this will depend on the areas' elevation). My attention has been more towards "barely all-year freezing tundra/glacier", which is roughly about -20 on just before the boundary of temperate and tropical in 129 tall NS poles world.
« Last Edit: December 03, 2017, 03:50:46 am by Fleeting Frames »
Logged

ArrowThunder

  • Bay Watcher
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #4 on: December 03, 2017, 03:41:51 pm »

Nice work! Based on your research, would you recommend a "sweet spot" range for world gen values that result in large areas of the map that freeze in winter but remain unfrozen in other months?

Absolutely! A great follow up study would attempt to more clearly define the boundaries between climates (which is limited with my study thanks to the 5 step increments I took). However, the groundwork for those definitions is done with this study.

Looking at the wiki page on climates, temperate biomes are the ones that melt in the summer and freeze in the winter. So if you have a min/max & mesh combination that can emphasize parameters 15-45 (without elevation, or poles), then you'll be mostly temperate. If you don't mind excluding other possibilities, limiting the min/max range to 20-45 (without poles) should ensure that only temperate climates are created. If you wanted to have, say, warm climates as well, but half as likely, you could define a temperature range of 20-70 and mesh weights of something like [4:4:3:2:2]. But the true power of this research gives you even more control than that!

I think one of the more interesting things about the results is just how wide the temperature range for some climates are vs. others. What it tells us is something we already kinda knew: that there are temperate biomes that are much warmer than other temperate biomes. What this means is that if you don't want your water frozen in any month *except* the winter months, then you should aim for the higher end of the temperate spectrum, probably parameters between 35-45.

If you're including poles, things get tricky. That said, generating a 50-50 temp world with poles and loading the temp map should provide the insight needed to understand how the poles are going to skew the results your temperature maps generate (and if anyone does so, I encourage them to share their results here!).

TL;DR: my best guess for the range where water only freezes in winter (but not the other months) would be when the internal temperature parameters are between around 35 and 45, although I didn't collect any data from after embarking, so I'm not at all sure. Careful though, achieving that consistently means looking at poles and elevation to tune your min/max and mesh settings. Good luck!

Hm, neat!

The min-max of -50 to 150 of exported grayscale maps or specificially quantifying mountain lowering is definitely new to me. Haven't paid much attention to those things, in part because it is difficult to line them up with what I'm curious about - I prefer embarking instead. Still, the anomalies do somewhat fit in with not getting wholly tropical worlds even with over 85 min temperature.


Worth of note: iirc biome is dependent on the summer temperature, which is around +20 over the ...average, maybe? It's been a long time since I read that research, so don't call me on this. Anyway, this is why you can get freezing grasslands and such.

Yeah, I didn't load any embarks on the worlds, and there's no DFHack for 44.02 yet, so I didn't even try taking data in degrees urist. A great follow-up study would be to generate similar worlds but with easy/zombie dwarves via raw tweaks (immortal, don't need anything), so you could easily load up embarks in them and actually look at temperatures over an entire year in-game.

Quote
Also worth nothing: Like elevation, rainfall also cools down - hot areas in particular, as those have more rainwater to boil. You can see this in the differences between 75 and 100 rainfall forests with 85+ temperature. Interestingly, the worlds seem to generate wholly the same within even so grand rainfall range as long as the biome doesn't change, something that often isn't true for options like volcanism, savagery or elevation. I suspect part of the disrepencies was tied to your 0-100 randomized rainfall cooling hotness in addition to the orographic precipitation.

(Which ties well in with them showing up as hot areas started showing up.)

Yeah, I suspected it had to do with rainfall. It'd be interesting to do more research on the topic!

Quote
The 85 temperature also makes more sense now, given the 67% grayscale value. This makes it fit in better with the drainage and rainfall cutoffs biome generation uses.

I think the grayscale values do a great job of showing just how hot Toady thought things would be, like "okay anything past here is just not worth recording". It sounds to me like you're already familiar with 85 as a sort of cutoff for consistency. If you know of any more research that has been done past that, or on the drainage and rainfall cutoffs you're talking about, I'd love to see it!

Quote
PS: Some notes regarding your pre-set values: Consider them like a really fine mesh size. This means your lack of seeds and elevation variances are both going to alter the resultant geography a bit. Also, you could have just set volcanism to min-max 50 and ditched it's map, since you never varied it.

Oh yeah, the way I did things is definitely not the most consistent. I did the volcanism the way I did because I chose to fix volcanism on a whim while I was in the world painter gui xD. But there was a method to my madness. Because it's a simulation, I sort of took the liberty of knowing that the parameters were indeed linearly fixed to the outputs (which would be horrible practice in any real world science). Instead of trying to 100% silence the noise, I thought more knowledge might be gleaned from the study if I actually left noise from rain and elevation in. The results were kinda perfect in that regard: just enough consistency to establish that the theoretical framework was sound and provide a trendline (the hottest temperatures are consistent), while also allowing us to see temperature changes elevation variations and also the anomalies w/ drainage and rainfall. Now, enough is known that temperature could be controlled and other causes could be explored for the 85+ distortion effect.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #5 on: December 03, 2017, 04:10:43 pm »

Ragundo has disassembled the DF code for how biomes are determined, and I'm not aware of that logic having failed at any time. I've essentially translated the C(++) code into Lua and used it in a number of my scripts, e.g. the Biomemanipulator (visible on the first page of the utiliites and 3:rd parties sub forum as the time of this writing).
For a world without poles the tropicality is determined by whether the temperature is above 75 or 85 degrees, with below 75 = temperate, above 85 = tropical, and the range in between being the "maybe" zone which comes into effect only in worlds with a Y dimension of 129 or 257. Biomes in the "maybe" zone have per biome criteria for whether they're going to be tropical or temperate (both for worlds with pole(s) and worlds without). It can be noted that Ragundo's code is based on the data stored for the world tile, i.e. it does not make temperature adjustments for altitude or latitude: that's done by DF during world gen. A further note is that the code makes use of Vegetation, but as far as I've seen this value is identical to rainfall after world gen and is zero during world gen. However, I don't think I've taken a closer look at ocean, glacier, lakes or mountains (where the latter actually has vegetation, although it's grass only).
A result of latitude based biomes for worlds with poles is that it's possible to get whacky temperatures in them, as temperature only comes into play in the "maybe" zone, apart from the low end of the temperature range (e.g. glacier and tundra)
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #6 on: December 03, 2017, 05:35:50 pm »

For a single year of test, quickest is just to prepare carefully, ensure embark is quiet/peaceful and set popcap to 0. Once embarked, plop down a food stockpile and wait.


Tbh you can even do a macro to quickly designate obsidian walls around fort with liquids, plant piles and set up food gathering zones to feed the fort as well as manager order to give booze.


Yeah, there's been previous studies, though not exactly the same - don't seem to have 'em in browser history handy, alas, so gotta search. I think the 85 bit may have been in one of the worldgen threads, don't recall about the variance bit. The reason I mentioned it fitting in was that the 67% fits rather well into forests and swamps needing at least 66 rainfall, and sand desert/marsh/swamp needing less than 33 drainage, and badlands over 66. (Speaking of this chart ofc.)

ArrowThunder

  • Bay Watcher
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #7 on: December 04, 2017, 05:18:29 am »

For a world without poles the tropicality is determined by whether the temperature is above 75 or 85 degrees, with below 75 = temperate, above 85 = tropical, and the range in between being the "maybe" zone which comes into effect only in worlds with a Y dimension of 129 or 257. Biomes in the "maybe" zone have per biome criteria for whether they're going to be tropical or temperate (both for worlds with pole(s) and worlds without).

Very interesting! Looking closely though, I think it's more per region, not per world. However, the distinction of 85 being tropical is very useful information, and it got me thinking...

Yeah, there's been previous studies, though not exactly the same - don't seem to have 'em in browser history handy, alas, so gotta search. I think the 85 bit may have been in one of the worldgen threads, don't recall about the variance bit. The reason I mentioned it fitting in was that the 67% fits rather well into forests and swamps needing at least 66 rainfall, and sand desert/marsh/swamp needing less than 33 drainage, and badlands over 66. (Speaking of this chart ofc.)

Wow, that chart is so useful!

With both of your comments, I took a look back in some of the key anomaly cases and found something interesting: world 125 (with the super consistently scorching temperatures) is a wasteland, with no rainfall (as per the chart). But most notably: world 135 (with the wildly and surprisingly cold temperatures) is covered in vegetation and rainforests. As soon as I saw that, it struck me: vegetation on a large scale (like in rainforests) can have an unbelievable impact on temperatures in real life. The vegetation is there because there's lots of rain and there's plenty of sun.

But what is perhaps even more interesting is while that may be the way that Toady was thinking (justifiably), it seems to have been implemented peculiarly, likely due to the ordering of world generation. IIRC, vegetation comes after rainfall & temperature and is influenced by both. So instead of calculating the temperature control based on vegetation, the world generator checks if it would be tropical, and if so, offsets for rainfall before calculating the final biome (and tropicality). This would explain why parts of world 135 are temperate, and why areas in the ocean and mountains aren't scorching. This offset likely occurs in worldgen and would therefore be invisible to the biommanipulator code.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Science Report: Temperature Parameters in Worldgen
« Reply #8 on: December 04, 2017, 05:56:41 am »

No, the biome calculations are per world tile. World tiles are then collected into regions based on being of the same world region type and being perpendicularly adjacent to another member of the region. Some region types are single biome (e.g. Glacier and Mountain), while others are multiple biome (like Jungle and Desert). Grassland/Hills share the same set of biomes, and differ only in Drainage.

And yes, the chart is very handy, but not the complete truth (it's correct, but doesn't have all the details).

Ragundo's code work both on PSVs and within generated worlds (it needs to be adjusted for the different interpretation of Elevation, as well as the absence of Vegetation and Salinity) as far as I've seen. I think I've said it above, but Vegetation = Rainfall after world gen, as far as I've seen. Also note that I'm talking about the fixed world tile temperature element here, not the effective one that's applied to the tile and varies at least with seasons (assuming there are seasons).

Logged