Latest Posts

Topic: Trees and Terrains

Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2015-07-04, 20:28

Good point, I have not mentioned it but I believe that same terrains have "no trees" attribute, this would be preserved. Or even better, we can have another specific biome "no trees". This could be more "systematic" approach.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-07-05, 08:32

thanks kapputtnik, can you also give me the full equation used so i can have an idea of how much tweaking a value will affect the growth??

I think i see where the problem arise. the difference in temperature between the different terains are fairly low (ice is 240 to 260, and desert is 300 to 320), and many palms hhave a low pickiness, so the different temperature won't affect them much.

I have a plan to change the values, according to the following general scheme

                                 temperature          fertility               humidity

summer - - - - - - - - - - - - - - - - - - - - - - - - - - - - high - - - - - - - - - - - - - - - high - - - - - - - - - - - - - - - -- high

greenland - - - - - - - - - - - - - - - - - - - - - - - - - - medium - - - - - - - - - - - - - medium - - - - - - - - - - - - - - medium

wasteland - - - - - - - - - - - - - - - - - - - - - - - - - - medium - - - - - - - - - - - - - high - - - - - - - - - - - - - - - - - low

iceland - - - - - - - - - - - - - - - - - - - - - - - - - - - - low - - - - - - - - - - - - - - - - low - - - - - - - - - - - - - - - - - - high

At least, that referring to the green terrain types.

I intend to make those values different enough that trees of the wrong biome will have a difficult time growing on the wrong biome, while the values within the same biome will be closer. Furthermore, I intend to set for every biome at least one kind of tree perfectly adapted, with ideal values falling in the middle of the biome range, but with high pickyness, and one with values somewhat distant, but lower pickiness. so the specialized tree will grow preferrably in a homogeneous terrain, while the generalistic tree will grow on the boundaries. a generalistic tree will occasionally be found in the wrong biome, but that's intended; it's the occasional palm that can spread to a temperate zone, or the occasional deciduous that will grow in cold climates too. but there won't be palms growing in the middle of the snow.

However, to make it work, I need to know the equation.

And if I can say it, using a program to find values for the trees was a bad idea. not only it was unreliable, but doing it manually would have probably been faster than making a program just for that.

Edited: 2015-07-05, 08:36

Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2440
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2015-07-05, 11:11

king_of_nowhere wrote:

thanks kapputtnik, can you also give me the full equation used so i can have an idea of how much tweaking a value will affect the growth??

Sorry, no. I try'd myself to get this idea, but i am not able to understand the math behind it. At einstein's page (see his Signature) there is a explanation. I think there are more than one equatation necessary to get the resulting values. Einstein could may explain...

And if I can say it, using a program to find values for the trees was a bad idea. not only it was unreliable, but doing it manually would have probably been faster than making a program just for that.

The program was used to get the current values as close to the values we have before the one world merge. This should made growing of trees on older maps as close to the behavior when the map is made. See https://bugs.launchpad.net/widelands/+bug/1348800 for more info.


I like Tibors idea. Do you think old maps could be compatible with this idea?


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-07-05, 17:45

I'd checked both einstein's signature and the bug report, but i have not found the equation i seek. in particular einstein's page has all imaginable equations in treatment of trees, except the one where it tells you how to calculate the actual probability of a tree growing or dieing.

well, I can try to do some blind changing anyway. i willl post the file with the new values and then someone may try to implement them and see it they work


Top Quote
einstein13
Avatar
Joined: 2013-07-28, 23:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2015-07-06, 00:34

king_of_nowhere wrote:

thanks kapputtnik, can you also give me the full equation used so i can have an idea of how much tweaking a value will affect the growth??

  1. this is the thread where all begun
  2. this (point 5.3.) is the general equation used in our model (only grow, not die!).
  3. this this is a function where everything is calculated
  4. this is the current function. A bit changed.

To calculate the probability of growth we need values:

  • Tree: prefered humidity
  • Tree: prefered fertility
  • Tree: prefered temperature
  • Tree: pickness
  • Ground: mean humidity
  • Ground: mean fertility
  • Ground: mean temperature

Mean ground is standard mean value between all 6 connected parts in single point where the tree lives. For one type of soil it will be just the value of the soil. For (example) coast it will be mix of soil and water.

Then we use equations:

sigma_fertility = sigma_humidity = sigma_temperature = 1 - tree_pickness

fertility_distance =
    (tree_fertility - terrain_fertility) / (kFertilityWeight * sigma_fertility)
humidity_distance =
    (tree_humidity-terrain_humidity) / (kHumidityWeight * sigma_humidity)
temperature_dinstace =
    (tree_temperature - terrain_temperature) / (kTemperatureWeight * sigma_temperature)

probability = 
    exp[ (-(fertility_distance)^2) /2]*
    exp[ (-(humidity_distance)^2) /2]*
    exp[ (-(temperature_dinstace)^2) /2]*

That is all what Widelands is calculating right now. I don't know how often it is calculated (the same time period or different for each tree type?). I know only that it is working, but not perfectly.

Also it is good to notice that (basic power equation):

exp(x)*exp(y) = exp(x+y)

And that is why the function is looking a bit strange.

Edited: 2015-07-07, 11:10

einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-07-06, 02:58

i tried to manually tweak the values in those datsheets. i also indicated for each ttree where it is supposed to grow, anf for the terrains if they are supposed to grow anything. someoe could try to implement those values in the code and see if they work.

unfortunately, i have no idea how to upload a file, so sommeone also has to explain me that.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2440
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2015-07-06, 06:56

Thanks einstein for the explanation.

king_of_nowhere wrote:

unfortunately, i have no idea how to upload a file, so sommeone also has to explain me that.

There is currently no possibility to upload files to widelands.org. So you could make an account on launchpad (where the bugs are reported) or use another file hoster.

But why do you not try your new values for your self? The files where the values are set are simple text files. You could find them in your widelands data folder:

  1. For terrains: /world/terrains/init.lua
  2. For the trees: /world/immovables/trees/TREENAME/init.lua (each tree has his own folder and his own init.lua file)

Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-07-06, 20:53

kaputtnik wrote:

Thanks einstein for the explanation.

king_of_nowhere wrote:

unfortunately, i have no idea how to upload a file, so sommeone also has to explain me that.

There is currently no possibility to upload files to widelands.org. So you could make an account on launchpad (where the bugs are reported) or use another file hoster.

But why do you not try your new values for your self? The files where the values are set are simple text files. You could find them in your widelands data folder:

  1. For terrains: /world/terrains/init.lua
  2. For the trees: /world/immovables/trees/TREENAME/init.lua (each tree has his own folder and his own init.lua file)

thanks, i will. just two questions: i openend the init.lua file and i see it's quite messy; I would have to rewrite manually every single value, one by one. for 3 values for 62 terrains it is quite a lot. is there any faster way to do it? and if i go to a new line for every terrain type (i mean, just pressing enter) to make it more readable, wiill the file stil work?


Top Quote
einstein13
Avatar
Joined: 2013-07-28, 23:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2015-07-06, 21:06

From my point of knowledge lua scripting language: you can make any spaces face-smile.png

https://en.wikibooks.org/wiki/Lua_Programming/whitespace

And I don't know any good way to change all values at once. Sorry face-confused.png


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2440
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2015-07-06, 22:07

king_of_nowhere wrote:

thanks, i will. just two questions: i openend the init.lua file and i see it's quite messy;

Normally its a well structured file... if you change some of the values please use a simple text editor (nothing like "Word", "wordpad" or "Libre/Open office")

I would have to rewrite manually every single value, one by one. for 3 values for 62 terrains it is quite a lot.

Did someone say that it is an easy job? face-wink.png

is there any faster way to do it?

No, as i know. It's just work.... With a good editor or with regular expressions its maybe easier. But it's a lot of work in anyway... sorry. In the beginning you see the lot of work, but if you've begun, with every changed value the less values you have to change face-smile.png


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote