Latest Posts

Topic: Measuring working time of productionsites

niektory
Avatar
Joined: 2019-06-03, 20:06
Posts: 47
Ranking
Pry about Widelands
Location: Poland
Posted at: 2020-01-17, 09:13

WorldSavior wrote:

Does this new method also work fine when the worker walks a lot around or if there are a lot of animations? And what about buildings with various output?

Seems to works fine with the workers walking around.

If a building produces one ware but skips another, the productivity percentage falls, but not drastically. Based on my testing Frisian Drinking Hall that produces Rations but skips Meals reaches 96%, and Furnace that produces Gold but skips Iron reaches 85%. One quirk I noticed is that in those cases the plus/minus sign next to the percentages is almost always a minus, even if the overall productivity rises. This is because the percentage alternately rises when a ware is produced and falls when it's skipped, and the rising one is only displayed for a very short time.

The percentage takes a fairly long time to rise or fall. Not sure if it's good or bad. Depends if you want to see short term or long term productivity.

EDIT: Unlike before, productivity now falls if buildings skip work because their output is not needed. I think it's a good change, before it just showed an "out of date" value.

I also think it should reach 100% sometimes. It's just more satisfying. face-smile.png

I ran into a nasty bug when trying this out. Not sure if it's caused by these changes, but I don't remember ever running into it before. The game frequently freezes for an extended amount of time, sometimes for over 10 minutes. Load the attached save and it should occur within a few minutes. The version is r24376[080cd82@HEAD] (Release).

Edited: 2020-01-17, 09:21

Attachment: bug long hangs.wgf (923.0 KB)

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1116
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-01-17, 09:45

Just for information here is how it works:
every time a production_program finishes we save a tick mark of actual gametime. For this it is irrelevant if it is a pure "inside" program or contains an "outside" walking worker program.
when the next program finishes we can measure the time needed for it. This is very low for one single failed / skipped program. Only if a program fails/skips a second time it has a potential 10 second penalty if the first skip / fail of the particular programm has happened less then 10 secs before.
then we use the following formula based on a time base of 10 minutes:
percentage = percentage * (10 min -program_time) + 100 % * program_was successful * program_time
so the second summand is only there if th program was succesful.
the speed of falling and rising can be adjusted by setting the time base. However it is different for the buildings. A building with very long Working times (mostly containing walking programs) will rise faster then others and reach higher overall productivity.
the reason for the frisians drinkiung halöl reaching 96% while skipping meals is that this is the maximum value for the drinking hall as skipping takes literally no time. the reason for a furnace skipping iron only having 85% is that it has 2 ironcycles and 1 goldcycle so it gets the 10 second penalty when skipping the second iron cycle in a row. If it skips only gold it will reach its max productivity instead
the negative trend in this cases might be annoying but shows that something is not completely correct, I'll think about a solution though.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 1434
Ranking
One Elder of Players
Location: GER
Posted at: 2020-01-19, 15:42

Interesting...

hessenfarmer wrote: the reason for a furnace skipping iron only having 85% is that it has 2 ironcycles and 1 goldcycle so it gets the 10 second penalty when skipping the second iron cycle in a row.

I'm wondering if it wouldn't be better if there wouldn't be a penalty for the second skipping, but later; maybe third or forth skipping? There are some buildings which run a program two times per cycle and I don't really see why they should work slower than they could when they produce only one kind of ware...


“It's a threat to our planet to believe that someone else will save it.” - Robert Swan

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1116
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-01-21, 09:51

WorldSavior wrote:

Interesting...

hessenfarmer wrote: the reason for a furnace skipping iron only having 85% is that it has 2 ironcycles and 1 goldcycle so it gets the 10 second penalty when skipping the second iron cycle in a row.

I'm wondering if it wouldn't be better if there wouldn't be a penalty for the second skipping, but later; maybe third or forth skipping? There are some buildings which run a program two times per cycle and I don't really see why they should work slower than they could when they produce only one kind of ware...

I have thought about that. In my opinion this is only the case if there isn't a program in between the 2 skipping programs. meaning you have 3 programs only or they are ordered badly. Currently I only remeber the semelting works having this 3 program constellation. for them the solution would be to have 2 identical programs with different names. "smelt_iron_1" and "smelt_iron_2" so they are skipped independently. Any other Productionsites where there is a similar situation?

BTW the changes got merged yesterda to the master branch. I need to provide a fix for the 100% problem though so I can fix this on the fly as well.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 1434
Ranking
One Elder of Players
Location: GER
Posted at: 2020-01-21, 17:43

hessenfarmer wrote:

for them the solution would be to have 2 identical programs with different names. "smelt_iron_1" and "smelt_iron_2" so they are skipped independently.

That sounds like a very nice solution.

Any other Productionsites where there is a similar situation?

Atlantean smokery (2 times fish), Empire armorsmith (2 times helmets), maybe also frisian large armor smith (each sword 2 times - but not in a row), maybe frisian small armor smith (broad sword 2 times - but not in a row), maybe recycling center, maybe reindeer farm

I've read through a list of all productionssites of all 5 tribes and hope that I didn't forget anything.


“It's a threat to our planet to believe that someone else will save it.” - Robert Swan

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1116
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-01-21, 17:49

WorldSavior wrote:

hessenfarmer wrote:

for them the solution would be to have 2 identical programs with different names. "smelt_iron_1" and "smelt_iron_2" so they are skipped independently.

That sounds like a very nice solution.

Any other Productionsites where there is a similar situation?

Atlantean smokery (2 times fish), Empire armorsmith (2 times helmets), maybe also frisian large armor smith (each sword 2 times - but not in a row), maybe frisian small armor smith (broad sword 2 times - but not in a row), maybe recycling center, maybe reindeer farm

I've read through a list of all productionssites of all 5 tribes and hope that I didn't forget anything.

Ok I'll have a look into it. Many thanks for the help.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1116
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-01-23, 09:44

Hi, I pushed a new revision of the branch which fixes the 100% problem. I normalized each productionsites time base to 3 times the average working time (although the average is only based on the last average and the current duration yet) by this a fully working building reaches 99,1 % at minimum and I could just add a 0,9 % before we skip the decimals. While writing I will try to use a weighted average (giving history probaly 80% weight and actual value 20%) and see how this works. by this we could probably have the average working time after the things have settled by just using a debug print. I need to correct the lua files though.


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1316
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-01-23, 09:55

I was trying to view your commit ... is there a way to list latest commits regardless of branch on GitHub? If not, what branch it is?


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1116
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-01-23, 10:06

uups sorry should have done this in the first post.
https://github.com/widelands/widelands/tree/productionsite_performance

feedback is appreciated


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1316
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-01-23, 10:24

Well, I liked more the previous state:

entire_duration = 10 * 60 * 1000;

This says that 10 minutes is some reference time and the same for all sites. By your change this variable becomes kind of volatile. What is usual values (range) achieved? I would say it is between 1-5 minutes....

I dont think this is best way to adress rounding and trimming.

I would not mind this change for players, but for AI I would prefer to keep current state. Also AI does not need to achieve 100% or 0% performance


Top Quote