Granite mines should check if their output is needed

Bug #1344179 reported by wl-zocker
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Wishlist
Unassigned

Bug Description

Currently, there are two different designs on how mines work:
1) When there is enough input (stock > target quantity), always produce a ware. When there is not enough input, produce the ware only when it is needed (stock < target quantity). I.e. the mine consumes food even when its output currently is not needed.
This system is currently used for all Atlantean mines, and the Imperial (deep) gold, iron ore, and coal mine.
2) The other mines (all Barbarian mines and the Imperial marble mine, including all enhancements) do always work, even when the economy has no food (there is no check at all).

I suggest the following:
- All mines built on granite plots (granite, marble, crystal) should check whether their output is needed and only produce if that is the case. The idea is that their output is not needed regularily (but only when new buildings are built), so it makes no sense to have hundreds of stones on stock.
- The other mines should work as described in 1. It is then possible to produce ores and coal on stock. This is useful because they are always needed.

If the mines do not produce when their output is not needed and the food producing buildings are changed to do the same (there are some inconsistecies), you end up with having lots of basic food ingredients (water, wheat, raw fish/meat), which are not very useful. When more smelting works are built, this food first has to be processed.

What do others think about this?

Tags: gameplay

Related branches

Revision history for this message
SirVer (sirver) wrote :

There are target quantities for each of the outputs (coal, iron, whatever the granite mines produce). All should adhere to that I think. If the user wants to stockpile coal, she can increase the target quantities.

Changed in widelands:
status: New → Confirmed
status: Confirmed → Incomplete
Revision history for this message
wl-zocker (wl-zocker) wrote :

Most buildings do not honor the default target quantity of the produced ware, but the one of the consumed ware (i.e. the building works as long as there is enough of the input ware in the economy, regardless of whether the output is needed). The animal farms and the Barbarian weaving mill I fixed also used this concept. I discovered later that this is the normal behavior, but for those buildings, it annoyed me.
Should the behavior be changed for all buildings or are there reasons why it was designed the way it is?

Revision history for this message
SirVer (sirver) wrote :

It was never really designed or discussed about imho - somebody just implemented one approach and we never talked about it much. It helped with Widelands cycles in the ware dependencies.

But I do not think what you say is completely correct. Imho the buildings are implemented something like this:

1) if your output target quantity is not reached, produce if you can.
2) if your output target quantity is reached and it is not reached for your inputs, do not produce.
3) if your output target quantity is reached and the one for your inputs is too, just produce.

I think that 3 might be bad. 1 and 2 make sense to me.

Revision history for this message
wl-zocker (wl-zocker) wrote :

> But I do not think what you say is completely correct.
Yup, indeed I expressed a bit unclear. Thanks for correcting me.

> I think that 3 might be bad. 1 and 2 make sense to me.
This is exactly what I changed in my branch (https://code.launchpad.net/~wl-zocker/widelands/conf_files_changes, r7066 and r7067, if someone is interested in it).
When their output is needed, the buildings produce always. When their output is not needed, they never produce. The target quantity is now really a target and not a minimum value.
Is this the way to go for all buildings?

Revision history for this message
SirVer (sirver) wrote :

> Is this the way to go for all buildings?

I think so - it feels more consistent to be. Might feel bad in the game though, but we will not be able to tell without trying it out.

Revision history for this message
wl-zocker (wl-zocker) wrote :

I will start working on this. Or is there a reason why this was set to incomplete?

Changed in widelands:
assignee: nobody → wl-zocker (wl-zocker)
status: Incomplete → In Progress
Revision history for this message
SirVer (sirver) wrote :

incomplete just means: currently under discussion around here. Go for it!

Revision history for this message
GunChleoc (gunchleoc) wrote :

With this change, maybe we should increase the default target quantity for processed foodstuffs (ratios, smoked fish etc) so we always have enough of them. We do need to make sure though that cattle farms will still produce then and not wait for the bakery to snatch up 100% if wheat and water.

Revision history for this message
wl-zocker (wl-zocker) wrote :

According to https://help.launchpad.net/Bugs/Statuses, incomplete means that information is needed. I do not know how our use differs from that.
Increasing the default target quantity makes sense. Should this only happen for the food delivered to mines or also for intermediate goods (e.g. flour)?
The cattle farm will produce oxen and the bakery will produce bread until the target quantity is reached. As long as that is not the case, both will consume wheat and water. It is then the task of the economy/road network/player to take care that both buildings are still supplied. So I see no problem here. The same problem occurs for many other wares, too (e.g. logs -> charcoal kiln, wood hardener, metal workshop).

Revision history for this message
GunChleoc (gunchleoc) wrote :

I'm not sure if we need an increased target quantity for the basic stuff, since the taverns etc will use it up to fulfill their own target quantities.

Revision history for this message
SirVer (sirver) wrote :

Fixed in r7155.

Changed in widelands:
status: In Progress → Fix Committed
importance: Undecided → Wishlist
milestone: none → build19-rc1
wl-zocker (wl-zocker)
Changed in widelands:
assignee: wl-zocker (wl-zocker) → nobody
Revision history for this message
Teppo Mäenpää (kxq) wrote :

How would this affect training?

Currently, empire mines consist two work cycles. If either fails, there is not training.

If a player has some wine/foodstuff production but not enought, typically the first cycle succeeds and 2nd fails. This leads to mine exhaustion without worker training.

If this change was implemented, training would be affected.

Revision history for this message
wl-zocker (wl-zocker) wrote :

I have not tested it in the game, but I think training should not be affected at all. The program in question is:
[mine_marble]
sleep=20000
return=skipped unless economy needs marble or economy needs stone
consume=wine ration
animate=working 20000
mine=granite 2 50 5 17
produce=marble:2
animate=working 20000
mine=granite 2 50 5 17
produce=marble stone

[mine_stone]
//the same again, with different outputs

When mine_marble or mine_stone are successful, the worker gains experience (when both are successful, the worker gains 2 EP). The program is successful when
- marble or stone are needed. If wanted, a "or workers need experience" (only the Barbarian micro-brewery uses this) can be added. It is an interesting question whether this should not be added to all buildings that need a better worker when upgraded (i.e. all mines (including the deepest ones) and the axfactory).
- the needed food is available. This is only consumed once, i.e. when there is no food, nothing is mined at all.
- there is still granite in the mountain. If there are less than 50% (second parameter) of the initial amount in the radius 2 (first parameter) and no stone is mined (in 5% (third parameter) of the cases, even the empty mine finds some resources), the worker still has a 17% (fourth parameter) chance of gaining experience.

I do not see how my change should affect the training of the workers (I only changed the return= line). I cannot deduct your statement from the conf file.

Revision history for this message
Teppo Mäenpää (kxq) wrote :

Current scenario: Experience is gained only when both cycles succeed. If one of the mine-steps succeeds and other fails (no food/wine), mountain resources diminish but miner does not gain experience. If the economy has trouble delivering rations/wine fast enough, the mine may need upgrade before the miner is experienced enough.

new way: Experience is gained also when one mine-step succeeds, if the other is skipped as a result of stone-not-needed.
Also, if marble and stone are mined in separate steps, the granite mine produces what the economy needs and exhausts later. Both these benefit the Empire.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Sounds familiar:

https://wl.widelands.org/forum/topic/1478/

This is a separate bug though - could you please open a new one?

Revision history for this message
wl-zocker (wl-zocker) wrote :

Sorry, but what you say is wrong.

> If one of the mine-steps succeeds and other fails (no food/wine), mountain resources diminish but miner does not gain experience.
I think most of the sentence is correct, but there is only one consume command. I.e. when there is enough food for the first mine command to be executed (one ration and one wine), the second one is also executed because no more food is needed in between.

I have just tested it in the game: When the mine only has one ration and one wine, it starts mining and produces the four wares (I did not check how many resources vanish from the mountain, but I guess one with every mine command). The worker has gained one experience point now. Because I set the maximum stock level of wine and rations to one and the way to my headquarters is long, the mine does not contain any food and can therefore not work. But the worker has already gained experience.

Revision history for this message
wl-zocker (wl-zocker) wrote :

I noticed that there might be some problems of the terms we use.
For me, program is everything that comes after [mine_marble] (the nine lines I posted above). A command is just one line, i.e. the mine command is the line "mine=granite 2 50 5 17".

Can you please define "cycle" and "mine-step"?
Also, I do not understand your last paragraph with the separate steps. Maybe what I wrote in the merge request is helpful:
- The crystal mine and the marble mine check if any of their output is needed before they work, even when the output cannot be created in the current program. This is to avoid "lucky digging" (I only need marble -> my mine finds more marble than normal).

Revision history for this message
Teppo Mäenpää (kxq) wrote :

> Sorry, but what you say is wrong.

This is always possible. However,

> but there is only one consume command.

In the latest release, there are consume-commands in lines 34 and 54 of widelands/tribes/empire/marblemine/conf.

> I have just tested it in the game: When the mine only has one ration and one wine, it starts mining and produces the four wares

In current trunk your findings can be true: consume-commands (34, 48 in my current snapshot) are executed only if corresponding wares are needed. Both steps produce four stones, so in your test half of the program was most likely skipped.

Revision history for this message
wl-zocker (wl-zocker) wrote :

Yes, there are two consume commands. But they are in different programs (mine_marble and mine_stone) which are completely independant of each other.
In my test, only mine_marble was executed. One wine and one ration were consumed, and two granites were removed from the mountain (at least I think so, one in each mine command). Four wares (2 marble and 1 marble/1 stone) were produced and the worker gained an experience point. As you can see, mine_marble contains everything that is needed for a full cyclus (consume, mine, produce, gain experience), therefore I was only talking about mine_marble in my posts above and I also only considered mine_marble in my in-game test. I did this to simplify things and because your inital question was about training, which is completed within mine_marble.
The same reasoning applies to mine_stone, which is the same program, but with different outputs. This is why I talked about one "program" in general.

Since I still do not understand your problem, I cannot open a new bug report. If you think this is important, please do so.

Revision history for this message
Teppo Mäenpää (kxq) wrote :

>Since I still do not understand your problem

I player a test game to be more clear, and -- it turned out that I remembered wrong.

GunChleoc (gunchleoc)
tags: added: gameplay
removed: conffiles
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.