Bad colonisation strategy for AI?

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

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.
Post Reply
Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Bad colonisation strategy for AI?

#1 Post by Oberlus »

Playing 0.4.7 RC2.

So far so good. I noticed some of the bugs reported for RC1 have been corrected (the others, if any, I bet are also corrected, it's just I didn't look for them).

To the point: I found some unprofitable colonisation strategy for one of my AI neighbours in my current game.

Pale blue AI, Trith, at turn 147 has:
- Simbiotic Biology.
- Subterranean Habitation.
And obviously self-sustaining. I guess that allows it to colonise poor planets, right?

The following systems were under its control (until I kick in in turn 145).

Carina y:
- Medium Ocean (unoccupied).
- Tiny radiated with Philosopher Planet (colonised with exobots).
- Asteroids (exobot colony under construction).
- Small Inferno (colonised with exobots).

Carina a:
- Medium Radiated (unoccupied).
- Small Barren (unoccupied).
- Medium Radiated with Ambient Superconductors (unoccupied).
- Gas Giant (unoccupied).

Lomadia:
- Tiny Ocean (outpost with Scanning Facility finished).
- Medium Radiated with Ambient Superconductors (inhabited by Ancient Guardians)
- Small Terran with Ki Spice (unoccupied).
- Asteriods (unoccupied).

Mentar b:
- Medium Inferno (exobot colony under construction).
- Asteriods (unoccupied).

Mentar a:
- Tiny Ocean with Eccentric Orbit (unoccupied).
- Large Desert (Trith capital).

Why has the AI not colonised the Small Terran in Lomadia with Trith and the Radiated and Barren planets in Carina a with exobots but has colonised the further away Philosopher planet in Carina y? It seems to be like a very bad planning. The Lomadia system was visible from my systems under Trith control since (not sure) turn 50 or 100.
Am I missing something or the AI here is playing a bit dumb? Having only 7 planets at turn 145 (half of them with under construction exobot colonies) while my Egassem have 48 planets, but I'm the only direct neighbour of it and I know for sure that no one has attacked that AI.
Attachments
Trith_AI_bad_colonisation.jpg
Trith_AI_bad_colonisation.jpg (54.88 KiB) Viewed 1880 times

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

Re: Bad colonisation strategy for AI?

#2 Post by Dilvish »

Oberlus wrote:Pale blue AI, Trith, at turn 147 has:
- Simbiotic Biology.
- Subterranean Habitation.
And obviously self-sustaining. I guess that allows it to colonise poor planets, right?
No, I don't believe it does. Trith have Narrow environmental tolerance, so they go directly from Good to Poor, and then Self Sustaining just doubles the environmental adjustment. So their Good instead of +3*PlanetSize is +6*PlanetSize, but for them Poor planets are -4*PlanetSize rather than the normal -2. So with their techs you cite it looks to me like they would still be at -2*PlanetSize for terran planets.

It looks to me like they would have to get all they way up to Xeno Hybridization before they could colonize anything other than Good Planets. Or perhaps I'm doing my calcs wrong? I don't recall that really being talked about back when a critical change was made in PR#44. Does anyone here play Trith much? What tech does it take to colonize Terran with them?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: Bad colonisation strategy for AI?

#3 Post by dbenage-cx »

Trith can colonize poor planets(Terran, Tundra) from the start(Small is +2.0). They start with desert (small = +12.0), only access to the 3 until xenological genetics(just before hybridization).

(Edit: That is assuming no other species nearby, special malus for xenophobic self-sustaining species)
Last edited by dbenage-cx on Wed Apr 26, 2017 8:43 am, edited 1 time in total.
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.

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

Re: Bad colonisation strategy for AI?

#4 Post by Oberlus »

Dilvish wrote:Self Sustaining just doubles the environmental adjustment. So their Good instead of +3*PlanetSize is +6*PlanetSize, but for them Poor planets are -4*PlanetSize rather than the normal -2.
Hmm. I've tried to find that double adjustment in the github to no avail. I've used for the searches "target.sizeasdouble", "self-sustaining", "SetTargetPopulation" and "xenophobic".
In the end, I've checked this files:
- default/scripting/species/common/population.macros
- default/scripting/species/common/xenophobic.macros
- default/scripting/species/common/env.macros
- default/scripting/species/SP_TRITH.focs.txt
- all the population affecting techs in default/scripting/techs/*/<TECHS>.focs.txt

The ENVIRONMENT_MODIFIER macro in population.macros does not take into account self-sustaining.
The SELF_SUSTAINING_BONUS macro does this:
effects = SetTargetPopulation value = Value + 3 * Target.SizeAsDouble // Gets the same bonus as three growth specials

I can't find any place where it does 2.0*Value (after the environment effects) or sth like that.
I guess I'm not missing any file, judging by dbenage-cx answer.

Anyway, I think Self-sustaining should be able to colonise poor planets from the start, otherwise they would be really fucked up.

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

Re: Bad colonisation strategy for AI?

#5 Post by MatGB »

Actually...

I remember now I introduced a minor bug in self-sustaining when I did the prioritisation ages ago and while we discussed it we never agreed which way to go with it: self sustaining now allows you to colonise really early but that wasn't my intent when I made the change, we considered trying to gatekeep it in some way or instead have them not get some tech bonuses that other species do: the latter is my preferred but it wasn't something we agreed on and it basically got forgotten.

The change was to make sure that self sustaining worked as described (ie the equivalent of all three growth specials) and at the same priority time (ie after Good/Bad Population), but doing this meant it now worked after and regardless of the Habitation bonus/penalty.

So yeah, Trith AIs think they can't live places they actually can, because we never decided which way to jump on what they should be able to do and thus the AI wasn't updated.
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
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Bad colonisation strategy for AI?

#6 Post by Oberlus »

MatGB wrote:So yeah, Trith AIs think they can't live places they actually can, because we never decided which way to jump on what they should be able to do and thus the AI wasn't updated.
Shouldn't the AI consider for colonisation just the actual (current) population limit that we human players see when we check it in the UI?

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

Re: Bad colonisation strategy for AI?

#7 Post by MatGB »

Have you noticed how long those reports take to generate? They're one of the biggest individual lag things for me. The AI client does its own calculation based on numbers in the python scripts, and while theoretically the numbers haven't actually been changed, because we changed what order they're calculated it does make a substantial difference.

I don't actually do AI stuff, I'm just about capable of editing a datafile with numbers in if someone checks it, and the Pedia suitability reports are also beyond my comprehension: I can change the numbers that feed into them but not how they're worked out.

So while it would be ideal for the AI to get the same info we do that's not currently the case (although I believe it's a long term goal for them to be able to query the database directly)
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
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Bad colonisation strategy for AI?

#8 Post by Oberlus »

MatGB wrote:python scripts
Ah, I found them. I'll have a look and see if I understand them, or learn some python.

Edit: I guess it would be enough to comment out the lines 59 to 61 in ColonisationAI.py to get the same values than we get from population.macros.
Should I learn GitHub and commit that?

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

Re: Bad colonisation strategy for AI?

#9 Post by Morlic »

Please always add the savegame and the relevant AI log file when making a report regarding the AI behavior. It cuts down the time to fix a bug by approximately a factor of 100 on average.
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
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Bad colonisation strategy for AI?

#10 Post by Oberlus »

Morlic wrote:Please always add the savegame and the relevant AI log file when making a report regarding the AI behavior.
For the case on this thread, I have a save game from when I noticed the weird behaviour of Trith, but I already started another game.
Some questions about that:
- If I save a game and exit FO and on next sesion I reload that saved game, will AI logs keep all the information from previous turns or I should make copies of every log each time I exit FO to be sure I don't lose any relevant information for a possible undiscovered bug?
- If I was playing a different game and then load a different saved game, will AI logs keep all the information from previous turns?
Morlic wrote:It cuts down the time to fix a bug by approximately a factor of 100 on average.
Yeah, with a p-value>0.01 ;)

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

Re: Bad colonisation strategy for AI?

#11 Post by Morlic »

Oberlus wrote:
Morlic wrote:Please always add the savegame and the relevant AI log file when making a report regarding the AI behavior.
For the case on this thread, I have a save game from when I noticed the weird behaviour of Trith, but I already started another game.
That savegame would be good to have and useful.
- If I save a game and exit FO and on next sesion I reload that saved game, will AI logs keep all the information from previous turns or I should make copies of every log each time I exit FO to be sure I don't lose any relevant information for a possible undiscovered bug?
The AI logs are generally overwritten and the previous information is lost. Still, having a log file with the most recent turns can often be useful as the AI calculates and logs many information each turn. Of course, if the weird behavior is rooted only in calculations of previous turns and would be fine in later turns, logs are less useful but that is usually only known in hindsight.

If you want to go through the trouble of copying files when playtesting, that could help but it is certainly not expected from you.
- If I was playing a different game and then load a different saved game, will AI logs keep all the information from previous turns?
Doesn't matter, same behavior as above.
Morlic wrote:It cuts down the time to fix a bug by approximately a factor of 100 on average.
Yeah, with a p-value>0.01 ;)
I am actually serious. There were bugs in the past that were immediately obvious when looking at the log but that would have required hours of looking through the code to find because they are hiding in not-so-obvious places. There were bugs that required a very specific game situation to occur which is therefore hard/impossible to reproduce in a reasonable time.

Having a savegame additionally means I can immediately check any possible fixes instead of starting some hundreds of games hoping that there is a similar game situation which occurs and then work from there or guessing what a bug might be and then randomly push it to master and hope it helps.

The factor of 100 is a rather conservative estimate if you compare "fix that takes 10 minutes" vs "can't reproduce, will randomly fix in a year when working on some other thing".
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
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Bad colonisation strategy for AI?

#12 Post by Oberlus »

I attach the save game. Although it seems it won't be necessary for the the described issue since it was already known by MatGB, nor useful in any way to inmediatly test the appropriateness of a given solution since the "wrong-doing" must have happened since turn 1 and the save game is turn 145.

Thanks for the info about AI logs. From now on I'll only play games with concrete seeds for the random generator so that I can replay the whole game in case I find something weird that would need older than last-turn AI logs (or maybe the game save does store the used seed?).
Morlic wrote:I am actually serious.
I know, and I know you are right in an hyperbolic way. In fact, I've already attached logs and saves on other bug reports. My pedantic statement was to make you sure I was understanding you, despite of your lengthy way to say "a lot", but no offence intended.

Best.
Attachments

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


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

Re: Bad colonisation strategy for AI?

#13 Post by Dilvish »

dbenage-cx wrote:Trith can colonize poor planets(Terran, Tundra) from the start(Small is +2.0).
AH, ok thanks. I see now that when I had traced back to see when the requirement of TargetPop >= 0 disappeared, I forgot that along the way the adjustment had changed from a doubling of current target to an addition of 3* planetsize.
Oberlus wrote:I guess it would be enough to comment out the lines 59 to 61 in ColonisationAI.py to get the same values than we get from population.macros.
Should I learn GitHub and commit that?
That would not be the right change to make, no. I'll take care of this particular change. It would be great for you to learn git and GitHub, though, and you could propose changes for things in the future. Be sure to read up on our GitHub process do's and don'ts in the programming forums.
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
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Bad colonisation strategy for AI?

#14 Post by Oberlus »

Thank you, Dilvish. I'm already reading some git and GitHub stuff, I hope to be helpful in the future.

Post Reply