Strategic AI Mod

A place for discussion of making game modifications.
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Tue May 01, 2018 9:17 pm

Update (72fa1cd):

This version of the mod is intended to be used with r22256 or later.

  • The AI now avoids creating attack plans using damaged ships (combat_ship_ordering sorts them last). If an attack plan must include damaged ships due to lack of available undamaged ships, the AI will delay the attack by 1 turn if any of the damaged ships are at a location where they can be repaired.
  • The AI may assign damaged military ships to fallback missions, if they aren't already assigned to any other task.
  • Fixed a typo that affected what mission types civilian ships were allowed to use.
  • Improved AI research desire calculation for the case where the AI is not in contact with any other empire.

With the tactical AI now part of vanilla, it's much more common for the AI to have damaged ships on hand. So it made sense to add some awareness of ship damage at the strategic level. The AI will now prefer to attack and intercept with undamaged ships if it can, and when planning attacks, it may delay one turn to repair ships first.

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Sat May 05, 2018 10:27 am

Insufficient Transport error: probably when Phidi AI tries to move pop

Using Steam DEV branch with latest AI strategy AI mod
Attachments
Orthin Fourth.rar
(229.04 KiB) Downloaded 721 times
Insufficient transports.png
Insufficient transports.png (71.74 KiB) Viewed 20899 times

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Mon May 07, 2018 1:51 am

Hmm, It looks like the error is being produced inside the call to order.set_activity() that sets city planning, so the AI is trying to set city planning when it isn't actually possible to do so.

From the error message, we can see that the reason it isn't possible is because planet.cant_city_plan yields a "true" value. But the call to order.set_activity() is guarded by a call to possibly_set_city_planning(), which in turn calls planet:cant_set_activity('City Planning') which returns planet.cant_city_plan.

So it's not really clear how that is possible...

User avatar
sven
Site Admin
Posts: 1620
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: Strategic AI Mod

Postby sven » Sat May 12, 2018 2:37 am

harpy eagle wrote:So it's not really clear how that is possible...


My bad. PlanetProperty.cant_city_plan was missing logic for the case where we can't city plan on a planet because doing so would cause some *other* planet to starve. Should be fixed as of r37528.

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Wed May 23, 2018 8:52 am

Does the mod still hold any difference between the current vanialla version?

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Fri May 25, 2018 6:22 am

I don't think so.

I did have some variations on the AI strategy cards system sitting around, but I wasn't really satisfied with it, so it was never released.

If sven doesn't get to it first I'd like to someday look into what it might take to implement mercenary hiring for AI Phidi and enslavement for AI Gremak. I actually did some work on the latter a little while back, but the AI seemed to have consistent problems with slave revolts so I shelved it.

I'm probably not going to be doing any serious modding for at least several weeks.

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Fri May 25, 2018 8:35 am

Thanks for the update

I think it is safe to assume that mercanary hiring and ensavement/hqarmonisation will not be touched upon in the near future with the update for diplomacy around the corner and the DLC seemeingly being underway which will surely shake up some of the systems in late game (or at least terraforming)

Merc hiring seems like the lower hanging fruit: if the AI is in war and can afford their upkeep, it should by some :)
More if being overwhelmed by number of ships and less if it has more ships - the logic of which ships to by could of course be tricky but a balanced approach should cover most of the potential scenarios withouth adressing them specifically

Slaves are expected to be more triyk as you have mentioned due to the serious kickback from slaves.
Maybe if the AI would only ensalve/Harmonize if it has the necessary population/force + 30% strength to contain them? This should take care of some other effects to pops down the line such as redistribution of pops to other planets - as long as salve revolts are a rare occurance overall in normal circumstances (no war going on casuing starvation or unrest from other reasons) they are also not an issue but flavor :)

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Fri May 25, 2018 1:31 pm

zolobolo wrote:I think it is safe to assume that mercanary hiring and ensavement/hqarmonisation will not be touched upon in the near future with the update for diplomacy around the corner and the DLC seemeingly being underway which will surely shake up some of the systems in late game (or at least terraforming)

I think so too, but, I'm not sure when I'm going to be getting around to it.

zolobolo wrote:Merc hiring seems like the lower hanging fruit: if the AI is in war and can afford their upkeep, it should by some :)
More if being overwhelmed by number of ships and less if it has more ships - the logic of which ships to by could of course be tricky but a balanced approach should cover most of the potential scenarios withouth adressing them specifically

Getting them to buy mercs should be easy. The critical part will be getting them to rotate out obsolete mercs when they reach their upkeep budget.

Which means 1) determining what their budget should be in the first place. I don't have a good model for how much coin the AI should desire to save up for economic development.

And 2) determining when a ship is idle and not involved in an important offensive or defensive operation. Even if they're obsolete we don't want to scrap ships that could contribute to key battles.

Once those questions have answers the rest should fall into place.

As for enslavement, being to cautious means that the AI never uses the feature. I think what it really needs to do is plan ahead and start building raiders (which build faster than tanks and have a bonus to suppressing revolts) and/or transferring Gremak pop (who have the slavemasters trait) to planets that have populations the AI intends to enslave, and only then enslaving them.

I was able to make the AI react to planets with slave revolts risk by building raiders and transferring slavemasters, but it was always too late and the AI would always lose planets, even in peacetime. It seems some level of pre-planning is necessary.

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Fri May 25, 2018 4:03 pm

The budget of the AI could be tied to the overall income and number of planets
- The more income it has the less the less it should save on the account
- The more planet it has the more it should save on the account
This is so that there is always enough coins available to buy out planetary improvements (and ships) and keep the infrastructure buildup flowing

With mercs: it only really makes sense to by them if the AI is in war due to their high upkeep (overall cost is high and not worth over long period of time). If the AI is running out of coin to maintain existing ships, the most expansive merc ship should be the first to be scrapped due to the above: one merc command cruiser can pay for the upkeep of several faction specific cruisers so no question wthich should stay

Scappring on the other hand should only occur when low on budget so that no important opportunities are lost in battle. S othe rule could be:
1. Buy IF in war AND Budget allows for it
2. Disband IF not in war OR Budget is low

What abouth harmonisation? As they cannot rebell, they can be harmonized withouth penalties (except for the loss of resource yields)
Slavery is a tough nut to crack: can the AI be told to post some Raiders on each planet per default the exact amount of which being dependant on the planet size? Thus they would build 4 Raiders on a medium sized planet and get slaving :) The pre-condition in this case would be the succesfull "buildup" aka: availabilty of Raiders on a spcific planet: if it has reached the level designated for that planet size, all enslavable pops can be enslaved.

Since the AI will not be transporting Raiders anywhere, this mechanic woul take care of potential rebellions on the long term
It could also account for loss of Raider units during bombardments as the AI would recognise that their amount has dropped below target value and produce new ones

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Sat Aug 25, 2018 10:47 am

I think we have a good picture for how mercenary hiring AI would look now, probably something like this:

Budgeting for Mercenaries:
- budget based on coin income vs mercenary upkeep
- reserve a small amount of coin income * number of planets for economy, and of the rest spend no more than half on mercenaries. The reason for the latter is that mercs are a great supplement to naval power when you are under-utilizing your income, but a fleet made entirely of mercenaries would be weaker (looking only at upkeep and the max number of ships an empire could support).

Buying Mercenaries:
- when the AI is able to purchase new mercenaries it scores possible purchases according to combat power/upkeep. I don't think the actual purchase cost is really that important more than a few turns out, and its better to start simple, so we'll just disregard that for now.
- the AI also keep track of the combat power/upkeep score of mercs it already has, and if a new merc's score is greater by some factor it disbands the old mercenaries. It doesn't do this for any merc ships assigned to certain missions, like attack or intercept. It probably should also not disband anything until it is using a certain portion of its merc budget, to avoid excessive churn.

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Sat Aug 25, 2018 11:53 am

Sounds reasanable

Do you know what will happen if the AI acutally bought a merc ship?
I assume (and hope) it will disappear from the merc pool but could never observe it as it has not happened yet - might run into bugs because of it once they do start buying

If the above works and they can buy and command withouth error, can dependency be built in according to diplomacy status?

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Sat Aug 25, 2018 12:09 pm

BTW: enslavement and harmonisation seems ot have been added to the AI repertoire some time ago and have seen enslaved and cyborg pops after AI occupation :)

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Sat Aug 25, 2018 7:02 pm

There are some possible issues here from the game mechanic:
1. The basic merc pool AIs can have access to are that of Marauders - but these require a gift to be in good enough of a relationship to sell slaves/ships. It might be that the code to purchase slaves/ships is already in place but the missing peace is the gifting to the Marauder faction
2. There does not seem to be a difference in how many Maradauder factions the faction is freindly with - the pool is the same. This means that the first gift is necessary for merc ships buying but consequent gifts to other factions is much less usefull
3. Phidis and their Trade/ally partners have access to multiple pools of merc ships. The AI would thus need to be able to compare the usefullness of the ships within these pools to make proper decision.

Since due to the above, the overwhelming majority of merc ships would come from Marauders, it would even make sense to alter the logic of the third point and prioratize any other pool in order to make the map and engagements more varied. Phidi could still hire from Marauder pool - but only if no other pool is available or if they are empty

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Sat Sep 01, 2018 10:21 am

A problem that would naturally arrise from AI buying from the same limited merc pool as the player is: increased micro MGMT for the player checking what is available in the pool to be the first to buy a powerfull or simply newly available ship

While a notification on new ships would make sense: listing all the new models, prices and factiosn they belong to in a format similar to the Herald Tech buy menu, the simplest solution might be to pin the merc pool icon and number next to the own fleet size number as seen below

The number would automatically indicate when a new ship is available (and even more importantly if anything is available to buy) unless the AI has bough the same amount of ships during its turn, as the number of new ships are

Even more importantly: the icon could be linked directly to the merc browser window, reducing the number of clicks to get to them each time by at least 2

Optionally, the race specific icon could be positioned next to the palyer pool to even better differentiate the two - but ultimately these icons would be best deployed in vanilla code
Attachments
Merc Pool.PNG
Merc Pool.PNG (242.15 KiB) Viewed 20237 times

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Thu Nov 01, 2018 6:03 pm

I'm not sure if the AI buying ships from the merc pool would really disrupt the player that much. To me it looks more like a general issue of the player not knowing when new and better merc ships become available, which becomes exacerbated when the AI can start buying out mercenaries as well. Just thinking of an even simpler solution, perhaps a notification (as in using the current reports system) that one of the mercenary groups has new ships available this turn would be enough?


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 4 guests