Weird AI behavior (keeps depopulating own planet)

Describe your experience with the latest version of FreeOrion to help us improve it.
Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Message
Author
Jaumito
Space Kraken
Posts: 116
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Weird AI behavior (keeps depopulating own planet)

#1 Post by Jaumito » Fri Jun 23, 2017 1:23 pm

FreeOrion_v0.4.7_2017-04-24.60d06dc, Linux (cmake) build.

This is something I can't find an explanation for.

The game was a testbed of sorts, I wanted to see how fast and far the AI could expand if left on its own with plenty of room to play with. So I picked 3 maniacals AI in an absurdly large universe (4000 systems IIRC), low planets, low starlanes. Turns out it was a bad idea, I've since learned that those aren't the preferred AI settings by far, but anyway I'm not here to discuss this.

To the point: since the beginning of the game (now at turn 200), Blue AI keeps colonizing/losing a planet. I can only assume it's always the same planet, since I haven't met any AI yet. Here's the 'Colonies' graph (bottom only, sorry - I had to stretch the window over several workspaces for the behavior to be noticeable.)
colonies.png
colonies.png (11.04 KiB) Viewed 400 times
Also, this:
planets.png
planets.png (42.82 KiB) Viewed 400 times
So, what could cause the AI to do this, and why so regularly? Could there be a bug in the code where the AI evaluates whether a planet is inhabitable or not? Something else?

Morlic
AI Contributor
Posts: 238
Joined: Tue Feb 17, 2015 11:54 am

Re: Weird AI behavior (keeps depopulating own planet)

#2 Post by Morlic » Fri Jun 23, 2017 5:03 pm

[quote="Jaumito"]
So, what could cause the AI to do this, and why so regularly? Could there be a bug in the code where the AI evaluates whether a planet is inhabitable or not? [quote]

Could be. Please post savegames and the AI logs so we can figure it out instead of doing random guesses.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Jaumito
Space Kraken
Posts: 116
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: Weird AI behavior (keeps depopulating own planet)

#3 Post by Jaumito » Fri Jun 23, 2017 7:42 pm

Done.
Attachments
AI_3.log
(154.47 KiB) Downloaded 6 times
AI_2.log
(158.48 KiB) Downloaded 7 times
AI_1.log
(188.21 KiB) Downloaded 8 times

[The extension sav has been deactivated and can no longer be displayed.]


User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Weird AI behavior (keeps depopulating own planet)

#4 Post by MatGB » Sat Jun 24, 2017 2:23 am

Other option is misusing Concentration Camps?
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Jaumito
Space Kraken
Posts: 116
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: Weird AI behavior (keeps depopulating own planet)

#5 Post by Jaumito » Sat Jun 24, 2017 7:43 am

MatGB wrote:Other option is misusing Concentration Camps?
It's been happening since the very early game (about turn 20-30, I'd say), so unlikely. Unless the AI gets Concentration Camps tech for free.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Weird AI behavior (keeps depopulating own planet)

#6 Post by MatGB » Sat Jun 24, 2017 10:01 am

Could be Trith or Eaxaw, both species start with it
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Oberlus
Vacuum Dragon
Posts: 669
Joined: Mon Apr 10, 2017 4:25 pm

Re: Weird AI behavior (keeps depopulating own planet)

#7 Post by Oberlus » Sat Jun 24, 2017 2:39 pm

Does AI logs inform you of the species of the AI?

Jaumito
Space Kraken
Posts: 116
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: Weird AI behavior (keeps depopulating own planet)

#8 Post by Jaumito » Sun Jun 25, 2017 12:24 am

Oberlus wrote:Does AI logs inform you of the species of the AI?
Just checked, and you're right. Although there's indeed a Trith AI, it's actually a Laenfa (AI #3) that seems to have problems with depopulation - its in-log Empire name ("Union") matches the in-game Blue AI's.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Weird AI behavior (keeps depopulating own planet)

#9 Post by MatGB » Sun Jun 25, 2017 8:52 am

That's weird, it's maybe not got the phototrophic calculation right for a dim/no star system?
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Morlic
AI Contributor
Posts: 238
Joined: Tue Feb 17, 2015 11:54 am

Re: Weird AI behavior (keeps depopulating own planet)

#10 Post by Morlic » Sun Jun 25, 2017 10:00 am

The planet in question (if you load the game as multiplayer and select the Union empire for a human player) is Maretta II:

- Medium Swamp for Laenfa (Adequate)
- Blue star
- Temporal anomaly special
(- irrelevant Resonant moon special)


The suitability report is completely broken (see screenshot)


The AI makes at least 2 calculation mistakes:

1) Phototrophic bonus is applied ignoring the condition that it requires a target population > 0.
2) GRO_PLANET_ECOL has an effect after population

I am working on a fix.
Attachments
PlanetSuitabilityBug.png
PlanetSuitabilityBug.png (90.63 KiB) Viewed 310 times
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Morlic
AI Contributor
Posts: 238
Joined: Tue Feb 17, 2015 11:54 am

Re: Weird AI behavior (keeps depopulating own planet)

#11 Post by Morlic » Sun Jun 25, 2017 11:02 am

If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 4609
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Weird AI behavior (keeps depopulating own planet)

#12 Post by Vezzra » Sun Jun 25, 2017 4:04 pm

Morlic wrote:Hopefully fixed in master:
I assume that only applies to the broken AI calculations, so the suitability report is still broken, right? In this case an issue about that should be opened.

User avatar
Dilvish
AI Lead, Programmer
Posts: 4686
Joined: Sat Sep 22, 2012 6:25 pm

Re: Weird AI behavior (keeps depopulating own planet)

#13 Post by Dilvish » Wed Jun 28, 2017 12:41 am

Morlic wrote:The suitability report is completely broken (see screenshot)
In the past I had noticed that the suitability report seems to go similarly broken (overestimating max pop for all species) on the actual turn that a planet became either apparently-depopulated or actually-depopulated via Evacuation, but never got around to tracking down just why. (Partly because that situation is relatively rare, and there is also some funny handling that makes the species icon be removed and the pop show as zero apparently one turn prior to it actually hitting zero and being totally converted to an outpost, destroying the Evac building before it autodestructs can allow the species to return).

It looks like this may be related, when the planet has a low enough pop that for some purposes it is getting treated like an outpost, but the pop is actually nonzero, then the projections wind up off. It reminds me of some trouble we had a while back in trying to get the projections accurate since some of the effects are gated by the target pop already being above zero, I think we had to make some sort of two-step process to get the projection right, but perhaps that is still being thrown off if the current pop is between zero and one.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Weird AI behavior (keeps depopulating own planet)

#14 Post by MatGB » Wed Jun 28, 2017 7:56 am

Dilvish wrote:
Morlic wrote:The suitability report is completely broken (see screenshot)
In the past I had noticed that the suitability report seems to go similarly broken (overestimating max pop for all species) on the actual turn that a planet became either apparently-depopulated or actually-depopulated via Evacuation, but never got around to tracking down just why.
That, we think, was fixed, it became more important with the Ancient Guardians as you tend to do a suitability report on the turn you capture them
Numbers in planet suitability report are wrong on the turn right after a planet has been depopulated · Issue #979 · freeorion/freeorion
It looks like this may be related, when the planet has a low enough pop that for some purposes it is getting treated like an outpost, but the pop is actually nonzero, then the projections wind up off. It reminds me of some trouble we had a while back in trying to get the projections accurate since some of the effects are gated by the target pop already being above zero, I think we had to make some sort of two-step process to get the projection right, but perhaps that is still being thrown off if the current pop is between zero and one.
I think the best approach is to remove such gates to population, they apply weirdly depending on timing anyway and it would be better to balance things differently, if you can live underground you can live underground, etc. I did take several out when I did the effects priority for population boosts but I almost certainly missed some.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Morlic
AI Contributor
Posts: 238
Joined: Tue Feb 17, 2015 11:54 am

Re: Weird AI behavior (keeps depopulating own planet)

#15 Post by Morlic » Wed Jun 28, 2017 6:10 pm

Vezzra wrote:
Morlic wrote:Hopefully fixed in master:
I assume that only applies to the broken AI calculations, so the suitability report is still broken, right? In this case an issue about that should be opened.
Done.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply