Topic: Help with the calculations and strategies

einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-02-11, 11:50 UTC+1.0

So far I've made two small calculations for Widelands. I don't know much about programming but I would like to help that way: making some calculations, develop a problem and return simple equations or numbers.

My previous work is on the site:

http://student.agh.edu.pl/~rak/widelands/

If you have any suggestions or questions, just ask.

einstein13

Edited: 2014-02-11, 11:53 UTC+1.0

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

Top Quote
Tibor

Joined: 2009-03-23, 23:24 UTC+1.0
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-02-11, 21:58 UTC+1.0

einstein13,

I am interested in practical result of your calculation. F.e. - what is best proportion of rangers vs lumberjacks?

What size of area can one lumberjack or one ranger "cover" - I mean f.e. if there is empty space of 50x50 - how many lumberjack and rangers should be placed there and what maximum production (trunks per period) they can achieve.

This is still too theoretic, but practical question would look like:

If I want to achieve production of 40 trunks - how many rangers (we are talking about sustainable production, not cutting existing forests) and lumberjacks are needed in the game?

Then how much the terrain type matters?

My experiences says that one ranger can produce enough forests for 4 lumberjacs, does it match your calculations?

Of course, the AI would be too stupid to pick right place for lumberjacs and rangers (considering terrain and buildings in vicinity) but still some target numbers based on target productions must be defined within AI.


Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-02-12, 00:26 UTC+1.0

Tibor wrote: (...) what is best proportion of rangers vs lumberjacks?

From my calculations you can see that the best proportion is 1 lumberjack per 1 forester. But I will do some experiments. Also I will do some about different terrain. But it will last more time than 1 week... face-confused.png (I have to learn for studies!)

https://wl.widelands.org/encyclopedia/empire/buildings/foresters_house/ https://wl.widelands.org/encyclopedia/empire/buildings/lumberjacks_house/

What size of area can one lumberjack or one ranger "cover" - I mean f.e. if there is empty space of 50x50 - how many lumberjack and rangers should be placed there and what maximum production (trunks per period) they can achieve.

It is very hard to say. More lumberjacks means more trunks. But the function can be like logarithm (always growing up, but not too fast). In my opinion we should think not as maximum production, but maximum need in the economy (we need 200 trunks/ minute-> build foresters & woodcutters for 200 trunks, maybe 220 (+10%).

I will make some tests in the future and give you the results.

If I want to achieve production of 40 trunks - how many rangers (we are talking about sustainable production, not cutting existing forests) and lumberjacks are needed in the game?

From my calculations:

Pair lumberjack - forester produce about 1.2 trunks / minute

So 40/1.2=33.333...=34 pairs

Answer: you need at least 40 lumberjack and 40 forester houses (in average terrain mode).

Then how much the terrain type matters?

Probably most of everything. As I said: don't know what are the factors of dying trees, so don't know how much the terrain type matters. I will do the tests for that too.

My experiences says that one ranger can produce enough forests for 4 lumberjacs, does it match your calculations?

Not really. My experience says something else: 1 lumberjack and 1 forester. Calculations says 1 forester and 1.312 foresters (less than 2!) will "eat" all the trees created by the forester.

Of course, the AI would be too stupid to pick right place for lumberjacs and rangers (considering terrain and buildings in vicinity) but still some target numbers based on target productions must be defined within AI.

I don't think so. AI can choose best places for wood production. It can be easily chosen: get the best terrain. Pick up 20x20x20 and get average wood production. That is the best place for wood production. But to define that function we need tests for terrain types! face-sad.png

We can count everything using only code of Widelands, but I don't know where to find the numbers (probability of dying trees- where it is?!).

einstein13


more questions- more answers face-smile.png


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

Top Quote
Tibor

Joined: 2009-03-23, 23:24 UTC+1.0
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-02-12, 23:03 UTC+1.0

Valuable answers, but I dont trust your 1:1, so I am waiting for results of your tests face-smile.png

In many games a player is constrained by terrain (lack of it) so usually you dont have big enough free empty space of good soil. Usually there will be other buildings in vicinity (farms are worst to be there). Many time the forester will be placed on the border and its production (forest) will block expansion of territory...

But of course some checks when placing foresters and cutters are possible and my AI is doing some. But everything must be mathematically defined and not very CPU expensive...

One of possible tests when picking new place is how many foresters/lumberjacks are in radius of (f.e.) 20.


Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-02-13, 10:47 UTC+1.0

Tibor wrote: your tests face-smile.png

Tests are completed for GREENLAND and tribe EMPIRE. You can watch replays, make own test or what you want. The results are written down on XLS file (or PDF2). Average time of work was ~33.6 sec, and ideal calculations: 37.8, so small error. Another thing is the 'mu' factor (how often the tree will grow and be chopped down?). Its value can be 1%, 2%, 60% and 100%. That's for one-type-terrain. And the values can be a bit different- more tests needed.

In many games a player is constrained by terrain (lack of it) so usually you dont have big enough free empty space of good soil.

Yes, but you can plan your empire before you will build foresters and woodcutters. First forester (or some of them) will be built where the base is, but main wood production should be built on good soil. You plan the territory you have. The algorithm is not so difficult. But it needs some writing face-smile.png (I can help something about it)

Usually there will be other buildings in vicinity (farms are worst to be there).

You can prohibit the built there. That's the easiest way.

Many time the forester will be placed on the border and its production (forest) will block expansion of territory...

You can build an outpost or anything there and expand the territory (if needed)

not very CPU expensive...

Usually complex algorithms are: either CPU expensive or RAM expensive. I prefer RAM expensive (usually it's easier to implement such algorithms). This algorithm will be very complex and will need lots of code lines.

One of possible tests when picking new place is how many foresters/lumberjacks are in radius of (f.e.) 20.

Second one is to make own AI map with terrain as a matrix with numbers: 0- nothing built, 1- prohibited, ... (anything you want). So if you want to build a building (for example brewery):

  1. check the matrix
  2. then build (if possible)

After that your foresters will be free of the problems. Sometimes you don't have enough terrain? Expand or conquer! face-smile.png Worse thing is when you will not have enough territory (for example Colonies map). Algorithm for that place should be different a bit... But it can be added in the future! face-smile.png

EDIT: some errors with the calculations. CORRECTED face-smile.png

Edited: 2014-02-13, 21:52 UTC+1.0

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

Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-02-13, 22:34 UTC+1.0

The post above is corrected (mistakes with values and their interpretation).

I've updated the files to the newest version. Now the calculations are experimentally confirmed and the terrain types are defined (the 'mu' factor for each of them). I don't have enough time to make test for:

What size of area can one lumberjack or one ranger "cover" - I mean f.e. if there is empty space of 50x50 - how many lumberjack and rangers should be placed there and what maximum production (trunks per period) they can achieve.

If someone wants to help, let me contact! It isn't hard. face-smile.png I need 2 experiments to do and then I will tell how many foresters and woodcutters should be placed in such a places.

einstein13


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

Top Quote
Tibor

Joined: 2009-03-23, 23:24 UTC+1.0
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-02-13, 22:40 UTC+1.0

Well, you go too far. Much farer then are my plans.

My placing of building (except for military ones) is to be random, but every considered location should be scored. F.e.: Are the borders of empire closer then x fields? For lumberjacts I can count trees in vicinity, simalarly when placing rangers AI should put them close to lumberjacs. When placing farm, they should have no rangers in vicinity....

So when placing a building, the AI will have couple of candidate fields with various score and best one will be used.

But I do not plan any sectorization of territory and specialization of these territories... it would be too complicated

I will look at your files


Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-02-17, 23:57 UTC+1.0

Tibor wrote:

Well, you go too far. Much farer then are my plans.

My plans were to calculate as much as we can. So last release of woodcutters & foresters is done! face-smile.png

Of course more studies are needed but it can be done as another project face-wink.png

Have fun!


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

Top Quote