Currently Online

Latest Posts

Topic: main roads becoming normal again

Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-15, 07:26

Do we talk about the same thing? Unused roads should be downgraded so that carrier2 can be sent elsewhere... this is what I mean and agree with


Top Quote
ypopezios
Avatar
Joined: 2018-04-19, 23:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-15, 18:51

GunChleoc wrote:

Please check carefully that I haven't accidentally changed the semantics of the algorithm.

Your changes seem safe. The LAST_DIRECTION stuff sounds like a poor choice, but I'm not sure. What I know is what I want to do, and that is to simply iterate over the 6 roads of the flag (i.e. "for each road in roads").

GunChleoc wrote:

There is also a NOCOM question in there that needs resolving.

kMaxWallet (which in turn is based on kAnimalPrice) should be the same constant across the whole codebase, so as if we later decide to change the finetuning of the algorithm, to not have to look for it in more than one place.

GunChleoc wrote:

In trunk, no roads were demoted. In this branch, the road that I sent wares across was eventually demoted. Unused roads are never demoted in either version, but I guess that's a problem for another day?

The old algorithm demotes a road only after at least 150 wares pass comfortably through it. That can mean many hours of idle animal and the demotion may finally happen right when the road is about to get busy again, which is very bad timing. The new algorithm demotes a road on the first ware that passes after a long enough time (a newly promoted road needs 2.5 minutes of full idleness to risk demotion, while a fully busy road needs 12.5 minutes of full idleness). To properly handle that issue, one should wake up non-empty wallets after some time to charge them and check for demotion. This should be very easy to be done by someone familiar with the scheduling system.


Top Quote
ypopezios
Avatar
Joined: 2018-04-19, 23:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-15, 20:30

Concerning manual influence of the promotion, here is a half-serious idea: Instead of giving the ability to immediately promote a road (which people have strongly opposing opinions about, a fair compromise would be to) rather provide control over the sensitivity of an empire's promotion/demotion system (whether through an increase/decrease pair of buttons or a simpler two-value on/off switch). When the player sets the empire to high sensitivity, it will charge and reward all wallets in bigger amounts of coins, resulting both in faster promotions for high-traffic roads and faster demotions for low-traffic roads. That way, advanced players will have the option to accelerate the promotion of a new high-traffic road, while risking their economy having animals going back and forth their roads like in a badly tuned system (and if we go the increase/decrease option, we could gather experience to find the average optimal value for AI and novice players). This is simple to implement and could get easily enabled/disabled per scenario.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-05-15, 23:57

ypopezios wrote:

WorldSavior wrote:

Why again is the wallet not only a new metaphor for grade of business?

The wallet metaphor is used only to help us come with a better model (let's say the wallet model). That model is superior in various ways:

  • Simplifies the understanding (the familiar money concepts are easier to reason with than abstract concepts).

  • Simplifies the calculations (there is no more need for guessing the right value of various factors).

  • By achieving the above, it opens up new options for enhancing the game, in ways which were previously too complicated to consider (it can actually get expanded to solve almost all logistical problems in Widelands).

  • In the given case of road promotion/demotion, the old model had no way of achieving the precision of the new model, and it even misbehaved under some circumstances.

WorldSavior wrote:

Are my questions not detailed enough?

For the specific questions I just indicated that I possess further details to cover them in depth, which I could share if a question indicated deep enough interest on the matter. So far I rarely get such questions, I mostly get concerns (too many of them, as unfortunately people focus much more on the problems than on the solutions). But meanwhile we have reached the point where people can test a working branch and witness the improvements for themselves.

Okay...

ypopezios wrote:

This time I also played whole scenarios to see promotions/demotions in real conditions. They both work as expected and much better than the old algorithm. No issue found. The code is ready for review and merge, and it is safe even for build 20.

That frees me to contribute in other things. I'm open to suggestions. I'm generally more interested in algorithms (promotion/demotion has been a good example). Suggestions from Tibor get priority, for obvious reasons.

Would you have fun at improving the Artificial Intelligence? I could imagine that algorithms could play a very important role there. This task just requires good knowledge about Widelands, or someone with good knowledge who can help.


Wanted to save the world, then I got widetracked

Top Quote
einstein13
Avatar
Joined: 2013-07-28, 23:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2018-05-16, 00:32

ypopezios wrote:

Concerning manual influence of the promotion, here is a half-serious idea: (...) provide control over the sensitivity of an empire's promotion/demotion system (...)

I am strongly against this solution. Because it doesn't solve the problem of immediate promotions. It makes people ability to change the mechanics, which is even more complicated. If you don't understand the basic mechanic, changing it can cause terrible problems.

Please explain me, why people have doubts about micromanagement of roads? I understand that in 95% of cases it would be useless and I understand that most of the players will never use the feature (no idea how it works or no needs), but except that I don't know why.


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, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-05-16, 07:04

Tibor wrote:

Do we talk about the same thing? Unused roads should be downgraded so that carrier2 can be sent elsewhere... this is what I mean and agree with

That's what I meant too. At the moment, the algorithm to change the state is only triggered when ware is carried.

ypopezios wrote:

To properly handle that issue, one should wake up non-empty wallets after some time to charge them and check for demotion. This should be very easy to be done by someone familiar with the scheduling system.

Maybe we can add some code to the carriers' "idle" task to fix this?

ETA: found it

ypopezios wrote:

The LAST_DIRECTION stuff sounds like a poor choice, but I'm not sure. What I know is what I want to do, and that is to simply iterate over the 6 roads of the flag (i.e. "for each road in roads").

6 means "iterate over 6 directions". LAST_DIRECTION means "iterate over all directions" - this makes the code safer, and also instantly tells whoever reads the code why it is 6.

ypopezios wrote:

kMaxWallet (which in turn is based on kAnimalPrice) should be the same constant across the whole codebase, so as if we later decide to change the finetuning of the algorithm, to not have to look for it in more than one place.

OK, I have put that in the Road struct and will push a new version once it has finished compiling.

ETA: Pushed

Edited: 2018-05-16, 08:51

Busy indexing nil values

Top Quote
ypopezios
Avatar
Joined: 2018-04-19, 23:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-16, 11:09

GunChleoc wrote:

Maybe we can add some code to the carriers' "idle" task to fix this?

ETA: found it

If there is an "idle" task, your code could work. But I have the impression that idle carriers become fully "taskless" on line 111:

return skip_act();  //  wait until signal

I would like to replace it with something like this:

// subtract maintenance cost and check for road demotion
road.charge_wallet(game);
if (road.wallet() > 0) {
  return schedule_act(game, road.time_before_bankruptcy());
} else {
  return skip_act(); // wait until signal
}

where time_before_bankruptcy is something like wallet_ / carriers_count(). But I don't know the mechanics behind schedule_act.


Top Quote
ypopezios
Avatar
Joined: 2018-04-19, 23:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-16, 12:13

einstein13 wrote:

Please explain me, why people have doubts about micromanagement of roads?

Having read arguments for and against micromanagement in many threads of this forum, I'm afraid that there is no safe way to answer that without triggering another round of fruitless quarrel. The other time I had opened the window of choosing a new building for a position. But when I made my choice, it didn't work. I found out that meanwhile a forester had just planted a sapling right on that position. At that moment I wished for all kinds of fun buttons (undo forester's last action, unroot sapling, burn sapling, dismantle sapling, call woodcutter, promote sapling to tree, etc.) Then I reminded myself that this is a strategy game and moved on to deal with some strategic issues instead, where the real fun is. Don't spend your time telling me how much that example differs from road promotion. Just try to stick to the similarities and you may get my point.

WorldSavior wrote:

Would you have fun at improving the Artificial Intelligence? I could imagine that algorithms could play a very important role there.

That's a well-advised suggestion (although I would expect Tibor to make it first). Still teaching the AI to deal with the shortcomings of Widelands is less productive than freeing Widelands from those shortcomings. Therefore, the logical first step would be to improve Widelands' models, creating a more AI-friendly environment in the process.

GunChleoc wrote:

For finding interesting problems, try the economy tag

Many of those problems are caused by the problematic economy model and need to be solved from the ground up.

GunChleoc wrote:

Maybe you could work together with Einstein on this one: https://wl.widelands.org/forum/topic/4245/?page=3#post-24907

and

einstein13 wrote:

@ypopezios
As I have mentioned in other topic, reworking the finding route algorithm needs some simplification for CPU. Do you want to take on that?

From my point of view it is a huge part of work.

This is indeed a huge part of a huge work for huge improvements. We have to break it into smaller parts. Introducing the wallet model was one of them. Another one is the introduction of communication between neighboring nodes (primarily flags). There are many kinds of messages that could go back and forth flags, so we need to focus on just a few of them at a time. An easy case should be swapping routes between identical wares about to cross the same road from opposite directions. I think that I'll pick this one for my next contribution (of course in a separate thread).

ETA: What would be the right subforum to start such a thread in?

Edited: 2018-05-16, 14:30

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-16, 12:51

WorldSavior wrote:

Would you have fun at improving the Artificial Intelligence? I could imagine that algorithms could play a very important role there.

That's a well-advised suggestion (although I would expect Tibor to make it first). Still teaching the AI to deal with the shortcomings of Widelands is less productive than freeing Widelands from those shortcomings. Therefore, the logical first step would be to improve Widelands' models, creating a more AI-friendly environment in the process.

Yes, this is also an option, f.e. roading, as ypopezios already has some experiences in this area...


Top Quote
einstein13
Avatar
Joined: 2013-07-28, 23:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2018-05-16, 15:27

ypopezios,

I got your point of strategy game/ micromanagement. I agree that we can say that "this is a feature, not a bug" in both directions (you about your idea of Widelands roads and me about my idea). I will not argue any more here. Maybe I will do a contribution one day for that and it will be solved from my perspective face-grin.png .

About the other topic (routing wares & CPU usage): I will be glad to talk a bit and making some blueprints. But maybe not another forum. Rather another topic. Or several topics with one main topic. Probably wiki page can be added too. If we want to make a simple patch - simple one topic. But if you are going to rebuild whole system (like me), we will need proper way of communication.


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

Top Quote