Latest Posts

Topic: Improving Production Sites

toptopple
Avatar
Topic Opener
Joined: 2013-10-30, 08:11
Posts: 156
Ranking
At home in WL-forums
Posted at: 2016-07-26, 11:52

The aim of this thread is to discuss improvements to multi-product production sites of Widelands, by exclusion of the training sites (which have their own implementations). For this I refer to the LUA scripts of these sites.

Problem: If you take e.g. the Barbarians->Big-Inn you will find that this site can produce 3 kinds of products: ration, snack and meal. You will further find that producing a ration in a Tavern costs about 45 sec in time. Running the same cycle in a Big-Inn costs about 117 sec, which means a "penalty" of 77 sec for using the Big-Inn instead of the Tavern. I was bold enough to assume this is a bug and submitted a correction in my branch topple-sounds-4. With this correction in place, the penalty to use the Big-Inn is only 10 sec against the Tavern and 5 sec against the Inn.

If we look closer to what causes this problem, we find that the following script element the Snack

            "return=skipped unless economy needs snack",
            "sleep=35000",
            "consume=barbarians_bread fish,meat beer",
            "produce=snack"

contains an unconditional sleep phase of 35 sec before evaluation takes place whether a complex production can take place resource-wise. This is the culprit!

- "return=skipped unless economy needs snack" returns immediately when there is no need for the product.
- "consume=barbarians_bread fish,meat beer" also returns immediately when there is not enough resources.
- the "sleep=35000" runs as a penalty

If the script is modified in the following way, the problem disappears, leaving only that amount of "misfit production site" penalty which was planned for, in this case 5 seconds.

            "return=skipped unless economy needs snack",
            "sleep=5000",  
            "consume=barbarians_bread fish,meat beer",
            "sleep=30000",
            "produce=snack"


If "consume" returns it breaks the entire procedure, hence the longer sleep time is omitted.

== Activity ==
I have supplied amendments for the Taverns, Inns and Big-Inns in my branch topple-sounds-4. Similar enhancements can - and I think: should - be applied to the Smelting-Works and various Weapon-Smithies (if they are multi-production-sites). I can prepare a branch for this in short time since I actually tested this in a private "data" version already. It works good! The question for the penalty, if there should be one and if yes, how high, is left to lead. ;) So when I get a "Go" from you here, I can do more about it!

What is left-over is the statistics for the production sites. E.g. if a smelting-works is running full charge with only producing Iron, it still will display only 65 % productivity or so, because of the "false" return from the Gold production cycle. This is bearable, maybe, but in the future one may think of relating productivity values more to time consumption than to production events. Cheers!


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-07-26, 15:28

I fully agree. A site that produces many resources shouldn't be penalized if it only produces one of them. If your big inn is only producing rations because they are all you need, it stands to reason that it would make them at least as fast as the simple tavern.

Since we're here, may I point out that the barbarian inns will use indiscriminately meat, fish or bread to produce a ration, despite meat being extremely abundant for barbarians, while bread being super expensive? I'd rather there was a way to instruct the inns to preferrably use meat or fish to make rations instead of bread. Possibly a command such as "use the resource whose stock is most abundant", which shouldn't be hard to code and should do the trick.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-07-26, 17:49

I agree on both points.


Busy indexing nil values

Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2016-07-27, 17:06

king_of_nowhere wrote:

I fully agree. A site that produces many resources shouldn't be penalized if it only produces one of them. If your big inn is only producing rations because they are all you need, it stands to reason that it would make them at least as fast as the simple tavern.

I also agree with the improvement!

Since we're here, may I point out that the barbarian inns will use indiscriminately meat, fish or bread to produce a ration, despite meat being extremely abundant for barbarians, while bread being super expensive? I'd rather there was a way to instruct the inns to preferrably use meat or fish to make rations instead of bread. Possibly a command such as "use the resource whose stock is most abundant", which shouldn't be hard to code and should do the trick.

I prohibit my buildings to use only meat instead. If I want to add "only some" fish/bread, the solution is to let the building have 1-2 wares at most, and after that you will see that bread is used only in 30-50 % of time (the rest is moving bread from the distance).

This improvement will bring less distance between advanced players and newbies, and I am not sure about improving it.


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

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-07-27, 17:15

Good point - let's just do the sleep times then.


Busy indexing nil values

Top Quote
toptopple
Avatar
Topic Opener
Joined: 2013-10-30, 08:11
Posts: 156
Ranking
At home in WL-forums
Posted at: 2016-07-28, 08:27

I agree with GunChleoc. We must remember this is a game, after all, and it needs to have a strategy depth. Depth means there must be different ways to do things and also bad ones.

king_of_nowhere
If your big inn is only producing rations because they are all you need, it stands to reason that it would make them at least as fast as the simple tavern.


Nicely put, but we may also notice that big companies take for everything much more time than smaller, and Taverns are specialised for rations, so they should make them faster. Strategy depth is also demanding here, so I would suggest to include a penalty in the advanced buildings for less advanced products. This will give players a small advantage for holding all kinds of kitchens at the same time (or alternatively supplying all demanded resources)!

I would slightly increase the penalty in Inns + Big-Inns to 7 sec for Snack and 8 sec for Meal, so that someone using the Big-Inn for Rations COULD suffer a 15 sec penalty (+33 % of Tavern), 8 sec for Snack (+22 % of Inn). The "could" means that this penalty is conditional only takes place when demand for a delayed product is there but not the resources. If the economy doesn't need for a product, it is always skipped neatly.

We could, if you like the idea of penalties, also add an unconditional increase of production times of lower products in higher buildings, say by 15 % per step (and then reduce the conditional penalty a bit). What do you think?

Edited: 2016-07-28, 08:27

Top Quote
toptopple
Avatar
Topic Opener
Joined: 2013-10-30, 08:11
Posts: 156
Ranking
At home in WL-forums
Posted at: 2016-07-28, 08:52

Just submitted my branch topple-production-logic-1. It is about the smelting-works. You may want to check it out!

Description: "Modified the LUA scripts for all races' smelting_works so that the penalty production time for not supplying iron-ore or gold-ore are reduced to 10 seconds for each kind of resource per production run."


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2016-07-28, 12:11

I am not much happy about such changes especially now in feature freeze, because it can affect AI. If it is done for one type of building - OK then, but if you are going to do it for more, further testing and tweaking of AI would be needed.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-07-28, 19:32

This will definitely be something for Build 20, not Build 19 face-wink.png


Busy indexing nil values

Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 01:54
Posts: 351
Ranking
Tribe Member
Posted at: 2016-07-28, 22:38

Keep in mind that going from tavern to inn to big inn are upgrades, not downgrades. The way I see it, it makes more sense for upgrades to make them better at producing lower-level items, not worse.

After all, when you go from a low-level amateur to top-level professional, you become better at making small, quick programs, not worse. The same is true for sketches, short stories, peanut butter & jelly, etc.


Top Quote