Latest Posts

Topic: Regression: Empire Ai failure

WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 2091
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-05-07, 20:05

Tibor wrote:

Are you sure you mean AI as Computer Player?

Sorry, I don't understand that?

AI does not manipulate the target for soldiers, should it? In my experimental branch it just stops/starts the barracks...

As I said, it would be better, if the economy settings for soldiers would concern only untrained soldiers. In that case, the AI doesn't need to manipulate that settings, or only in a case when it makes sense to recruit a lot of new soldiers (for example if barbarians start close to an enemy and close to iron, coal and so on).

And in case noone changes the implementation of economy settings for soldiers: I think the AI should manipulate the settings. Otherwise it would reach the maximum of soldiers after some time instead of going on to train more soldiers. That wouldn't make sense in a lot of autocrat-matches

GunChleoc wrote:

I had a look at the first savegame. There are 48 soldiers sitting in the warehouses, so that the Barracks won't do anything is correct - we have plenty soldiers.

The reason that none of them are in the training site is that they already have all the Arena upgrades. If you take over the player and enhance the Arena to a Colloseum, the soldiers start moving there immediately.

So it's exactly how I guessed face-smile.png

So, this has nothing whatsoever to do with how soldiers are produced and upgraded; there must be something else that keeps the AI from expanding.

Are you sure? If the economy settings for soldiers only concern untrained soldiers, the barracks will "produce" on and on, if a trainingssite is working... So the AI would increase the military power on and on.

But you are right at that thing: Sometimes the AI stops to expand for no reason, and that's a problem face-wink.png


Wanted to save the world, then I got widetracked

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-07, 21:17

GunChleoc wrote:

I had a look at the first savegame. There are 48 soldiers sitting in the warehouses, so that the Barracks won't do anything is correct - we have plenty soldiers.

The reason that none of them are in the training site is that they already have all the Arena upgrades. If you take over the player and enhance the Arena to a Colloseum, the soldiers start moving there immediately.

So, this has nothing whatsoever to do with how soldiers are produced and upgraded; there must be something else that keeps the AI from expanding.

I am not able to investigate the player (how can I open the savegame and see the player's buildings?), but another possibilities are:

  • too many military constructionsites
  • no free spots nearby the border to place new militarysites...

But generally there can be some mathematical error under the hood that is hard to track down...


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-07, 21:20

By my opinion, manipulating with barracks and changing soldiers target are very similar approaches, the bottom line is that AI should decide that "I dont/need new soldiers", once the decision is made it is only implementation detail...

Stopping barracks is equal setting the soldier target o 0, starting barracks is equal to setting target to 10 or so...


Top Quote
PkK

Topic Opener
Joined: 2012-01-06, 12:19
Posts: 236
Ranking
Widelands-Forum-Junkie
Posted at: 2017-05-07, 21:30

Tibor wrote: I am not able to investigate the player (how can I open the savegame and see the player's buildings?), but another possibilities are:

  • too many military constructionsites
  • no free spots nearby the border to place new militarysites...

But generally there can be some mathematical error under the hood that is hard to track down...

There are no construction sites. There is plenty of space. Most of the buildings that are there are not producing, since the economy doesn't need whatever could be produced. Being a trade outpost also helps against shortages. It just looks like the AI is content with the situation. It seems to have no further needs or wants.

Philipp (who doesn't know how to look at the other player in the savegame either, and thus uses the replay as a workaround).

P.S.: Though I always assumed that the AI wants upgraded soldiers, but here not even the arena has been upgraded. Maybe the large number of low-level soldiers it has is sufficient to satisfy the AIs desire for security.

Edited: 2017-05-07, 21:32

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-07, 21:49

PkK wrote:

Tibor wrote: I am not able to investigate the player (how can I open the savegame and see the player's buildings?), but another possibilities are:

  • too many military constructionsites
  • no free spots nearby the border to place new militarysites...

But generally there can be some mathematical error under the hood that is hard to track down...

There are no construction sites. There is plenty of space. Most of the buildings that are there are not producing, since the economy doesn't need whatever could be produced. Being a trade outpost also helps against shortages. It just looks like the AI is content with the situation. It seems to have no further needs or wants.

Philipp (who doesn't know how to look at the other player in the savegame either, and thus uses the replay as a workaround).

P.S.: Though I always assumed that the AI wants upgraded soldiers, but here not even the arena has been upgraded. Maybe the large number of low-level soldiers it has is sufficient to satisfy the AIs desire for security.

AI is stupid. It is pure mathematic. Just a lot of mathematical formulas and if..elfi..else.. structures. And many variables and constants. They are pain to manually create and test, this is why I am working on genetic algorithm based AI...


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2017-05-08, 10:30

At that point in the game, the barracks itself had already decided that the economy doesn't need any more soldiers. No need to have the AI start/stop the barracks at this point, as it can be controlled by the militarysite, trainingsite and economy settings.

I turned the games into multiplayer games for easier testing: https://bugs.launchpad.net/widelands/+bug/1689246


Busy indexing nil values

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-08, 11:06

When AI starts fighting, "stocks" of soldiers are always 0, because there are usually a lot of unoccupied slots in militarysite - then barracks will be creating new soldiers as fast as they can (are stocked). So the soldiers target as long as it is >0 does not make any difference. So my reasoning was, that sometimes AI might want to stop creation of new soldiers and let material (like iron) be used for promotion of soldiers instead. But if AI decide that it would never ever stop the barracks - this will be fine for me.... this is what genetic algorithm should be about.

Of course AI can instead of stopping barracks set target to 0, but at the end this will make no difference....


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-08, 11:24

I looked at the savegame, the AI attempts to build new militarysites beyond the water (as close to enemy as possible), but it cannot create the road there. Also AI does not expand territory if a militarysites close to enemy are needed. So it is stuck there. I dont think there is simple fix (like change of single line in AI or a single constant).


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

Let's ignore this then until the new AI is ready - we might look at the code afterwards to see if we can have a sort or reachability check.


Busy indexing nil values

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-08, 19:34

Reachability check is trivial. But overall picture is: Update_buildable_fields checks about 50 fields at once, every ~7 seconds. It takes the field, scan the vicinity in radius of ~15 fields for various buildings. It counts all it sees (number, size, type of various sites, resources (rock, trees, mines) but does not do reachability check. Because doing it for 50 fields - usually adjacent - would be very CPU intensive and mostly waste of CPU time. What would be needed is some partitioning of area into small pieces (f.e. 5x5) and test reachability among these smaller regions and cache the results. This is general idea, but perhaps sometimes in the future - I mean after next release, if my experimental branch will make it into release...

Edited: 2017-05-08, 19:45

Top Quote