AI weird behaviours

AI development

Moderators: Grummel7, Committer

Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: AI weird behaviours

#16 Post by Oberlus »

I am spotting an AI's tendency to stockpile PPs in excess.
I'm on a SP game. AIs began stockpiling lots of PP around turn 70-80, at an average rate of around +20 PP per turn. By turn 100 they have between 150 and 550 PP in the stockpile.
One AI is Sly, it has 400 PP in the stockpile and produces 100 PP per turn. The one with 550 PP is also producing 100 PP per turn and is the one with the strongest army. The empires with less stockpile are also the ones with less industry output.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: AI weird behaviours

#17 Post by Ophiuchus »

Probably they dont know how to use stockpile and had some disconnected planets?

Low hanging fruits would be: Teaching them disconnected stockpile use (e.g. allow stockpile use on all projects, put disconnected projects in front of the queue) and how to increase stockpile use (e.g. if there is already a meaningful stockpile, prioritize stockpile techs a bit and if there is a big stockpile e.g. >300PP go for the stockpiling center).

More involved: make them use stockpile focus if necessary (e.g. if part of empire got disconnected)

Even more involved: teach them to use stockpile strategically (e.g. planning on building GGG on disconnected planets).
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: AI weird behaviours

#18 Post by Grummel7 »

Oberlus wrote: Fri Sep 02, 2022 9:18 am I'm on a SP game. AIs began stockpiling lots of PP around turn 70-80, at an average rate of around +20 PP per turn. By turn 100 they have between 150 and 550 PP in the stockpile.
One AI is Sly, it has 400 PP in the stockpile and produces 100 PP per turn. The one with 550 PP is also producing 100 PP per turn and is the one with the strongest army. The empires with less stockpile are also the ones with less industry output.
Could you attach a log file?

The AI does know how to use stockpile and it normally does use it. I doubt that it does use it strategically.

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: AI weird behaviours

#19 Post by LienRag »

I noticed on a test game (with the last version, the one tested in MP) that the AI keeps sending troops on my planets even when they have a structure that is lower than the amount of damage that is done by my mines.
So, none of these troops ever touched land...

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: AI weird behaviours

#20 Post by Oberlus »

Grummel7 wrote: Sat Sep 03, 2022 6:29 pm Could you attach a log file?
I didn't have the logs.
I reloaded autosave from turn 2 and let it autoturn for 100 turns. The behaviour reproduced. I attach logs and save files. Version 000f16 with PR #4113.

Then I started a multiplayer game with six AIs, same version, and let them play for 200 turns, but none of them ever got more than a few turns of stockpile extraction limit, and only temporarily. So the behaviour didn't repeat.

I let you do the forensics :)
Attachments
player_and_server_logs_and_saves.7z
(1.54 MiB) Downloaded 64 times
AI_logs.7z
(5.09 MiB) Downloaded 65 times

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: AI weird behaviours

#21 Post by Grummel7 »

That's really odd.

As far as I can make it out, the AI is using stockpile:

Code: Select all

Production Queue Turn 104 after ProductionAI calls
==============================================================================================================
| Object                  | Location                   | Quantity | Progress     | Allocated PP | Turns left |
==============================================================================================================
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II>  | 1x 1     | 0.0 / 45.9   | 11.5         | 4          |
| BLD_TRANSLATOR          | P_3591<Skat I>             | 1x 1     | 86.6 / 288.7 | 28.9         | 7          |
| DY Nemesis Mk. 1        | P_3101<Mannaz β I>         | 1x 1     | 0.0 / 157.1  | 52.4         | 3          |
| DY Nemesis Mk. 1        | P_3094<Mannaz β Asteroids> | 1x 1     | 0.0 / 157.1  | 40.9         | 4          |
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II>  | 1x 1     | 0.0 / 45.9   | 0.0          | 7          |
--------------------------------------------------------------------------------------------------------------

Production Queue Turn 105 before ProductionAI calls
===============================================================================================================
| Object                  | Location                   | Quantity | Progress      | Allocated PP | Turns left |
===============================================================================================================
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II>  | 1x 1     | 11.8 / 47.2   | 11.8         | 3          |
| BLD_TRANSLATOR          | P_3591<Skat I>             | 1x 1     | 100.0 / 250.0 | 25.0         | 6          |
| DY Nemesis Mk. 1        | P_3101<Mannaz β I>         | 1x 1     | 53.9 / 161.6  | 53.9         | 2          |
| DY Nemesis Mk. 1        | P_3094<Mannaz β Asteroids> | 1x 1     | 53.9 / 161.6  | 46.2         | 3          |
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II>  | 1x 1     | 11.8 / 47.2   | 0.0          | 5          |
---------------------------------------------------------------------------------------------------------------
AI_3 had a production of 111, which would have been almost used up by the two Nemesis alone.
Still its stockpile keeps growing every turn.

Doesn't look like an AI issue.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: AI weird behaviours

#22 Post by Ophiuchus »

Grummel7 wrote: Sun Sep 04, 2022 8:44 pm AI_3 had a production of 111, which would have been almost used up by the two Nemesis alone.
how many supply networks and stockpile extraction did it have? Hm maybe I'm confused. The numbers show that they spend more PP than the industry production you stated. So the stockpile must/should decrease regardless of networks and stockpile extraction limit.

Also, the allocated PP on the translator did not work (so probably in a different supply group). There are ~15PP missing (29PP max and allocated, only 13.6 PP spent). Actually it got cheaper, so maybe only ~11PP missing (not sure/depending on effect evaluation order). Total PP in the projects is 87 in turn 104, 232 in turn 105, so actually 145PP were spent which is still 35PP too much.

One explanation: the real industry is actually higher than the allocated one, the PP spent on heavy troopers could mean the project was fully sponsored, so there could be PP transfer to the stockpile
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: AI weird behaviours

#23 Post by Grummel7 »

Ophiuchus wrote: Tue Sep 06, 2022 8:50 am how many supply networks and stockpile extraction did it have? Hm maybe I'm confused. The numbers show that they spend more PP than the industry production you stated. So the stockpile must/should decrease regardless of networks and stockpile extraction limit.

Also, the allocated PP on the translator did not work (so probably in a different supply group). There are ~15PP missing (29PP max and allocated, only 13.6 PP spent). Actually it got cheaper, so maybe only ~11PP missing (not sure/depending on effect evaluation order). Total PP in the projects is 87 in turn 104, 232 in turn 105, so actually 145PP were spent which is still 35PP too much.
The empire was completely connected and had many Sly, so it had a big stockpile use limit.

The numbers in the queue are okay. They are confusing because the games accounts build progress as percentage of completion, not as spent PP. Here 28.9 PP were spent for one step of the Translator, bringing it to 4/10. Next turn the cost decreased to 25 per step, so 4/10 were shown as 100 PP. Perhaps the table should be changed to displaying percentages, but it's only AI debug output after all.

Still, the AI had 111 PP, predicted to spend 133 PP, actually got 156 PP and while the stockpile grew...

Perhaps I should put this into a GitHub issue.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: AI weird behaviours

#24 Post by Ophiuchus »

Grummel7 wrote: Tue Sep 06, 2022 8:24 pm The empire was completely connected and had many Sly, so it had a big stockpile use limit.
the freeoriond.log sais empire 3 has two supply groups, with system 987 being isolated
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: AI weird behaviours

#25 Post by Grummel7 »

Ophiuchus wrote: Wed Sep 07, 2022 12:00 pm the freeoriond.log sais empire 3 has two supply groups, with system 987 being isolated
AI_3 is empire 4.

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: AI weird behaviours

#26 Post by Grummel7 »

I have an explanation for the AI behaviour, though I do not what's causing it:

Just loaded the turn 102 save game and advanced one turn.
Now this is what I see in the AI-log and the server-log:

Code: Select all

Production Queue Turn 102 after ProductionAI calls
=============================================================================================================
| Object                  | Location                  | Quantity | Progress     | Allocated PP | Turns left |
=============================================================================================================
| DY Scout Mk. 1          | P_3087<Royal Mannaz β II> | 1x 1     | 7.6 / 15.3   | 3.8          | 2          |
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II> | 1x 1     | 22.9 / 45.9  | 11.5         | 2          |
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II> | 1x 1     | 22.9 / 45.9  | 11.5         | 2          |
| DY Heavy Troopers Mk. 2 | P_3087<Royal Mannaz β II> | 1x 1     | 22.9 / 45.9  | 11.5         | 2          |
| Organic Outpost Ship    | P_3087<Royal Mannaz β II> | 1x 1     | 70.7 / 106.1 | 35.4         | 1          |
| BLD_TRANSLATOR          | P_3591<Skat I>            | 1x 1     | 25.0 / 250.0 | 25.0         | 9          |
| DY Nemesis Mk. 1        | P_3101<Mannaz β I>        | 1x 1     | 52.4 / 157.1 | 30.6         | 3          |
-------------------------------------------------------------------------------------------------------------


Empire.cpp:2174 : ========Empire::CheckProductionProgress=======
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_SHIP name: DY Scout Mk. 1 id: 13077) (1) x1  (remaining: 1)  uuid:>
Empire.cpp:2232 :    allocated: 2.2935
Empire.cpp:2233 :    initial progress: 0.5
Empire.cpp:2239 :    updated progress: 0.75
Empire.cpp:2240 :  
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_SHIP name: DY Heavy Troopers Mk. 2 id: 13544) (1) x1  (remaining: >
Empire.cpp:2232 :    allocated: 6.8805
Empire.cpp:2233 :    initial progress: 0.5
Empire.cpp:2239 :    updated progress: 0.75
Empire.cpp:2240 :  
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_SHIP name: DY Heavy Troopers Mk. 2 id: 13544) (1) x1  (remaining: >
Empire.cpp:2232 :    allocated: 6.8805
Empire.cpp:2233 :    initial progress: 0.5
Empire.cpp:2239 :    updated progress: 0.75
Empire.cpp:2240 :  
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_SHIP name: DY Heavy Troopers Mk. 2 id: 13544) (1) x1  (remaining: >
Empire.cpp:2232 :    allocated: 6.8805
Empire.cpp:2233 :    initial progress: 0.5
Empire.cpp:2239 :    updated progress: 0.75
Empire.cpp:2240 :  
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_SHIP name: Organic Outpost Ship id: 42) (1) x1  (remaining: 1)  uu>
Empire.cpp:2232 :    allocated: 21.224
Empire.cpp:2233 :    initial progress: 0.666667
Empire.cpp:2239 :    updated progress: 1
Empire.cpp:2240 :  
Empire.cpp:2334 : Completed an item: Organic Outpost Ship
Empire.cpp:2462 : New Ship, id 19562, created on turn: 102
Empire.cpp:2483 : Marking completed production queue item to be removed from queue
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_BUILDING name: BLD_TRANSLATOR) (1) x1  (remaining: 1)  uuid: 897e7>
Empire.cpp:2232 :    allocated: 15
Empire.cpp:2233 :    initial progress: 0.1
Empire.cpp:2239 :    updated progress: 0.2
Empire.cpp:2240 :  
Empire.cpp:2231 : elem: ProductionQueue::Element (ProductionItem: BT_SHIP name: DY Nemesis Mk. 1 id: 14395) (1) x1  (remaining: 1)  uui>
Empire.cpp:2232 :    allocated: 31.414
Empire.cpp:2233 :    initial progress: 0.333333
Empire.cpp:2239 :    updated progress: 0.666667
The server calculates with much lower costs than the AI!
In fact it looks like the servers value are all exactly 60% of the costs, the AI gets.

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: AI weird behaviours

#27 Post by Oberlus »

Grummel7 wrote: Wed Sep 07, 2022 5:30 pm I have an explanation for the AI behaviour, though I do not what's causing it:

The server calculates with much lower costs than the AI!
In fact it looks like the servers value are all exactly 60% of the costs, the AI gets.
Hmmm... Could this have anything to do with the game being started with a FO version and continued with a different one? (I don't remember if I really did that with that saved game.)
If there was a change in the cost factor game rules, the server updated it correctly but the AIs keep playing with values stored in the save file, then something like the above could happen. Does it make sense?

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: AI weird behaviours

#28 Post by Grummel7 »

Oberlus wrote: Wed Sep 07, 2022 5:38 pm Hmmm... Could this have anything to do with the game being started with a FO version and continued with a different one? (I don't remember if I really did that with that saved game.)
If there was a change in the cost factor game rules, the server updated it correctly but the AIs keep playing with values stored in the save file, then something like the above could happen. Does it make sense?
Actually it is much simpler, I can reproduce it now: Start a game with e.g. with all cost factors (part, hull, building) set to 0.2 and the AI will stockpile from the beginning.

It seems that the AI-client is simply not aware of the cost factor rules.

I'll create a GitHub issue.

quarague
Space Floater
Posts: 31
Joined: Thu Jan 05, 2023 8:00 pm

Re: AI weird behaviours

#29 Post by quarague »

Playing 0.4.10 with AIs on manical (ie maximal) aggression mode.

I noticed that the AI tends to almost cease all attacking of planets once my empire (according to the total production/ total research etc charts) is sufficiently stronger then theirs.

The most dramatic case was where I conquered an AIs capital. There were two other planets still colonized by the AI in the system and a few more systems around it. One turn later the AI fleet showed up and obliterated my attack fleet. The AI fleet contained a number of troop ships, easily sufficient to reconquer their home planet. I did not have any other fleets strong enough to defeat the AI fleet in orbit. I expected the AI would just retake their capital but it did not. They just stayed in orbit and waited for some 20 turns until I had build another fleet and conquered the rest of the system.

My tech and my production were much higher than the AIs so it might be a reasonable assessment that I would eventually come back and defeat the AI but just defending and waiting for this to happen seems a sure defeat strategy.

I observed this in other games as well, if my empire is ahead in production/ research the AIs will stop trying to conquer my planets. In some cases they might take back a planet I conquered from them but they will never try to take planets I colonized first. They just sit there with a massive fleet next to my planets that their fleet could easily conquer and wait for many turns until I have patiently build my own fleet to defeat theirs.

User avatar
drkosy
Space Dragon
Posts: 367
Joined: Sat Jul 11, 2020 9:41 am

Re: AI weird behaviours

#30 Post by drkosy »

I have other weird behaviours in one game:
One AI put a colony ship in the middle of my empire with several planets to colonize but it just stopped in an empty system and doesn't do anything. (see screenshot 2)
Another AI sends ships to Soror Alpha (see screenshot 1) even if the passage is blocked by a monster that eats up the ship.

Edit: The scout got to Soror while 2 warships attacked the monster.

Version is 0.5+ build 2022-12-22
Attachments
Bad-AI2.jpg
Bad-AI2.jpg (252.15 KiB) Viewed 1187 times
Bad-AI1.jpg
Bad-AI1.jpg (350.6 KiB) Viewed 1187 times
Want some fresh experience? Try Kosymod

Post Reply