Latest Posts

Topic: Repairing mines

WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 795
Ranking
One Elder of Players
Location: GER
Posted at: 2018-04-24, 15:30

This thread is a sequel of the discussion which ended in another thread at this point

I could imagine to fix those following bugs at once:

  • Many mines extract less resources from the mountains than they produce

  • Many mines are not finding the desired 5% (or 10%) of resources if they are depleted (in relation to the amount they would find if they are not depleted), but less.

  • Many mines consume faster if they are depleted.

First of all, I tried to modify the imperial coal mine, but I didn't find a perfect solution.

No matter what I'm doing with the lua-files, at least one of the following problems shows up:

  • The mine consumes faster if depleted
  • If the mine is depleted, it finds 3 pieces of coal at once if it finds something
  • If the mine produces 3 pieces of coals at once, it says that it produces 2 or 1 pieces.

Imho problem #1 is the smallest (if the difference of speed is not so high). What do you think, should I try to write the code that way? Or is there a better solution?


“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: 429
Ranking
Tribe Member
Location: Bavaria
Posted at: 2018-04-24, 17:15

WorldSavior wrote:

This thread is a sequel of the discussion which ended in another thread at this point

I could imagine to fix those following bugs at once:

  • Many mines extract less resources from the mountains than they produce

As far as I remember fromm the thread this is probably due to balancing. But it definitly screws up the percentage because 2 pieces found at 5 percent is 10 percent I think. So for me a solution might be to align mine with produce and just multiply the cycle with the produced wares by dividing the waiting and operating times by this value. However the Atlantean crystal mines as a thread starter won't be that easy cause they are really complicated.

  • Many mines are not finding the desired 5% (or 10%) of resources if they are depleted (in relation to the amount they would find if they are not depleted), but less.

Probably could be solved by the above solution as well.

  • Many mines consume faster if they are depleted.

that could probably be fixed by the order of the programs

First of all, I tried to modify the imperial coal mine, but I didn't find a perfect solution.

Could you provide your solution in a branch or as a copy of code here (as far as I know you don't like launchpad) that would make the discussion easier.

No matter what I'm doing with the lua-files, at least one of the following problems shows up:

  • The mine consumes faster if depleted
  • If the mine is depleted, it finds 3 pieces of coal at once if it finds something
  • If the mine produces 3 pieces of coals at once, it says that it produces 2 or 1 pieces.

Imho problem #1 is the smallest (if the difference of speed is not so high). What do you think, should I try to write the code that way? Or is there a better solution?

Hard to say without knowing your code. Currently I don't understand what is happening with your changes.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 795
Ranking
One Elder of Players
Location: GER
Posted at: 2018-04-26, 14:37

hessenfarmer wrote:

WorldSavior wrote:

This thread is a sequel of the discussion which ended in another thread at this point

I could imagine to fix those following bugs at once:

  • Many mines extract less resources from the mountains than they produce

As far as I remember fromm the thread this is probably due to balancing.

I think that the last statement was that it's rather a bug and bad for the balancing. The statement was from me, but has anyone arguments against it?

But it definitly screws up the percentage because 2 pieces found at 5 percent is 10 percent I think.

This bug has nothing to do with percentages of depleted mines, or what do you mean?

So for me a solution might be to align mine with produce and just multiply the cycle with the produced wares by dividing the waiting and operating times by this value.

Multiplying a cycle with wares?

  • Many mines consume faster if they are depleted.

that could probably be fixed by the order of the programs

Yes... But if I try to fix it, the problem is that the mine says that it produced 2 or 1 pieces instead of 3.

First of all, I tried to modify the imperial coal mine, but I didn't find a perfect solution.

Could you provide your solution in a branch or as a copy of code here (as far as I know you don't like launchpad) that would make the discussion easier.

No matter what I'm doing with the lua-files, at least one of the following problems shows up:

  • The mine consumes faster if depleted
  • If the mine is depleted, it finds 3 pieces of coal at once if it finds something
  • If the mine produces 3 pieces of coals at once, it says that it produces 2 or 1 pieces.

Imho problem #1 is the smallest (if the difference of speed is not so high). What do you think, should I try to write the code that way? Or is there a better solution?

Hard to say without knowing your code. Currently I don't understand what is happening with your changes.

Okay. This is the current code:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "mine=coal 2 50 5 17",

        "produce=coal:2",

        "animate=working 20000",

        "mine=coal 2 50 5 17",

        "produce=coal"

What's wrong here? First of all, you can see that the mine does "produce=coal:2" at one place, but it is connected with only one "mine="-line, so here the mine removes 1 coal from the mountain, but puts 2 coal at the flag. Next problem is that the mine has only 3,3% efficiency if it's depleted - and if it finds something, it finds not only 1 piece, but two at once.

One further problem: If the mine is depleted, the second "animate"-line is very rarely reached, so the time between the meals of the miners is at least 20 seconds shorter, so they eat significantly faster. (Normally they eat one time in 96 seconds.)

It's possible to solve all the problems at once, but then the mine will say that it finds 2 pieces instead of three:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 15 17",       -- 3*5%=15%

        "produce=coal",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

        "produce=coal:2"

So the mine produces 3 coal at once here, but the last line is "produce=coal:2", so the mine will say "has produced 2 coal". At least that's what I think, I didn't test it.

Further questions? face-smile.png


“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: 429
Ranking
Tribe Member
Location: Bavaria
Posted at: 2018-04-26, 20:00

WorldSavior wrote:

  • Many mines extract less resources from the mountains than they produce

As far as I remember fromm the thread this is probably due to balancing.

I think that the last statement was that it's rather a bug and bad for the balancing. The statement was from me, but has anyone arguments against it?

Hm I think the number of wares produced, and time to produce them forms part of the balancing. The fact that some tribes could extract more from the natural ressources than others is bad for balancing I agree. Especially on low ressource maps.

But it definitly screws up the percentage because 2 pieces found at 5 percent is 10 percent I think.

This bug has nothing to do with percentages of depleted mines, or what do you mean?

Yes I meant percentage of depleted mines. Currently the chance to find something is defined in the mine program but not the chance of how much is produced from depleted mines on average. From my perspective it should be defined how much could be produced. So I think we should probably fix this issue as well. in this fix cycle.

So for me a solution might be to align mine with produce and just multiply the cycle with the produced wares by dividing the waiting and operating times by this value.

Multiplying a cycle with wares?

ok my expression was not really exact. I meant if there is a produce :2 cycle just add another mining line and if you add another animate line as well you should divide the animate cycle by two.

What's wrong here? First of all, you can see that the mine does "produce=coal:2" at one place, but it is connected with only one "mine="-line, so here the mine removes 1 coal from the mountain, but puts 2 coal at the flag. Next problem is that the mine has only 3,3% efficiency if it's depleted - and if it finds something, it finds not only 1 piece, but two at once.

Understood so far.

One further problem: If the mine is depleted, the second "animate"-line is very rarely reached, so the time between the meals of the miners is at least 20 seconds shorter, so they eat significantly faster. (Normally they eat one time in 96 seconds.)

That is what I don't understand fully so the whole chain of Program entries is terminated if the mine line does not return true? Is this documented anywhere? I wasn't aware of this yet.

It's possible to solve all the problems at once, but then the mine will say that it finds 2 pieces instead of three:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 15 17",       -- 3*5%=15%

        "produce=coal",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

        "produce=coal:2"

So the mine produces 3 coal at once here, but the last line is "produce=coal:2", so the mine will say "has produced 2 coal". At least that's what I think, I didn't test it.

Why not? Iwould suggest playing around with the file and see how it behaves. How about having all 3 coal produced in the first sentence and just add the mine lines at the end to have proper extraction of ressources. of course the probability needs to be adjusted then so if it is set to two this would mean there is an average probabiltiy of 6 to find 1 piece

Further questions? face-smile.png


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 429
Ranking
Tribe Member
Location: Bavaria
Posted at: 2018-04-26, 23:57

Have finished my Excel about mines. some very strange values in there . feel free to use it in your fixes. I am mnow deeply convinced the mines need fixing and balancing.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 795
Ranking
One Elder of Players
Location: GER
Posted at: 2018-05-04, 18:51

hessenfarmer wrote:

WorldSavior wrote:

So for me a solution might be to align mine with produce and just multiply the cycle with the produced wares by dividing the waiting and operating times by this value.

Multiplying a cycle with wares?

ok my expression was not really exact. I meant if there is a produce :2 cycle just add another mining line and if you add another animate line as well you should divide the animate cycle by two.

Adding additional mine-lines has always been the plan.

One further problem: If the mine is depleted, the second "animate"-line is very rarely reached, so the time between the meals of the miners is at least 20 seconds shorter, so they eat significantly faster. (Normally they eat one time in 96 seconds.)

That is what I don't understand fully so the whole chain of Program entries is terminated if the mine line does not return true? Is this documented anywhere? I wasn't aware of this yet.

Yes, that is how it works, I tested that.

It's possible to solve all the problems at once, but then the mine will say that it finds 2 pieces instead of three:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 15 17",       -- 3*5%=15%

        "produce=coal",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

        "produce=coal:2"

So the mine produces 3 coal at once here, but the last line is "produce=coal:2", so the mine will say "has produced 2 coal". At least that's what I think, I didn't test it.

Why not? Iwould suggest playing around with the file and see how it behaves. How about having all 3 coal produced in the first sentence and just add the mine lines at the end to have proper extraction of ressources.

That is unfortunately no solution, because the mine wouldn't become depleted.

By the way, I've gotten a solution now, I guess: It's possible to just move some seconds of the "sleep"-line right after the first "produce"-line. It will not speed up depleted mines a lot and nobody has to be confused if the mine says "has produced 2 coal".


“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: 429
Ranking
Tribe Member
Location: Bavaria
Posted at: 2018-05-04, 21:03

WorldSavior wrote:

Adding additional mine-lines has always been the plan.

Understood, but I thought for whatever reason there might be animation lines added too, which is effectivly a sleep cycle. I f this would be the case it is importnat to have the overall production time of the complete cycle in mind.

That is what I don't understand fully so the whole chain of Program entries is terminated if the mine line does not return true? Is this documented anywhere? I wasn't aware of this yet.

Yes, that is how it works, I tested that.

that is indeed a pity face-sad.png

It's possible to solve all the problems at once, but then the mine will say that it finds 2 pieces instead of three:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 15 17",       -- 3*5%=15%

        "produce=coal",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

        "produce=coal:2"

So the mine produces 3 coal at once here, but the last line is "produce=coal:2", so the mine will say "has produced 2 coal". At least that's what I think, I didn't test it.

Why not? Iwould suggest playing around with the file and see how it behaves. How about having all 3 coal produced in the first sentence and just add the mine lines at the end to have proper extraction of ressources.

That is unfortunately no solution, because the mine wouldn't become depleted.

Ok I understand but what would be if we use this code:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 2 17",       -- 3 pieces*2%=6% which is close to the desired 5%

        "produce=coal:3",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 795
Ranking
One Elder of Players
Location: GER
Posted at: 2018-05-16, 01:07

hessenfarmer wrote:

WorldSavior wrote:

Adding additional mine-lines has always been the plan.

Understood, but I thought for whatever reason there might be animation lines added too, which is effectivly a sleep cycle. I f this would be the case it is importnat to have the overall production time of the complete cycle in mind.

The idea is rather to split up animation-lines, if necessary. I never planned to increase the total time...

That is what I don't understand fully so the whole chain of Program entries is terminated if the mine line does not return true? Is this documented anywhere? I wasn't aware of this yet.

Yes, that is how it works, I tested that.

that is indeed a pity face-sad.png

But that leads to depleted mines, so maybe it's good face-wink.png

It's possible to solve all the problems at once, but then the mine will say that it finds 2 pieces instead of three:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 15 17",       -- 3*5%=15%

        "produce=coal",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

        "produce=coal:2"

So the mine produces 3 coal at once here, but the last line is "produce=coal:2", so the mine will say "has produced 2 coal". At least that's what I think, I didn't test it.

Why not? Iwould suggest playing around with the file and see how it behaves. How about having all 3 coal produced in the first sentence and just add the mine lines at the end to have proper extraction of ressources.

That is unfortunately no solution, because the mine wouldn't become depleted.

Ok I understand but what would be if we use this code:

        "sleep=45000",

        "return=skipped unless economy needs coal",

        "consume=beer ration",

        "animate=working 20000",

        "animate=working 20000",   -- or just one time  "animate=working 40000",

        "mine=coal 2 50 2 17",       -- 3 pieces*2%=6% which is close to the desired 5%

        "produce=coal:3",

        "mine=coal 2 50 0 17",          -- 0%

        "mine=coal 2 50 0 17",       -- 0%

That would have the problem that the depleted mine finds three pieces at once if it finds something. Weird. And the efficiency of the depleted mine is not 5% here, but only 2%.

Edited: 2018-05-16, 01:09

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

Top Quote
Arty
Avatar
Joined: 2018-08-03, 12:14
Posts: 20
Ranking
Pry about Widelands
Posted at: 2018-08-16, 02:19

Okay, this is a little older, but judging from the lua files of the mines of most recent builds nothing has been done, so let me chime in here. I think most issues can be easily resolved.

So the problems are

WorldSavior wrote:

  • Many mines extract less resources from the mountains than they produce

  • Many mines are not finding the desired 5% (or 10%) of resources if they are depleted (in relation to the amount they would find if they are not depleted), but less.

  • Many mines consume faster if they are depleted.

and we want to solve them without creating annoying things like

WorldSavior wrote:

  • The mine consumes faster if depleted
  • If the mine is depleted, it finds 3 pieces of coal at once if it finds something
  • If the mine produces 3 pieces of coals at once, it says that it produces 2 or 1 pieces.

One of the main technical issues so far was that when the mine command fails, the calling program (in this case work) immediately fails without executing the other commands. This can easily be avoided by wrapping mine in a call command. For the imperial coal mine I suggest to replace the original

   programs = {
      work = {
         -- TRANSLATORS: Completed/Skipped/Did not start mining coal because ...
         descname = _"mining coal",
         actions = {
            "sleep=45000",
            "return=skipped unless economy needs coal",
            "consume=beer ration",
            "animate=working 20000",
            "mine=coal 2 50 5 17",
            "produce=coal:2",
            "animate=working 20000",
            "mine=coal 2 50 5 17",
            "produce=coal"
         }
      },
   },

by

   programs = {
      work = {
         -- TRANSLATORS: Completed/Skipped/Did not start mining coal because ...
         descname = _"mining coal",
         actions = {
            "sleep=46000",
            "return=skipped unless economy needs coal",
            "consume=beer ration",
            "call=mine_coal",
            "call=mine_coal",
            "call=mine_coal",
         }
      },
      mine_coal = {
         descname = _"mining coal",
         actions = {
            "animate=working 13000",
            "mine=coal 2 50 5 17",
            "produce=coal",
         }
      },
   },

What it does is:

  • The actual mining (including the animation) is now an extra program mine_coal which is called from work three times. And because the default behaviour of call is to ignore it when the called program failed, a mining fail doesn't result in work failing, so all three calls are always executed.

  • Non-depleted mines produce three coal per food consumption like in the original (just 3x1 instead of 1x1 and 1x2), and also in the same time. (To keep the times full seconds, I moved the one missing second from the mining to the sleeping part.)

  • Depleted mines automatically produce (on average) the stated 5% (compared to non-depleted mines) per food consumption, because there are no shenanigans anymore with work prematurely failing.

  • For the same reason, depleted mines also don't consume so much faster than non-depleted mines anymore.

  • HOWEVER, depleted mines still consume somewhat faster than non-depleted mines, because after failing to mine coal the worker can skip carrying the coal outside. With about 3.8 seconds walking time per coal, the food cycle of a depleted mine is about 11% shorter than that of a non-depleted mine. I don't see a way around that.

  • As a nice side effect, using this extra program for the mining also makes it easier to guarantee that production amount matches extraction amount. (It still allows to purposefully add such a discrepancy though, in case this is wanted to simulate a tribe's mining efficiency.)

Basically all mines could be adjusted this way. And if those discrepancies between production and extraction are on purpose and balanced, then this can still be incorporated. Only the Atlantean crystal mine is more complex. It already uses sub-programs and call, but inside each sub-program there are still lots of mine commands which can prematurely end a sub-program and mess with times and outcomes. (Which might be somewhat on purpose and already balanced, I don't know.)

In any case, I think that those premature fails with depleted mines should generally be avoided by having no more than one mine command in one program. Makes it much easier to define what a mine is actually supposed to do, script it accordingly, verify whether it works as intended, and not having to worry about so many nasty side effects.

Just my 2 cents.

What do you think? When I am done setting up my system (which still might take a while), I can make a branch and add such changes. Before that we would need to discuss the issue of production vs. extraction though, because it really looks like it was done on purpose with different tribes having different extraction efficiency, and undoing this might result in some unbalancing.

Edited: 2018-08-16, 07:33
Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 2626
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-08-16, 08:50

This is currently work in progress - see https://code.launchpad.net/~widelands-dev/widelands/mines-worldsavior/+merge/350716


Busy indexing nil values

Top Quote