Currently Online

Latest Posts

Topic: Problem with worker requests

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-06-20, 16:51

I just tried to play the 'Poor Hamlet' (Armes Dorf) startingcondition... had to start about 4 times from scratch because i made too many failures face-grin.png

Anyway, now i found something which i think is strange (i would call this a bug, at least with this wincondition): It looks like worker requests are not reset. Played Empire...

Hammer-problem:
At start i have only two hammers, one is needed for a builder, the second one is needed for the toolsmith. So in the beginning of the game one has to be careful with construction sites: As you soon build two construction sites, the second hammer will be turned into a second builder, leaving you with no hammer for the toolsmith. So my idea was to start a second construction site, but not connecting it to the economy. I believed this would prevent building the second builder and it looks like that: The second hammer stays in the warehouse. After building the toolsmith, the toolsmithy was made with the second hammer and all looks fine... Than i needed a hammer for the geologist and started to produce one hammer in the toolsmith... i had no construction site at this point in the game, but after the hammer was made it get transported to the warehouse and immediately a new builder was made (instead of the geologist), although i had a builder in the warehouse. In the end i had two builders without needing them at this time.

Pick-Problem, or stonemasons problem:
The toolsmith needs one marble column to finish. So one has to build at least a quarry and a stonemasons house, both needs a stonemason wich needs a pick but there is only one pick available in the beginning. So i build a quarry first to get some marble. While waiting for marble i built a stonemasons house. The stonemasons house lacks a stonemason, so after it get filled with some marble i send the stonemason from quarry to the stonemasons house to get this one marble column, and send him back to the quarry again. After some time the quarry gets out of resources, i dismantled the quarry and the stonemason was going to the stonemasons house. At this point in the game i had no need for any stonemason, because there were no quarry or other buildings which require a stonemason. But if i let the toolsmith start to produce a pick for a miner, the pick will be used immediately for a second stonemason.


This looks to me like worker requests are not reset, although there is no need for a worker.

The attached savegame shows the 'hammer'-problem:

  • start the game, open the inventory and look at the fourth tab, open also the economy settings
  • request a geologist at the flag on the mountain
  • start producing a hammer
  • wait until it get turned into a second builder

I would expect, because a builder is already at the warehouse, the hammer would be used for a geologist.

This can be solved with Economy worker limits, but i think a better solution would be to check available workers (in a warehouse) before creating them.


Attachment:
test_armes_dorf_hammer.wgf (88.1 KB)

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

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1928
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-06-20, 21:12
  • At some time point, the economy notices that one builder is needed but zero are currently available.

  • The economy checks how many builders can be created straight away: zero. A warehouse is told to plan to create one builder.

  • The warehouse requests a hammer.

  • A hammer is produced sometime later.

  • The hammer is brought to a warehouse that requested a hammer.

  • The warehouse uses the hammer to fulfil the plan and create a builder.

Edit:

When multiple worker types are planned, older plans have precedence over newer plans.

Plans are completely independent from the Requests that cause the Economy to trigger their creation.

Edited: 2020-06-20, 21:14

Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-06-21, 10:30

Thanks for the reply.

Plans are completely independent from the Requests that cause the Economy to trigger their creation.

I think i did some wrong wording, from a developers perspective.

Nordfriese wrote:

  • At some time point, the economy notices that one builder is needed but zero are currently available.

  • The economy checks how many builders can be created straight away: zero. A warehouse is told to plan to create one builder.

  • The warehouse requests a hammer.

  • A hammer is produced sometime later.

  • The hammer is brought to a warehouse that requested a hammer.

  • The warehouse uses the hammer to fulfil the plan and create a builder.

This describes what happen internally. Should a player have to know how this works?

If a warehouse plan was made in the past, the plan, or some of its content, is maybe outdated in the meantime. Shouldn't there be an additional check to verify that the warehouse plan is up to date yet?

I guess such a check would also save some iron in normal games.

'My' problem with the already started game is now: I have not enough iron left to create some tools to build a basic food economy to provide the miner with food and beer. The solution is to start from scratch again, preventing each action which will force a warehouse plan.


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

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1928
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-06-21, 12:44

For me it's hard to imagine playing without understanding the internal workflows triggered by every decision face-grin.png

In some cases, old warehouse plans will be cancelled if they are no longer needed. This is optimised out in several cases though for performance reasons; and in "normal" games it doesn't matter if you spend one iron too much on a worker you don't need; this code simply wasn't written with this extreme case in mind.

Code: Economy::create_requested_worker

If a warehouse plan was made in the past, the plan, or some of its content, is maybe outdated in the meantime. Shouldn't there be an additional check to verify that the warehouse plan is up to date yet?

The problem is that the code pathways involved here don't communicate. We have a Request that just asks for a worker. We have an Economy that frequently tries to fullfill requests and creates warehouse plans as needed. And Warehouses fulfil their plans when possible. "up to / out of date" has no definable meaning here.

Personally, I believe that fixing https://github.com/widelands/widelands/issues/3250 will involve some non-trivial refactoring of this function. When someone does that, they might try to address this issue as well.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-06-28, 08:50

The warehouse could check whether the target player immovable still exists before fulfilling a request.

This will not fix the unconnected construction site problem, but it will fix the 2 stonemasons problem.

For the second problem, we could save the descr() type and check for a match?


Busy indexing nil values

Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-06-28, 10:48

Nordfriese wrote:

For me it's hard to imagine playing without understanding the internal workflows triggered by every decision face-grin.png

Then you have to pay much attention to what players say face-smile.png

I started again from scratch built one house after another, every time waiting until the builder arrives at the warehouse again. I don't know how, but the toolsmith produces a hammer again, without needing one. Maybe i reset the economy setting too late, i don't know.

The problem here is that the code does things which a player can't control. Can't the player get more control of toolproduction if the toolsmithy window gets a third tab, where one can prefer the production of a specific tool? Similar to the prefer wares buttons of construction sites.


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

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1928
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-06-28, 20:36

kaputtnik wrote:

Nordfriese wrote:

For me it's hard to imagine playing without understanding the internal workflows triggered by every decision face-grin.png

Then you have to pay much attention to what players say face-smile.png

True face-smile.png And on the other hand, players have to pay much attention to what coders say, because things easy enough to imagine are nearly impossible to code, such as this: face-wink.png

The problem here is that the code does things which a player can't control. Can't the player get more control of toolproduction if the toolsmithy window gets a third tab, where one can prefer the production of a specific tool? Similar to the prefer wares buttons of construction sites.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-06-29, 08:07

Nordfriese wrote:

kaputtnik wrote:

Nordfriese wrote:

For me it's hard to imagine playing without understanding the internal workflows triggered by every decision face-grin.png

Then you have to pay much attention to what players say face-smile.png

True face-smile.png And on the other hand, players have to pay much attention to what coders say,

Also true. The relationship between developers and players are a bit complicated, because each can't live without the other ...

BTT: If it is such complicated to get a solution, i am in favor to remove the starting condition 'Poor Hamlet'. It is just no fun if one has to know how the internal code works.


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

Top Quote
JanO
Avatar
Joined: 2015-08-02, 11:56
Posts: 177
Ranking
At home in WL-forums
Posted at: 2020-06-29, 09:23

Would it be reasonable to code a manual mode for (tool-)smiths? Like two additional buttons (next to work/stop) where one can shift between "stop", "automatic", "manual" where stop is obvious, automatic means the current behaviour and manual makes this specific building invisible for requests from warehouses. Then we would need an additional window or tab (building-specific or economy-wide) where those manual requests can be set. This could look like the one for the economy targets to keep it simple on UI-level.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-06-29, 09:48

kaputtnik wrote:

BTT: If it is such complicated to get a solution, i am in favor to remove the starting condition 'Poor Hamlet'. It is just no fun if one has to know how the internal code works.

Basically this start mode is a puzzle. And it was requested by some players who liked the fun of solving it. It does no harm to leave it there.
Well I believe you don't need to know how the code works, after fixing the issue with the woodcutter in barbarians. If you built the right order of buildings the correct tools will be produced. As with other puzzles there is just one way to solve this.


Top Quote