Latest Posts

Topic: Do trees grow on mountains?

einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2015-03-08, 19:40

General working of the model is quite simple face-smile.png

Ok, not as simple as single line, but It is quite natural: using gaussian function: Wiki link, but 3-dimensional form of it.

Standard gauss => y(x) = exp (- (x-x0)^2/(2 sigma))

  • x0 - peak, best value
  • sigma - variable connected to standard deviation (I'm not sure if here is standard deviation or variance)

Short introduction:

Every type of terrain has 3 contstants we are interested in:

  • humidity (0 .. 1)
  • fertility (0 .. 1)
  • temperature (in Kelvin degrees)

Every tree has preferable conditions (humidity, fertility, temperature) and "pickness" value (0 .. 1). This value describe how the tree likes another type of terrain values. If the pickness is 0 - it likes ANY of terrain, if 1- only the prefferable conditions.

How it works?

  1. Get all the 6 tripples of values of terrain around the node (water, lava and ice is also counted here!)
  2. Then get mean value (mean=(val1+val2+val3+val4+val5+val6)/6)
  3. After that count all the "c" value for every of 3 variables (known also as sigma)
  4. Calculate gaussian function for every sigma, x0 (best fit for the tree) and x (terrain afinity)- that produces 3 possibilities of growing
  5. Multply 3 values from point 4- that produces 1 possibility of growing
  6. Points 4 & 5 are in one code line (C++ code)

If the possibility is high, the tree will grow fast, if low- it will grow slowly or die soon. For every terrain type and every tree we have another values.

Solution for editors

The easiest way is to build a table where all types of trees and types of terrain are included. It takes lots of time to test the terrain types and the trees.

I was trying to do that with older model, but after few hours of testing (during few days) I've realized that the values will change. Hopefully now it will be fixed for some time and I can retry the model. But still it takes hours of testing. So I NEED HELP WITH THAT. If you are interested in it, just send me a private message.

After having a table with values, it should be very easy to design maps. If we need well- growing trees, just plant the correct type of tree. If not- plant any other face-smile.png

Links

Launchpad thread for terrain afinity

http://bazaar.launchpad.net/~widelands-dev/widelands/terrain_affinity/view/head:/src/logic/terrain_affinity.cc -> First implementation of terrain affinity for trees

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/logic/terrain_affinity.cc -> current (dev) implementation

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/world/terrains/init.lua -> terrain values of fertility, humidity, temperature

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/files/head:/world/immovables/trees/ ->Trees variables: go to the tree and init.lua file to get values

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/world/immovables/trees/spruce/init.lua ->For example spruce

Basic idea for terrain- tree table

First idea for tree growing model

EDIT: sorry, strange behaviour of links here

Edited: 2015-03-08, 19:44

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

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2015-03-09, 07:50

einstein13 wrote:

Solution for editors

After having a table with values, it should be very easy to design maps. If we need well- growing trees, just plant the correct type of tree. If not- plant any other face-smile.png

And the correct type of tree depends on the terrain type furthermore, right?

How this could be implemented within the editor in an easy way for mapmakers? Normally you edit a map by placing the terrains on the map first and then place immovables (like trees). How does the mapmaker know which tree he should place? And if he knows which terrains are treefriendly to specific trees, he have to search for the specific trees in the menu.

I think the main problem is a relict of the 4 world behavior and the new terrain affinity from one world trys to keep the old differences between the 4 worlds. f.e. palms should only grow on desert terrains and the mushrom trees only on blackland terrains. But i am unsure about if this behavior is wanted by the mapmakers, because they have a lot more possibilitys to place terrains with the one world merge. Prior they could use 12 to 16 terrains, with one world they could use 61 terrains. The ability to use of lot more terrains type in one area of the map makes the old differences between the worlds senseless.

Correct me if i am wrong face-smile.png


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

Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2015-03-09, 15:28

kaputtnik wrote:

And the correct type of tree depends on the terrain type furthermore, right?

All the trees will grow, but not every as good as "the best fit".

How this could be implemented within the editor in an easy way for mapmakers?

Within the editor- I don't know. For me it is a basic knowledge like "2+2=4", but you have to remember more than few results (you need about 20 different results for trees and terrains?)

How does the mapmaker know which tree he should place?

I told you- the best is testing all the terrain types and trees, make a simple table and read it when designing.

And if he knows which terrains are treefriendly to specific trees, he have to search for the specific trees in the menu.

That is the result of my simple idea.

But i am unsure about if this behavior is wanted by the mapmakers,

For me- a mapmaker- it is THE MOST wanted behavior. I was playing on dev version where there were no differences for trees and terrains. It was HORRIBLE.

The ability to use of lot more terrains type in one area of the map makes the old differences between the worlds senseless.

Imagine that your forester will plant a palm on an ice. What happened in real life? Will the palm grow? I don't believe so. For me your idea of making no differences for trees on terrain types is senseless. Sorry :). We need a model that will allow all the trees grow everywhere, but not in the same behaviour.


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

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2015-03-09, 18:21

einstein13 wrote:

For me- a mapmaker- it is THE MOST wanted behavior. I was playing on dev version where there were no differences for trees and terrains. It was HORRIBLE.

[...]

Imagine that your forester will plant a palm on an ice. What happened in real life? Will the palm grow? I don't believe so. For me your idea of making no differences for trees on terrain types is senseless. Sorry :).

We may misunderstoud. I agree that growing trees on some terrains is senseless, or unlikely. What i meant was that the differences between the old worlds is senseless. Why should palm trees do grow good only on beach or desert terrains? Because this behavior fits our image of a real world. So Palm trees are a bad example, imagine instead the trees of blackland... why shouldn't they grow good on beach and desert or on the greenland terrains?

We need a model that will allow all the trees grow everywhere, but not in the same behaviour.

If we really want this, why don't we use a kind of ressource for the model instead of depending it on the terrain? Placing a "conifere" ressource on the map let grow coniferes good. Placing a mix of "conifere" and "mushroom" resources would let grow those trees good. Such kind "ressources" could maybe set on the map by placing the trees the mapmaker choose. But this behavior will make problems if no tree resources are set and a forester tries to plant trees face-sad.png

Just to explain my point of view, look at this example:

terrain_mix

Isn't it nice? I think so. To get this i used this terrains

  • from summer:
    • Steppe
    • barren steppe
    • mountain meadow
  • from desert:
    • desert
    • mountain meadow
    • high mountain meadow
    • meadow

Do the placed palms will do grow good? I don't know...


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

Top Quote
king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-03-09, 21:19

while i do appreciate the amount of effort you dev guys are putting in simply making the map look prettier, I do believe a player should be able to place a forester without solving matrix systems before. and a casual gamer should be able to make his own map and have trees growing on it without having to know about said matrix calculations.

In the end, it shuld be evident if forestercan plant trees to grow anywhere or not. the kind of tree does not concern the player, but the possibility does. for example, I've seen that even in four castles, while trees can grow on mountains, there are very few "adult" ones, so I suppose they still have good chances to die. And a player should be able to know that. So, whatever else you will do, I think the help text of the forester shoud specify "trees will grow with more difficulty on mountains and desert" or something like that. You may think it's intuitive, but games often employ acceptable breaks from reality.


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2015-03-09, 22:17

king_of_nowhere wrote: (...)

Have you read about my idea of "help-table"? If so, why did you mention about "matrix calculations"? And what are the matrix calculations here? I really don't know anything about that. face-confused.png

Is it too complicated to read simple table and see if there is "green" or "red" box for tree-terrain match? Or maybe you think it is too complicated for anyone?

kaputtnik wrote: imagine instead the trees of blackland... why shouldn't they grow good on beach and desert or on the greenland terrains?

I don't think that mushrooms or umbrellas should grow on greenland soils. Why? It is simple: wastelands are ashes, very fertile, but very dry. Also very hot. Greenland is middle-temperature, fertile (ok, this is match), but plenty of water. That was the main idea of wasteland and greenland. To be specific, with older model, before tweaking, general idea:

  • Winterland: very cold, not so fertile, lots of water (generally ice)
  • Greenland: middle-temperature, fertile and full of water (but not swamps :P)
  • Desert: hot, not so fertile (salt in the soil?), dry one
  • Wasteland: very hot (volcanos!), very fertile and very dry one

The trees shouldn't grow on mixtures of terrains, except some species. You know that there is number of species growing on taiga and on common middle-temperature parts of the world (wiki: flora, taiga)

Ok, we can plant some palms on greenland, but not winterland! Not all palms, because some of them need salt (not very fertile) to grow :). Wasteland is something mysterious for us- you can imagine all the things. But if you go to the origin of the land: Settlers II, you will see only volcanos, ashes and nothing interesting.

Of course you can disagree with the current model- I will not die for that face-wink.png But if so- propose your own values for your idea. You have links for the place of code above. Go, change, test and propose to the correct people face-smile.png If it will be ok, I will not cry face-grin.png Instead, I will prepare some other tests to help other people understand the behaviour.


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
Topic Opener
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-03-09, 22:38

I must have missed the help box. I have read some more technical explanations about trees growth models, and they involved matrixes. Yeah, if there is an help table then it becomes ok. I only worry that it is user-friendly. As for the rest, I think the concept is pretty good.


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2015-03-09, 22:44

king_of_nowhere wrote:

I must have missed the help box. I have read some more technical explanations about trees growth models, and they involved matrixes.

Probably in some parts there were matrixes in theory, but it was simplied to basic equations.

I only worry that it is user-friendly.

http://student.agh.edu.pl/~rak/widelands/files/TreesModel-explanation/Data01.pdf

Color - basic knowledge if it is a good (green) or bad (red) soil for the tree Number- % of how many trees survived on the land for 2 hours.

But the file was for older model. Now it needs re-testing and re-writing.

Is it user-friendly? One page?


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

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2015-03-09, 23:01

einstein13, please do not anger. I understand your point and the reason for the one world merge. But i feel misunderstoud. Maybe i am the only one who wants other benefits from the one world merge as "only" have the abililty to make maps with different vegetation zones.


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

Top Quote
king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2015-03-10, 03:42

http://student.agh.edu.pl/~rak/widelands/files/TreesModel-explanation/Data01.pdf

Color - basic knowledge if it is a good (green) or bad (red) soil for the tree Number- % of how many trees survived on the land for 2 hours.

But the file was for older model. Now it needs re-testing and re-writing.

Is it user-friendly? One page?

Sorry, I know I will sound terribly nitpicky, or that that I'm looking for excuses to bash, but NO, that is not user-firendly in the slightest.

For the following reasons.

1) that page is not easy to find. one looks for guides, he will look at an in-game help, then he will look in the site. that page is not there. to find it, one has to go to a link in your signature, which is not something most people would do.

2) very few people know the names of plants and terrains. Larch, spruce, alder, aspen? How do I know which tree is which? I grew up in a city and I didn't study botanics. To me a tree is a tree, I coudn't tell the difference live, I certainly cannot tell the difference from a few pixels. Meadow 1, meadow 2, mountain meadow? One who never used the map editor doesn't even know that the terrain types have names. Most important, one does not easily recognize them. I did use the map editor, but I am not able to tell the different kinds of meadows. the only difference is a slight shade of color, or maybe a few colored dots in the middle of the green. Worse, in most maps the terrains are mixed, and one cannot reasily tell which kind of meadow that is. I never realized that the mountains of desert tournament were a different color than the ones of four castles. If they were attached to each other I would see they were different shades of colors, but I'd have no idea what they meant.

3) that page contains the wrong information. Yes, I suppose it is very helpful for someone using the map editor, but one playing doesn't care which tree grows where, because it's the forester who chooses the trees to plant. A player wants to know if some tree can be planted at all. So, as long as the forester plants the best kind of tree, I only need to know if there is at least one tree that can grow there.

That sheet does contain the information, after a fashion. I can see if there is at least one green dot for every line. I consider all mountain types and all meadow types as one because I cannot tell each other, but they are similar enough within a given ambientation. I see that on every mountain kind there are trees that can grow on them, except for the winter mountains, and those are easy to tell because of the snow. That makes me think the sheet may not be up to date or it may be giving the wrong informations. Because it states that on desert mountains date palms should grow pretty well, but my experience with desert tournament wass that not a single tree growed, not even to stage 2. So either that was changed, or the forester wasn't planting date palms for some reason, or the sheet only counts the number of trees that die but does not take into account the probability of growing.

I'm really sorry about that. I hate to complain about work that people has done for free, and I hate to ask people to do more work. However, I feel that you failed to realize what are the needs of someone approaching the games with a more casual attitude, and therefore I felt my post is needed.

Edited: 2015-03-10, 03:43

Top Quote