AI bad decisions and near defeat issues

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
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

AI bad decisions and near defeat issues

#1 Post by MatGB »

Two observations on the AI building making decisions.

1) Shipyards are, according to the design description, supposed to be not built everywhere, but the AI builds them on close to every shipbuilding planet, including multiple shipyards for the same species in the same system. This includes Xenocoordination facilities &c. If possible, I'd set a limit on a species getting a shipyard depending on friendly/same species having one within X jumps—4 or 5 would probably be about right?

In the very early game, AIs are basically wasting resources on developing every system, making them weaker against attack, etc. Plus, when you do invade, completeing the invasion is easier as every system can build troop ships, etc very early.

2) An AI close to defeat desperately tries to rebuild lost important buildings even when completely pointless. One of my strategies is to go in and grab all shipbuilding worlds first, especiallt the capital if possible-Volp are an awesome workhorse world but they can't build ships, they're not a threat. If an AI loses all its shipbuilding worlds, it tries to build shipyards for species that can't build ships. It also builds imperial palaces, industrial centres, solar orbital generators, etc when they've been lost, when building a few more warships would possibly help turn the tide and let them regain lost systems.

Re the excess shipyards, maybe simply not let shipyards be built on planets that can't build ships? This would help newer players (and my flaky memory) as well as stopping the AI from wasting points.

Re the other issues, one thing I quite liked about MOO was the way near defeat AIs would sometimes surrender, either to the player or, more frequently, to another nearby AI. I suspect that's not currently possible, but is it worth thinking longer term? Or, perhaps, if all shipbuilding worlds are defeated the remnants, obviously former independent natives, should perhaps revert to independent status?

(Dilvish, I have a savegame with a Volp world trying to build shipyards and a palace if you need it LMK)
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: AI bad decisions and near defeat issues

#2 Post by Dilvish »

MatGB wrote:...shipyards...
The main check for shipyards just tries to have a calculated number of shipyards per colonizing race, starting at 1 and going up 1 per every hundred turns. In addition to the capitol provision mentioned below, there is also a new-ish clause which is probably causing problems, meant to ensure shipyards on the planets with better pilots, that one is probably causing the overbuilding, I'll fiddle with it some more.

2) An AI close to defeat desperately tries to rebuild lost important buildings even when completely pointless.
yes, many times that's the case. The idea is that it chooses a new capitol and tries to rebuild. If the new capitol is good enough and far away enough from the original it has a chance. An empire in this situation is likely a goner, though, so I haven't deemed it worthwhile putting a lot of time into trying to fine-tune a comeback-from-the-brink strategy. That's for someday farther down the road.
If an AI loses all its shipbuilding worlds, it tries to build shipyards for species that can't build ships. Re the excess shipyards, maybe simply not let shipyards be built on planets that can't build ships?
My algorithm for choosing a new capitol had overlooked shipbuilding & just went with highest population. I haven't had time to test it yet, but attached is a modified file to have it prefer colonizers, and then any other shipbuilding species, before considering a new capitol someplace that can't even build ships.
(Dilvish, I have a savegame with a Volp world trying to build shipyards and a palace if you need it LMK)
Sure, send it to me or post it. If the new palace is already built or even under construction I think it will take a few more mods to be able to test out this new code, so don't expect to see a difference yourself from this new code on that savegame you have. But I'll be able to make it work as a test.
Attachments
PlanetUtilsAI.py.zip
(1.53 KiB) Downloaded 46 times
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: AI bad decisions and near defeat issues

#3 Post by MatGB »

Dilvish wrote:
MatGB wrote:...shipyards...
The main check for shipyards just tries to have a calculated number of shipyards per colonizing race, starting at 1 and going up 1 per every hundred turns. In addition to the capitol provision mentioned below, there is also a new-ish clause which is probably causing problems, meant to ensure shipyards on the planets with better pilots, that one is probably causing the overbuilding, I'll fiddle with it some more.
It was seeing three Mu Ursh in the same system that got me specifically looking for it, but clarifying-if the AI has a shipbuilding native acquired in, say, turn 90 and colonises a nearby planet does that mean at turn 100 that planet should get a shipyard currently, or is it 100 turns after conquest of that species?
many times that's the case. The idea is that it chooses a new capitol and tries to rebuild. If the new capitol is good enough and far away enough from the original it has a chance. An empire in this situation is likely a goner, though, so I haven't deemed it worthwhile putting a lot of time into trying to fine-tune a comeback-from-the-brink strategy. That's for someday farther down the road.
Makes sense, that's sort of why I had the other suggestions, a "surrender" option for an AI that's basically dead might be easier to setup and make the game a bit better? Mopping up a completed enemy is something I find dull at the best of times.
My algorithm for choosing a new capitol had overlooked shipbuilding & just went with highest population. I haven't had time to test it yet, but attached is a modified file to have it prefer colonizers, and then any other shipbuilding species, before considering a new capitol someplace that can't even build ships.
(Dilvish, I have a savegame with a Volp world trying to build shipyards and a palace if you need it LMK)
Sure, send it to me or post it. If the new palace is already built or even under construction I think it will take a few more mods to be able to test out this new code, so don't expect to see a difference yourself from this new code on that savegame you have. But I'll be able to make it work as a test.
Attached, it's Zwicky up in the top right (Orange AI), I had saved the games for a different issue, a colony ship that was thrown away down on the bottom left but I decided it wasn't a terrible decision after I plyaed a few more turns (armed colony ships can be annoying in different circs afterall).
Mat Bowles

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

Hihoo
Space Kraken
Posts: 142
Joined: Wed Oct 23, 2013 8:50 am

Re: AI bad decisions and near defeat issues

#4 Post by Hihoo »

In the very early game, AIs are basically wasting resources on developing every system, making them weaker against attack
There are very different "good or bad" strategies in the very early game, depending on many factors, the size of the universe one of the most important.

a) Pushing colonization is GOOD if no opponents are nearby or your opponents meanwhile prepare for your early attack which doesn't come. Later in the game your superior resources will prevail easily against their outdated armadas.

If your opponents are far away and play the same strategy, its even obviously.

b) Too much colonizing is BAD if your nearby opponents start an early attack of course, taking your brand new cities without thank you.

if you play very aggressively very early, you run the risk of producing ships
just for the recycler, if your opponents are not nearby and can afford to push research and growth for some time. You won't easily catch up with them later.
Invasion troops are a rather time-resistant commodity now, but easy targets, even with escorts.

you can gamble on some unwary independents being nearby by building troop-ships very early.
then again, if there are none, colony ships would have been the better choice.

etc etc mostly self-evident. the point is know your situation, and if you don't, be prepared to change horses in midstream.

Generally speaking, gathering information cheaply very early is a good thing in most cases.

Consequently, the strong AI is able to play different default starting strategies, and choose one at random, the old civilization game being a good example

I agree with dilvish that it matters little for now what AI's do when nearly defeated.
Keep the player busy I guess and let the remaining AI's get their far systems easily maybe?

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

Re: AI bad decisions and near defeat issues

#5 Post by Dilvish »

Matt, thanks for that testfile; After having the AI throw out the under-construction Imperial Palace at Zwicky, I was able to confirm that the modified file above does cause the AI to choose a better planet to be its new capitol (it chose a Laenfa planet Messier, a few jumps above Zwicky).
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: AI bad decisions and near defeat issues

#6 Post by MatGB »

No worries mate, the AI is so much better now than it was when I first got it working (I started playing before Python was included, thinking "this'll be great when they've built an AI"), anything we can do to tweak it to make it a bit better, even at edge case positions, is good, so thanks for the work you've put in.
Mat Bowles

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

Post Reply