empire supply projections and the AI

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

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

empire supply projections and the AI

#1 Post by Dilvish »

For a while I've been thinking of refining the AI's colonization assessment re supply, to reduce or eliminate priority to expanding supply by colonizing just outside of the current supply range, especially if there are armed opponents around.

Morlic just noticed a conflict in some AI code regarding expected values for projected system supply values and committed some changes to address that which prompts some immediate attention to this, so I thought it a good time to open up a discussion both regarding the supply projections and regarding the colonization strategy issue.

Regarding the supply projections, it seems to me that really the underlying code conflict (about whether the system supply value can be greater than zero) stems from some changes that Geoff made while I was occupied with other matters last year and was rather inactive with FO, I don't recall reviewing those changes before and the commit message doesn't mention a PR for me to look for any discussion from the AI team. If there were discussions, it would be great if someone could point me to them. My initial take on reviewing that now is that I would prefer to restore the functionality that Geoff removed rather than take Morlics approach of harmonizing the AI code with the loss of that information. (And it very well could be that at least part of Morlic's commit above was not entirely due to the system supply issue and could still be a useful change, I need to look at it more closely)

On the broader colonization strategy issue, there is certainly some value to expanding the supply reach of the AI empire (potentially puts additional valuable planets within colonization reach), but it can take longer to colonize those peripheral colonies and then of course they are somewhat more exposed to hostile forces. Morlic's system graph analysis will likely be handy in this front, to help distinguish supply expansions towards apparently open territory versus supply expansions towards enemy empires. The latter could of course be still preferred by aggressive AIs if they make a favorable assessment of their strength versus the enemy. Brainstorming on this strategy issue is invited.
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
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: empire supply projections and the AI

#2 Post by Geoff the Medio »

Dilvish wrote:...some changes that Geoff made while I was occupied with other matters last year and was rather inactive with FO, I don't recall reviewing those changes before and the commit message doesn't mention a PR for me to look for any discussion from the AI team. If there were discussions, it would be great if someone could point me to them.
Looks like it was part of: https://github.com/freeorion/freeorion/pull/488

Edit: Just noticed there's a link from the commit page to the pull request:
link to pull request from a commit page on github
link to pull request from a commit page on github
Link_to_PR.png (55.48 KiB) Viewed 6591 times

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

Re: empire supply projections and the AI

#3 Post by MatGB »

I think it needs to depend on when in the game it is and how densely packed the galaxy is in terms of both planets and players.

I tend to select and fill entire systems and expand out, with colonies/outposts at the edges in order to extend supply to make an invasion work, preferably in good otherwise systems.

If there are a lot of planets per system then extending out too fast means you're not filling your home territory quickly, and filling up in a safe central block is by far the most efficient way to be able to outperform other empires. On the other hand, if you hold off invasions for too long then someone with a slightly better start than you can get further ahead. If you're a long way from an opponent then expanding is going to be essential and might as well do it relatively quickly, but if there are opponents very close by then concentrate on immediately defensible systems and capture their planets to get supply links.

I sometimes see an AI sending outposters way out into opposing territory to grab small or tiny worlds without any military backup, knowing that there was effectively a bug and larger worlds were being discounted far too much makes that clearer and I hope it reduces but any territorial expansion, especially into enemy supply areas needs a strong military presence else you might as well be giving them a gift, I certainly treat it as such (when I can figure out where they're going, sometimes it's really unclear).

Getting the AI to be able to defend its supply lines when there's a conflict is another thing that needs working on, possibly alongside this, but slower expansion of colonised territory except during an invasion makes sense compared to what they do now.
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: empire supply projections and the AI

#4 Post by Dilvish »

Geoff the Medio wrote:Looks like it was part of: https://github.com/freeorion/freeorion/pull/488
Edit: Just noticed there's a link from the commit page to the pull request:
Link_to_PR.png
Thanks, I had checked Morlic's recent commit and looked for new PR about it, but forgot to check to see if he had just opened up an issue without a PR.
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: 296
Joined: Tue Feb 17, 2015 11:54 am

Re: empire supply projections and the AI

#5 Post by Morlic »

Dilvish wrote: If there were discussions, it would be great if someone could point me to them. My initial take on reviewing that now is that I would prefer to restore the functionality that Geoff removed rather than take Morlics approach of harmonizing the AI code with the loss of that information. (And it very well could be that at least part of Morlic's commit above was not entirely due to the system supply issue and could still be a useful change, I need to look at it more closely)
As I wrote in the Github issue I created along with the fix, I think the best way to fix the problem mention is to rewrite empire.supplyProjections() to calculate values greater than zero as it did before.

Note that the fix I pushed is independent of that bug: What I fixed concerns a projected negative planet supply meter which is wrong regardless of what system we use to calculate the extent of the AI's supply lines.
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: empire supply projections and the AI

#6 Post by Dilvish »

Morlic wrote:Note that the fix I pushed is independent of that bug: What I fixed concerns a projected negative planet supply meter which is wrong regardless of what system we use to calculate the extent of the AI's supply lines.
The actual functional code change portion of what you pushed was a good bug correction, yes, it's really just the comments portion about system supply, which I read as calling for that portion of the code to made consistent with system supply always being <=0, which I objected to. But perhaps you just intended them to generally flag the inconsistency, and regardless, some interim comments don't matter much, so let's just sort out how we want to fix it (about which it sounds like we are in agreement on the broad strokes, and I think the finer details would benefit from some more debate anyways).
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: 296
Joined: Tue Feb 17, 2015 11:54 am

Re: empire supply projections and the AI

#7 Post by Morlic »

Evaluation of expanding outside of (current) supply is a tricky topic as there are so many considerations. I think the following things should at the very least be considered:

1) The number and value of currently colonizable planets
2) The number and value of colonizable planets we could "unlock" by expanding the supply
3) The "position" of the systems - are we moving towards an enemy, some unknown part of the universe or some already explored deadend?
4) The time of the game

For the first two points, it may make sense to do two passes for planet evaluation. At first, the "base value" for all planets are calculated. We then know the currently colonizable planets. In the next step, we check which of the currently non-colonizable planets (i.e. planets outside supply even after colonization) are unlocked by each planet. The supply score is then based upon the value of unlocked planets compared to currently possible targets.
There should be some incentives to push into unknown territory (using outposts) if there is no chance for colonization around (and/or trigger research of the next growth tech / exobots).

As far as point 3 is concerned, my graph analysis branch already classifies the "inner" (i.e. assumed to be safe) systems compared to (potentially) dangerous outer systems which are connected to either enemy or unknown systems.

For point 4 I'm thinking something like comparing the number of universe.systemIDs with the actual number of systems by game setup divided by the number of players. That allows some estimate to how likely it is to meet another player when moving into unknown territory.
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