How do Terrain Properties work?

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

How do Terrain Properties work?

Postby GriffonSpade » Tue Jul 15, 2014 2:17 am

There are a number of terrain properties, including 4 for temperature (tropical, temperate, cold, frozen), 2 for wetness (wet, dry), 2 for plant growth (green, foliage), and one for depth(ocean depth) and elevation (mountainous) each.
How does it choose which terrain best fits the values it generates for a given tile?
Does it pick the terrain with the overall closest values, do the values have to exceed the amounts, ...?

I've been utterly stymied by trying to add in a Taiga terrain(Pine Forests), which should replace Forests in colder regions, however even cloning Forests, and then removing the 'cold' requirement from forest and the 'temperate' from taiga, forests continue to spawn right next to tundra, and even glaciers. I've tried various other combinations as well, all ending with similar, or worse results. Unfortunately, it seems that my problem might lie with the multiple temperature properties (temperate property being applied even in arctic and sub-arctic regions, and the cold property not being applied sufficiently in said regions).

User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Re: How do Terrain Properties work?

Postby GriffonSpade » Tue Dec 23, 2014 7:31 pm

I've now looked at the code for the map generator. While I don't have enough knowledge and experience to edit it, I'm able to get a good idea of what it does with the (quite good) notation. Rather dishearteningly, it appears to have a large amount of hardcoding of settings that should be ruleset controlled, and the generator itself is full of ad hoc solutions to work well for the default terrains, but are horrible for adding new terrains.

I'll start listing my opinions on my progress so far. I'll start with the pre-generation files: temperature_map.c/.h; height_map.c/.h; mapgen_topology.c/.h

1) Elevation: appears to be decided quite intelligently, and nothing seems to be amiss with the elevation itself.

2) Temperature: appears to mostly be decided well, with the exception that there's no randomization to tmap(ptile) in temperature_map.c .

While height is a numerical value and temperature a numerical value converted to an analog, the next few seem to be simple booleans that are checked to either place terrains or prevent placement of terrains.

3) Wetness Condition: Dryness seems to be determined based on two factors:
a. Being in the 'Dry' zone latitudes
b. 35% or less of nearby terrain is water

If either of these are false, the terrain is considered wet.
IsDry is a requirement for placing deserts, and invalidates 'wet' terrain (Swamps, Forests, Jungles). Avoided if at all possible by rivers.

4) Low Terrain: Determined by being just above ShoreLevel, a variable percentage of the land above the shore, but below the mountainous level.
IsLow is a requirement for placing swamps. Preferable for river flows.

5) Terrain Too High: Determined based on too many nearby tiles being elevated.
TerrainTooHigh causes a tile to be generated at a flat terrain

6) Terrain Too Flat: Determined based on all nearby tiles being flat.
TerrainTooFlat causes a tile to be generated as a hill terrain.

7) The River generator seems to be well designed for the most part.

8) The Island Generator makes my head spin when trying to make sense of it, so I won't.
Last edited by GriffonSpade on Thu Jan 01, 2015 11:24 pm, edited 1 time in total.

User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Re: How do Terrain Properties work?

Postby GriffonSpade » Thu Jan 01, 2015 11:15 pm

Previous post has been altered and expanded.
Now for my actual suggestions/wishlist:

GriffonSpade wrote:2) Temperature: appears to mostly be decided well, with the exception that there's no randomization to tmap(ptile) in temperature_map.c .

The (0;-30%) cooler for increasing elevation above sea level and (-15%;15%) more temperate for being near oceans (depending on latitude) are really nice touches, but I wonder if adding a (-20%;20%) random temperature shift might help with terrain variance.

This is the line of code in question.

Code: Select all

      tmap(ptile) =  t * (1.0 + temperate) * (1.0 + height);
In fact, if you set the random to (-100%;100%) on all temperate maps, wouldn't that make the temperature truly random since all temperate maps set the latitude to half maximum?

The values for ColdLevel, TropicLevel, and the DryLevels should be declared in rulesets, rather than hardcoded.

On unwrapped maps, the description seems to say that the pole is always to the top, and equator to the bottom. Shouldn't this be half chance to invert, with poles at the bottom, and equator at the top? Additionally, it should have a half chance to tilt it like a Uranus map: poles and equators on the sides, rather than the top and bottom.

GriffonSpade wrote:3) Wetness Condition: Dryness seems to be determined based on two factors:
a. Being in the 'Dry' zone latitudes
b. 35% or less of nearby terrain is water

If either of these are false, the terrain is considered wet.
IsDry is a requirement for placing deserts, and invalidates 'wet' terrain (Swamps, Forests, Jungles). Avoided if at all possible by rivers.


There should be ruleset/server options to better control the IsDry boolean.
a. The amount of nearby water tiles required should be declared in ruleset.
b. Allow different latitudes to be used for the dry zone. For example, allowing any latitude to be dry (meaning it depends only upon nearby water tiles), or allowing any tile that is above ColdLevel to be IsDry (There's no particular reason why deserts shouldn't be able to form anywhere in the temperate or tropical latitudes; Cold regions would simply be 'tundra' or 'arctic' instead.)

GriffonSpade wrote:


Finally, probably the most important request, is that when generating a land terrain(and maybe water terrain?), it ALWAYS checks for correct temperature types!
First, it should check for MATCHING temperature type (If the temperature type is frozen when it goes to place a mountainous terrain, check for Frozen mountains/hills to place first, not just some random mountain/hill!).
Next, it should check for VALID temperature type (If there are no frozen mountains/hills, check for mountains/hills that are not cold, temperate, or tropical either).
Finally, it should check for ANY temperature type (If there are no frozen or un-temperatured mountains/hills, randomly pick any mountain/hill).

Currently, it skips straight to ANY temperature type for anything but flat land, or if it directly chooses Temperature Type as the determining value.

Wahazar
Elite
Posts: 332
Joined: Mon Jul 02, 2018 1:49 pm

Re: How do Terrain Properties work?

Postby Wahazar » Thu Oct 10, 2019 7:53 pm

I had very similar idea: add Taiga tiles, similar properties as forest (but with different resources), spawning near Tundra.
Not just as eyecandy gadget, but to provide longer climate change chain (less abruptly changes).
I was also confused with these terrain properties and found this topic.
Let me dig it out: where any change/updates meanwhile?
Is it possible to define Taiga properties to ensure its generation in cold biomes, not mixed up with jungle (assuming non-flat temperature model)?
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047

zeko
Posts: 12
Joined: Wed Oct 03, 2018 6:36 pm

Re: How do Terrain Properties work?

Postby zeko » Thu Oct 10, 2019 8:08 pm

Try setting property_cold for the terrain type.