Important Dates

Currently Online

Latest Posts

Topic: main roads becoming normal again

Tibor
Joined: 2009-03-23, 23:24
Posts: 1317
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-23, 21:35

I think there are two questions:

  • Is presented branch an improvement?
  • Is ypopezios willing to implement further changes?

If the aswers are YES and NO, I would vote for merging it


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1317
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-23, 21:44

hessenfarmer wrote: Currently AI is evaluating the need to build a building and afterwards tries to link all buildings by roads.

Exactly. AI but knows about buildings in vicinity (f.e. count of supporting/supported buildings, perhaps mines or space consumers) but even if it knows the number, it has no idea about actual layout (position).

E.e. when placing lumberjack, how could AI cope with information, there is one ranger in SE direction - in distance 5 fields and another one WWN - 6 fields away?

So it now only knows:

there are 2 rangers in vicinity up to 6 fields and 12 trees in vicinity up to 6 fields. Again - it has no sense of actual layout.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1131
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2018-05-23, 22:34

Tibor wrote:

I think there are two questions:

  • Is presented branch an improvement?

which branch do you refer to?

  • Is ypopezios willing to implement further changes?

If the aswers are YES and NO, I would vote for merging it

that doesn't prevent any future improvements my thoughts were more generally spoken


Top Quote
ypopezios
Avatar
Joined: 2018-04-20, 00:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-24, 02:21

WorldSavior wrote:

I hope that the official Widelands will be always as complex as it is now (approximately), so in this case one has to improve the AI instead of changing the game, if one wants to get a better AI.

Fear is a bad adviser. Current AI failures are not because of complexity, but because Widelands was developed without AI in mind (kind like AI was a luxury to have). I guess that was a choice of coding complexity at the time, not an effort to achieve a specific complexity-level for the human players. In any case, if for any reason the process of improving AI-friendliness affects game's complexity, adjusting it is much much easier than improving the AI. And I have zero hope that anyone will ever bother improving the AI as long as the material to work with is unfriendly (coding C++ is already unfriendly enough).

WorldSavior wrote:

I would be very interested if you could give some examples. I don't see how you could free Widelands from such shortcomings without changing the game too much.

I have to save that for another thread.

WorldSavior wrote:

Maybe it would make a lot of sense to teach the AI a clever road system for maps with perfect building ground, like in this description here: https://wl.widelands.org/forum/topic/2834/?page=1#post-19815

Teaching the AI with predefined patterns (like openings in chess) is not intelligent at all (try changing chessboard's shape or starting positions of pieces and most chess-bots will make dumb moves), so I won't go that direction. Moreover, Widelands is a strategy game, not a tycoon, thus perfect building grounds are rare (as well as boring).


Top Quote
ypopezios
Avatar
Joined: 2018-04-20, 00:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-24, 03:19

Tibor wrote:

I think there are two questions:

  • Is presented branch an improvement?

That's an easy one. The implementation of the new algorithm in the presented branch is an improvement in every single scenario. Not because it is particularly smart (it isn't, it just uses a better model), but because the old algorithm is particularly inefficient. However, the change which broke compilation is certainly a step back.

Tibor wrote:

  • Is ypopezios willing to implement further changes?

Generally, he is. But those will need more familiarity with the codebase and may take some time to reach there, during which he'll probably focus on other issues.

Tibor wrote:

If the aswers are YES and NO, I would vote for merging it

Apart from the setback mentioned earlier, I have already voted for merging (therefore, the votes so far are 2-1 for merging). And if that counts at all, merging would be quite a motivation boost (expectedly enough, not merging would have the opposite effect). To further help things, I have some news to share: After many hours of troubleshooting, I now have a dedicated virtual machine which successfully compiled Widelands a few times (that was excruciating, since Widelands' code is way more intermixed than necessary, so small changes often lead to recompilation of many files). Let's hope that it will provide some wares to Widelands' economy.

GunChleoc wrote:

Then, you could try fixing this yourself - it's probably just a missing include somewhere

In my understanding, includes are not related to that. And messing with the code at structure level would be dangerous for my current level of involvement (I wouldn't really be fully aware of the consequences of such changes). I don't think that it's a big deal to go back to separate constants and leave a comment for future unification (like in revision 8683). After all, the old algorithm used plain numbers instead. Let's make a favour to the codebase and free it from some old and dirty code.


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1317
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-24, 08:34

I am glad to hear that now you can compile the game by yourselves.

What I dont agree with is opinion that the engine of game itself is some complication for writing the AI. Also C++ is not that bad, because performance matters here. But what would help is multithreading in the game, f.e. make AI's parallel.


Top Quote
ypopezios
Avatar
Joined: 2018-04-20, 00:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-24, 10:02

Tibor wrote:

What I dont agree with is opinion that the engine of game itself is some complication for writing the AI. Also C++ is not that bad, because performance matters here. But what would help is multithreading in the game, f.e. make AI's parallel.

Adding multithreading is like adding better hardware, i.e. a mere relief to the problem, not an actual solution. Moreoever, multithreading favors functional programming, while Widelands' codebase is mostly object-oriented, and C++ is not particularly designed for multithreading. More importantly, AI is mostly high-level stuff (its DNA part is not), while C++ is mostly a low-level language. Programming the AI in C++ is like programming the graphics in Assembly. Having to think about pointers is something that some other languages' compilers can figure out, for the programmer to focus on logic. My point was that C++ repels many programmers. Like the low quality codebase repels all programmers. Likewise, current engine repels AI programmers. The first point won't change, so that part of the discussion is fruitless. The other two points have plenty of room for improvements.

At the moment it seems that making routing static will boost performance more than any other improvement (but this is for another thread). However, routing is just one aspect. An overall better engine has also the potential of increasing the AI's awareness of what is going on in the empire, to take more informed decisions and do less guesswork. And a log of such decisions can provide the AI programmer with useful feedback for future improvements. Now such things are close to impossible. All in all, when I say that AI-friendliness is an issue, I'm not saying something counter-intuitive. Still we live in the beginning of AI age and most people (even programmers) don't grasp the involved concepts. Therefore, I don't expect an early agreement on my approach. I just want to assure you that this is not a mere opinion, it is a well-supported theory.


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1317
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-24, 10:15

It this it can be viable to make AI parallel, because AI does 2 things when it "thinks":

  • reads state on the map
  • issues orders that are queued and executed later by engine

So it makes no changes to the map by itself.

AI itself does not use pointers and references extensively, so it friendly also to people who are not deeply familiar with them...

As usual: deliver something and we will see and understand better what you mean


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 1477
Ranking
One Elder of Players
Location: North of Germany
Posted at: 2018-05-24, 19:36

hessenfarmer wrote:

WorldSavior wrote:

I hope that the official Widelands will be always as complex as it is now (approximately), so in this case one has to improve the AI instead of changing the game, if one wants to get a better AI.

I fully aggree to this. However the Ai thing is complicated. I think Tibors effort to implement a generic algorithm solution is good for tuning the values in the algorithms. But the algorithms and the models need to be working efficiently as well. This is leading to two possible fields of work to improve the AI. Problem might be that after an algorithm change the training is set back to a state worse than already achieved, but some weaknesses in algorithms only appear after Ai has been trained sufficiently. Short story having a look in the AI algorithms might be a good idea to identify any weaknesses.

You're right

Therefore, the logical first step would be to improve Widelands' models, creating a more AI-friendly environment in the process.

How?

Maybe it would make a lot of sense to teach the AI a clever road system for maps with perfect building ground, like in this description here: https://wl.widelands.org/forum/topic/2834/?page=1#post-19815

Problem is that an algorithm of road building should be working for all maps. The suggestion in the discussion as far as I understand is to first build a road system then build the buildings.

Not necessarily. The AI could also just build buildings at "correct" places and then it could link the buildings in the "correct" way...

Currently AI is evaluating the need to build a building and afterwards tries to link all buildings by roads. So the change would rather be big and can't be tested easily.

... so this is not necessarily the case.

ypopezios wrote:

WorldSavior wrote:

I hope that the official Widelands will be always as complex as it is now (approximately), so in this case one has to improve the AI instead of changing the game, if one wants to get a better AI.

Fear is a bad adviser.

?

Current AI failures are not because of complexity, but because Widelands was developed without AI in mind (kind like AI was a luxury to have). I guess that was a choice of coding complexity at the time, not an effort to achieve a specific complexity-level for the human players. In any case, if for any reason the process of improving AI-friendliness affects game's complexity, adjusting it is much much easier than improving the AI. And I have zero hope that anyone will ever bother improving the AI as long as the material to work with is unfriendly (coding C++ is already unfriendly enough).

Actually Tibor is already improving the AI.

So the "shortcomings of Widelands which make it hard to improve the AI" are not in the gameplay, but only in the code?

I know just one shortcoming: Soldiers are able to conquer hostile military buildings, while it would be better if they could only destroy them...

WorldSavior wrote:

I would be very interested if you could give some examples. I don't see how you could free Widelands from such shortcomings without changing the game too much.

I have to save that for another thread.

You could just open it...

WorldSavior wrote:

Maybe it would make a lot of sense to teach the AI a clever road system for maps with perfect building ground, like in this description here: https://wl.widelands.org/forum/topic/2834/?page=1#post-19815

Teaching the AI with predefined patterns (like openings in chess) is not intelligent at all (try changing chessboard's shape or starting positions of pieces and most chess-bots will make dumb moves), so I won't go that direction.

What would be better?

And would it really not be an improvement to teach the AI the mentioned road system? It's much better on perfect building ground than the stuff which is the AI doing there right now.

Moreover, Widelands is a strategy game, not a tycoon, thus perfect building grounds are rare (as well as boring).

No, they are not boring, but amazing. Suboptimal building grounds are annoying. Furthermore one can invent road systems for them as well, and road systems of perfect building ground can also be used at suboptimal ground as well - to a certain degree.


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

Top Quote
ypopezios
Avatar
Joined: 2018-04-20, 00:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-24, 20:35

WorldSavior wrote:

Actually Tibor is already improving the AI.

Despite Tibor's hard efforts, the weak AI remains one of the biggest weaknesses of Widelands.

WorldSavior wrote:

So the "shortcomings of Widelands which make it hard to improve the AI" are not in the gameplay, but only in the code?

The shortcomings are primarily in the models used in the code.

WorldSavior wrote:

I know just one shortcoming: Soldiers are able to conquer hostile military buildings, while it would be better if they could only destroy them...

And would it really not be an improvement to teach the AI the mentioned road system? It's much better on perfect building ground than the stuff which is the AI doing there right now.

Seems that you mentioned two shortcomings here. I could fill a whole page of shortcomings myself. But don't even ask about it, cause I won't do it. If the AI ever reaches a decent level, then it would make sense to make a list of remaining shortcomings for future improvements.

WorldSavior wrote:

No, they are not boring, but amazing. Suboptimal building grounds are annoying. Furthermore one can invent road systems for them as well, and road systems of perfect building ground can also be used at suboptimal ground as well - to a certain degree.

It is great that Widelands provides something which you find amazing. That's one of the advantages of its open-ended design. It is not in my own interests though. Fortunately, Widelands supports maps of amazing variety (or annoyance if you prefer). And those are the ones where the AI fails the most.

WorldSavior wrote:

ypopezios wrote:

Teaching the AI with predefined patterns (like openings in chess) is not intelligent at all (try changing chessboard's shape or starting positions of pieces and most chess-bots will make dumb moves), so I won't go that direction.

What would be better?

Obviously to teach the AI how to make the most out of whatever is available to it at any given time, similarly to what intelligent humans do.

WorldSavior wrote:

You could just open it...

Really? I don't know how I missed that... Until I do, let's try keeping current thread on topic please.


Top Quote