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,433 views 134 replies
Reply #76 Top

Quoting Lavo_2, reply 75
I can think of a way. With abilities, you can set them up so they are leveled up by research. The level up in this case can be due to one of the filler techs, if not the first one, which can reduce AM costs, cooldown time, or other tweaks. This would ensure that the AI would use abilities more, albeit in a somewhat cheap manner.

That is a good idea for a Hard AI addon.

Though, I was thinking more of the inability for the AI to prioritize ability usage as the concept of this ability is better than the other gets lost on the AI. For example I can't give the AI their own ultimate ability cost which is one reason I was considering dramatically decreasing AM but increasing cooldown to give the AI a chance. The human player already has the advantage because they know how to conserve AM for this situation.

Reply #77 Top

Quoting Lavo_2, reply 75
I am well aware of this. I was using 9 of those slots at first, it was only once I moved two of the ships to the regular frigate menu that the MDs stopped occuring. As I said, it utterly puzzles me, but it works.

What were the roles by chance? I've used up all 9 with siege and starbase constructor roles without any issues.

I know the game gets finicky though ;)

Reply #78 Top

Quoting Lavo_2, reply 75
I can think of a way. With abilities, you can set them up so they are leveled up by research. The level up in this case can be due to one of the filler techs, if not the first one, which can reduce AM costs, cooldown time, or other tweaks. This would ensure that the AI would use abilities more, albeit in a somewhat cheap manner.

A couple of other hard AI options :P
 
Add additional targets per bank for their capital ships (easy)
 
Add an intrinsic 5th passive ability on AI capital ships that give it additional bonuses, not available to humies as it would be activated with hidden research.
 
Could do things like give Additional Squads, Capital Specific upgrades like Hull, Shields, or even add booleans like ImmuneToNonUltimateDisable or InstantBuildFighters. 
 
Not sure I'd do the ability thing but fun to brainstorm.
Reply #79 Top

Quoting ZombiesRus5, reply 77
What were the roles by chance? I've used up all 9 with siege and starbase constructor roles without any issues.

AntiModule, Siege, and StarbaseConstructor. I moved the former two off of the list, which is what fixed it. Seeing as how Siege works for you, odds are the AntiModule was the issue.

Quoting ZombiesRus5, reply 78
Add additional targets per bank for their capital ships (easy)
 
Add an intrinsic 5th passive ability on AI capital ships that give it additional bonuses, not available to humies as it would be activated with hidden research.
 
Could do things like give Additional Squads, Capital Specific upgrades like Hull, Shields, or even add booleans like ImmuneToNonUltimateDisable or InstantBuildFighters. 
 
Not sure I'd do the ability thing but fun to brainstorm.

All good ideas. Another is a ship-wide weapon or health boost of sorts (dmg boost, weapon cooldown, shield regen, etc).

Quoting ZombiesRus5, reply 76
Though, I was thinking more of the inability for the AI to prioritize ability usage as the concept of this ability is better than the other gets lost on the AI. For example I can't give the AI their own ultimate ability cost which is one reason I was considering dramatically decreasing AM but increasing cooldown to give the AI a chance. The human player already has the advantage because they know how to conserve AM for this situation.

The AI doesn't prioritize abilities as it just auto-fires them all. It isn't so much that the AI cannot "think" of which ability is better, the issue is that it does not "think" at all.

Reply #80 Top

Quoting Lavo_2, reply 79
The AI doesn't prioritize abilities as it just auto-fires them all. It isn't so much that the AI cannot "think" of which ability is better, the issue is that it does not "think" at all.

Well, thats my point of giving the AI better conditions and better opportunities to use abilities that make a difference. This can be done by giving them proper aiUse and aiTarget conditions, rebalancing AM and or cooldown costs, converting useless AM wasters to passives...

Point is the AI needs help to be competitive as a lot of the more useful abilities get canceled out by other less useful abilities or drained to quickly because of lack of proper ai conditions.

Reply #81 Top

Quoting ZombiesRus5, reply 80
Well, thats my point of giving the AI better conditions and better opportunities to use abilities that make a difference. This can be done by giving them proper aiUse and aiTarget conditions, rebalancing AM and or cooldown costs, converting useless AM wasters to passives...

Point is the AI needs help to be competitive as a lot of the more useful abilities get canceled out by other less useful abilities or drained to quickly because of lack of proper ai conditions.

Ah, yeah that's true. For example, the TEC's Gauss Blast really needs a longer cooldown.

Also these posts just gave me a great idea... One that might allow me to kill SoGE's AI bombing issue.

Reply #82 Top

Today it has come to my attention that the AI can build NotOnPage frigates. I was unpleasantly surprised by this, and did not believe it when I saw it just now, until I isolated which frigate it had built, which proved this. Picture detailing it below.

The ship in question is FRIGATE_FILLER_ADVFTR_IMP.entity.

Reply #83 Top

Quoting Lavo_2, reply 82
oday it has come to my attention that the AI can build NotOnPage frigates. I was unpleasantly surprised by this, and did not believe it when I saw it just now, until I isolated which frigate it had built, which proved this. Picture detailing it below.

Ah, sorry. I assumed you understood that or would have made it more clear.

I've been using that to get special starbase constructors in my mod for the AI. Specifically for races that use the colonizer as the dual starbase constructor. 

Reply #84 Top

Quoting ZombiesRus5, reply 83
Ah, sorry. I assumed you understood that or would have made it more clear.

I've been using that to get special starbase constructors in my mod for the AI. Specifically for races that use the colonizer as the dual starbase constructor. 

Ah, I see. I didn't know that the AI could build those NotOnPage frigates, admittedly my knowledge of them stops at the fact that they just don't show up on the page. Not your fault, tis my own ignorance. Just means I'll have to fix up some stuff, and add in more frigates to fill the void.

Reply #85 Top

Or just have duplicate frigates (same stats etc) so if they in fact do unlock the super expensive one it isn't a game breaker. That's all.

Reply #86 Top

Quoting boshimi336, reply 85
Or just have duplicate frigates (same stats etc) so if they in fact do unlock the super expensive one it isn't a game breaker. That's all.

I don't know how the AI will react to that, which is why I've avoided going that route,

Reply #87 Top

Quoting Lavo_2, reply 86
I don't know how the AI will react to that, which is why I've avoided going that route,

I haven't had an issues with this. In fact in my solution I cloned the Siege and Star base constructor as the not on page research frigates. If the AI builds them no one will really notice as they are exactly the same except for research pre-requisites.

Though you may want those ships research tree's as pre-reqs in the path if you don't want them built ahead of time :).

 

Reply #88 Top

Quoting ZombiesRus5, reply 87
I haven't had an issues with this. In fact in my solution I cloned the Siege and Star base constructor as the not on page research frigates. If the AI builds them no one will really notice as they are exactly the same except for research pre-requisites.

For some reason, when I replied to that post, I was thinking that it suggested that I make the ships themselves cost an exorbitant amount, and not what was actually said... I need to get more sleep before exams kill me.

Reply #89 Top

Good ideas here!

I added Capital ships without support points requirements for the AI to build by putting in a required research that only the AI can do. So finally the AI builds Capitals!

That is a great improvement. The AI puts terribly number of frigates into the build queue that blocks normal Capital construction.

 

Reply #90 Top

I'll note that the changes I posted earlier have resulted in the AI using massive amounts of capital ships, it isn't uncommon to see fleets with 7+ capitals, it as a whole preforms much better, though it's research is very weird now. It likes to research what I prioritize, that is virtually all civilian tech, but otherwise does not research other stuff that much, aka. the defense and military trees. However this might be due to the military chain only being on two of the filler ships. I'm going to play around with this more.

Reply #91 Top

Quoting Lavo_2, reply 90
I'll note that the changes I posted earlier have resulted in the AI using massive amounts of capital ships, it isn't uncommon to see fleets with 7+ capitals, it as a whole preforms much better, though it's research is very weird now. It likes to research what I prioritize, that is virtually all civilian tech, but otherwise does not research other stuff that much, aka. the defense and military trees. However this might be due to the military chain only being on two of the filler ships. I'm going to play around with this more.

What research modifier are you using?

Reply #92 Top

Quoting ZombiesRus5, reply 91
What research modifier are you using?

Do you mean to boost/encourage research for the AI, or something else? If the former, they're in this list. I've also since swapped out the max trainable level for a constant gain of experience until level 3 (i.e. capitals are spawned/built at level 3).

Reply #93 Top

Quoting Lavo_2, reply 92
Do you mean to boost/encourage research for the AI, or something else?

Sorry, quoted the wrong post and didn't bother to read it after I submitted.

Quoting Quiet_Man, reply 89
I added Capital ships without support points requirements for the AI to build by putting in a required research that only the AI can do. So finally the AI builds Capitals!

What research modifier did you use? I'm not seeing anything that allows the AI to build capital ships without support points.

Reply #94 Top

Quoting ZombiesRus5, reply 93
What research modifier did you use? I'm not seeing anything that allows the AI to build capital ships without support points.

He probably gave the AI an absurd amount of capital ship crews. Judging by his posts elsewhere, he's playing Maelstrom with Dreadnaughts, which due to their constant spawning, ensure that the AI constantly lacks capital ship crews.

Reply #95 Top

That's what I was afraid of and not really an ideal solution but understandable.

I've actually been thinking of a way to ensure only a single dreadnought for his mod but hadn't had a chance to code it out yet.

Reply #96 Top

Is it just me, or does the AI seem to flat out stop researching around an hour and a half into the game? It's really weird; even with all the pre-reqs they don't research them all.

It might be that the AI simply runs out of money due to buying new ships, but it disturbs me. Actually I think it might be due to a lack of cash... As I did first test this with cash not being an issue; I'll look into this some more.

Reply #97 Top

Seems cash isn't the issue... Gave the starting Terran a production rate of billions per second, and this still occurs. For reference, there are 55 combat techs, for the Empire, their race. Red/yellow are an offensive AIs, greens are defensive AIs, blue is research, and pink/purple are economic AIs. In addition, the offensive, defensive, and economic AIs have the same research spending setting in Gameplay.constants, which makes this utterly baffling. While I feel that the chains might have a negative effect on this problem, the faction shown here had their setup changed to the original method, the one I used as an initial proof of concept.

Reply #98 Top

Quoting Lavo_2, reply 96
Is it just me, or does the AI seem to flat out stop researching around an hour and a half into the game? It's really weird; even with all the pre-reqs they don't research them all.

It might be that the AI simply runs out of money due to buying new ships, but it disturbs me. Actually I think it might be due to a lack of cash... As I did first test this with cash not being an issue; I'll look into this some more.

I had a map where nine AI forces literally just sat in place until they were destroyed.  After twenty or so starts one finally colonized a single adjacent planet.

I had started them out with dead asteroids as HWs.

After days of playing around with things, I swapped the dead asteroids for pirate bases (with the tax bonus) and they began colonizing aggressively--even after I reduced the starting cash.

I had started them before with 10k credits and resources but it was the pirate income that got them going.

Might be much more to this.

 

Reply #99 Top

The AI is just too ****ing stupid, pardon the *, to do what we want.  Time to bug the daylights out of devs and hope the AI isn't the love child of Forrest Gump and Nell.

Reply #100 Top

Quoting Lavo_2, reply 96
Is it just me, or does the AI seem to flat out stop researching around an hour and a half into the game? It's really weird; even with all the pre-reqs they don't research them all.

It might be that the AI simply runs out of money due to buying new ships, but it disturbs me. Actually I think it might be due to a lack of cash... As I did first test this with cash not being an issue; I'll look into this some more.

I've limited my research down to a half or so dozen things I want the AI to research and it seems to work ok. I have noticed the AI especially when conflict starts really limits the amount of research it performs if any.