ZombiesRus5 ZombiesRus5

[SotF] Improving the AI

[SotF] Improving the AI

So I've finally tackled what I think is a good foundation for modding pacts, while maybe not ideal support the goals of my mod they are within the limitations of the game's moddability.

Another goal of mine has been to improve the AI as much as possible. 

What we know is the AI is not very moddable, so we have to look at this from the constraints that are available.

So what areas do I see as potentially AI improving options...

 

Gameplay.constants:

DamagePercentBonus - Actually works pretty well currently with getting the AI to attack the right targets. Might be be some opportunities though. I've considered removing the advantage the Human player has of targetting enemy capital ships by modifying these abilities changing what is anti-capitalship.

playerAISharedDef - Something I haven't really invested any actual time in. I'm hopeful some tweaks here might prove fruitful.

playerAISharedDef

  • table-Aggressive - Focuses on ships(10)->bounty(5)->tactical(3)->research(2)-others(1)->mines(0)
  • table-Defensive - Focuses on tactical(6)->ships(5)->bounty(5)->starbase(3)->planet(3)->research(2)->mines(2)
  • table-Research - Focuses on bounty(10)->ship(5)->research(5)->tactical(3)->others(2)->mines(1)
  • table-Economic - Focuses on bounty(15*)->ship(5)->civilian(5)->population(5)->research,planet(2)->others(1)
* is 15 the highest value?
 
options available
  • BuildShip
  • BuildModuleTactical
  • BuildModuleResearch
  • UpgradeResearch
  • UpgradePlanetArtifactLevel
  • UpgardPlanetPopulation
  • UpgradePlanetInfrastructure
  • MaxBountyBidCount
  • UpgradeStarBase
  • BuildMines

I'm wonder if these can be turned into Difficulty levels as one option. Another option may be to slide these values up or down to adjust how the AI behaves. 

It would be curious to see how the AI behaved if all the values excluding mines and bounty were set to 15.

I may also try some variations that slide values up or down based on AI behavior. For example, I dislike seeing un-upgraded starbases.

aiRetreatThreshold - from what I've gathered reading other posts this is a strength test with lower values resulting in longer battles and higher values resulting in a quicker retreat. 

 

Abilities

There are lots of possibilities to improve the AI here in my opinion. Here's a few of the issues that can potentially be resolved with rebalancing or coding changes.

  • Synchronized targeting, specifically single target synchronized abilities like Suppression
  • Default aiUseTimes not taking advantage of new better conditions
  • Default aiUseTargetCondition not taking advantage of new or better conditions
  • Antimatter costs canceling out 2nd or 3rd abilities from being cast
  • Ultimates never executed by the AI (Example Resurrection)
  • Abilities never executed by the AI (Example Resource Focus)

Single Target Synchronized abilities

I actually have a fix for this that's already in SotF. To make the AI and by extension the player more effective with this ability I changed it from ApplyTargettedBuffToSelf to ApplyBuffToTarget. The synchronizing still occurs but is cast via a callback from the affected target. I still have some more to change for the custom races in my mod.

So far I've changed Suppression, DisableImmune, TransferAntiMatter, DesignateTarget

Default aiUseTimes

A lot of abilities could be improved for ai casts by tweaking the aiUseTime on abilities. 

Here's a link to the valid list of aiUseTime's

Default aiUseTargetCondition

While not as many options as aiUseTime there are some useful aiUseTargetCondition's that might be put on abilities with the goal of improving the AI. 

One condition that pops out is the isCapitalShipOrStarbase condition. This might be extremely useful for the AI on abilities like DetonateAntimatter or NanoDissasembler. This condition won't stop a player from manually targetting a frigate, but it will cause the AI to choose to target capitals or starbases.

Another possibility for DetonateAntimatter is the AntimatterExceedsAmount condition as this ability only causes damage when there is decent amount of antimatter reserve.

The main point will be review each Ability's aiUseTime and aiUseTargetCondition especially for those that are the Any types and see if any potential improvement can be made.

Antimatter costs canceling out 2nd or 3rd abilities from being cast

This one bugs me a bit with the AI as typically AM reserves and cooldowns work out to the same ability being cast over and over when the better ability remains unused.

A couple of options present them self to help resolve this.

  • Rebalance AM, ai use/target conditions and cooldowns to ensure both abilities have a change to fire if appropriate. For example the Guass Blast and Flak Burst end up with Flak Burst rarely being cast during extended battles as the AM is chewed up by Guass Blast. In this scenario FlakBurst could be rebalanced to have a lower AM cost than GuassBlast but an aiUseTime of OnlyWhenManyTargetsInRange. This may require some rebalance to effect of the ability but will create a more dynamic AI.
  • Convert an AM using ability to a Passive. Again picking on the Kol..., The AdaptiveShield is a good opportunity for this type of conversion.
  • The onlyAutoCastWhenDamageTakenExceedsPerc could also be coupled with the rebalanced AM ai use/target conditions in the first bullet... For example AdaptiveShield could have a higher priority to fire based on AM, but only when it's exceeded a certain damage threshold.

Ultimates never executed by the AI (Example Resurrection)

While resurrection is the biggest example I'd like the AI to have more opportunity to execute Ultimate abilities.

  • For resurrection I intend to change this into an ability the AI will use. Basically any capital ship will have Resurrection applied to it once. It won't recast on a ship that's already been resurrected so only newly built ships will get the affect. Human players can still control this BAU.
  • For other ultimate abilities I'm thinking about dramatically reducing their AM costs and increasing cooldowns as I want the AI to prioritize using them. As it currently stands the AI will never disable it's other abilities like Radiation Bomb to store AM for Missile Barrage. By decreasing AM below normal abilities all level 6 capitals become dangerous even in extended battles.
  • I'll still look at the previous changes to help the AI make better decisions about when to cast ultimate abilities.

Abilities never executed by the AI (Example Resource Focus)

This bugs me too and considering resource focus isn't that big of an impact I'm considering making it a passive ability and possibly reblancing it some to compensate.

I guess I should add one more thing to the mix... Abilities that activate too much. Sorry, but the phase out hull on Vasari structures is going to get changed to an AM based ability. This one just bugs the shit out me trying to take down Vasari structures :P

 

Star Bases

The AI never does anything cool with these!

Why? Because it put's all it's upgrade points into Weapons/Toughness/Strikecraft before it even thinks about a different upgrade type.

This results in fairly boring usage of Star bases by the AI...

Solutions?

  1. Decrease the amount of upgrades available for Weapons/Toughness/Strikecraft
  2. Increase the amount of upgrades allowed for a Star Base from 8 to ?
  3. Add instant low level access for all star base upgrades
 

Decrease the amount of upgrades available for Weapons/Toughness/Strikecraft

In essence this would simply make additional upgrades available for Trade, Block Colonize or other special abilities

Increase the amount of upgrades allowed for a Star Base from 8 to ?

Simple enough increase from 8 to whatever. Downside is a lot more resources are needed to upgrade the starbase.

Add instant low level access for all star base upgrades

This one is intriguing. Essentially you could make up for the lack of dynamic behavior on the AI by forcing it to have upgrades that a human would most likely get anyway. Downside is the human gets these as well.

 

Generic Stuff

Spamming of mines by Advent drone hosts

Ok, I actually fixed this in my mod by removing mines from the carrier and creating a separate mine host similar to the Vasari mine layer.

m_weaponIndexForRange

I can't recall on this one but if I change the m_weaponIndexForRange to 1 for the Vasari Starbase will that prevent the other weapons from firing until it's in range of the antimodule weapons. I want the Vasari starbase to engage all it's weapons instead of staying out of range with it's anti-module. If this does cause issues I'm going to rework weapon ranges to ships and star bases with multiple weapons to be more effective.

 

maybe some other stuff I haven't considered yet...

117,368 views 134 replies
Reply #126 Top

Quoting GoaFan77, reply 126
It should, but wow, that is the exact opposite that our AI findings have discovered. Usually the AI beelines for techs that unlock units and abilities and ignore stat upgrades until they max out their fleet supply or otherwise cannot build additional ships.

Until now, our research has been based off of Diplomacy/Entrenchment. It is entirely possible that the AI has been optimized and reconfigured to research things more. I've certainly found that the AI seems to research much more in general versus Entrenchment. It's rather scary to see the AI research nearly all the techs in around an hour after they get a 100% research cost decrease.

Reply #127 Top

Quoting Valpheus, reply 125
Wow great reads!

Does the vanilla AI described here still apply for Rebellion?  My feeling is that the AI is not that eager to research ships, and Advent for example often queue up a large amount of weapon/shield upgrades.

I haven't seen the behavior you've described with Rebellion. From what I've seen the rebellion AI prioritizes superweapons, ships, structures and handful of other specific techs like wormhole or star navigation.

When you say your "feeling" are you testing with the dev.exe? Are you switching players to see what the AI has actually researched?

 

Reply #128 Top

Time to cast a necro-bump, and reopen discussion of Sins' AI, with a question: does Sins' AI properly work with a Research Victory? Some may wonder why I ask this, but I have a simple answer: if the AI does, then I believe it's possible that Research Victory could be retooled into a method to get the AI to research all the techs, by making RequiredCompletedResearchSubjects cover every single one of the factions' techs.

Further, in order for it not to actually count as a victory, it would have a research pre-requisite of a tech that the AI does not have access to, or the research victory would take so much time (say, 24 hours) that the AI wouldn't be able to complete it. While this would admittedly kill the research victory mode, it would make for a better AI, which I personally believe is more important.

Reply #129 Top

I have seen the AI try a research victory before, that's all I can say.

Reply #130 Top

Most excellent. This means that the theory I posted may in fact work!

Edit: Scratch that. Seems the game is hardcoded to have a maximum of 50 completed research subjects as a requirement, and is hardcoded for research subjects to take a maximum of 2760 seconds. Ah well.

Reply #131 Top

gotta love that ninja hardcoding. Too bad Stardock didn't try to actually work on priority level.

Reply #132 Top

It's unfortunate. I don't get why there is a hardcoding like this; I don't get the difference between say, 99 and 50, as they're both in the 10-99 range.

Reply #133 Top

Quoting Lavo_2, reply 131
Scratch that. Seems the game is hardcoded to have a maximum of 50 completed research subjects as a requirement, and is hardcoded for research subjects to take a maximum of 2760 seconds. Ah well.

Not sure about the 50 hardcode, but the duration of the research victory should be determined by the victory speed option. Unless 2760 is the highest number that the in game timer supports, I think that would have more influence than changing the time to research it.

Reply #134 Top

2760 is the highest with a 1.0x research speed option set.