Page 1 of 2

Weird AI behavior (keeps depopulating own planet)

Posted: Fri Jun 23, 2017 1:23 pm
by Jaumito
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 2006 times
Also, this:
planets.png
planets.png (42.82 KiB) Viewed 2006 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?

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Fri Jun 23, 2017 5:03 pm
by Morlic
[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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Fri Jun 23, 2017 7:42 pm
by Jaumito
Done.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sat Jun 24, 2017 2:23 am
by MatGB
Other option is misusing Concentration Camps?

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sat Jun 24, 2017 7:43 am
by Jaumito
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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sat Jun 24, 2017 10:01 am
by MatGB
Could be Trith or Eaxaw, both species start with it

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sat Jun 24, 2017 2:39 pm
by Oberlus
Does AI logs inform you of the species of the AI?

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sun Jun 25, 2017 12:24 am
by Jaumito
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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sun Jun 25, 2017 8:52 am
by MatGB
That's weird, it's maybe not got the phototrophic calculation right for a dim/no star system?

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sun Jun 25, 2017 10:00 am
by Morlic
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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sun Jun 25, 2017 11:02 am
by Morlic

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Sun Jun 25, 2017 4:04 pm
by Vezzra
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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Wed Jun 28, 2017 12:41 am
by Dilvish
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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Wed Jun 28, 2017 7:56 am
by MatGB
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.

Re: Weird AI behavior (keeps depopulating own planet)

Posted: Wed Jun 28, 2017 6:10 pm
by Morlic
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.