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 #27 Top

ITT: Semaz still thinks the technical forum is the place to complain when the answer to a modding question is not the one he wants to hear.

Reply #28 Top

I have sent a few e-mails into Blair about a month and a half ago on this issue and I haven't heard anything back. I'm assuming it is because he is incredibly busy.

Reply #29 Top

oh do shut up GoaFan.  Since we're running around blind trying to figure out ways to tweak the AI to research better instead of being a complete fraktard even as an AI set to research, I'm also asking in Technical hoping some answers come up to those questions.  Take off the troll hat, it's Christmas time.  Either contribute to the discussion or go find a nice offtopic thread to create.

I don't mind rewriting 12 different races if it tricks the AI into researching better.  It's a pain in the ass is all, but more than doable since I've rewritten Atlantians, Empire, KzerZa, Rogue, Taalo, Arilou Wps, and a 12th Race for 7DS.

ZR, Lavo, can you pastebin the dummy ship and/or research item you are using to trick the AI.  I made 4 for the Atlantians and put them in the Entity.manifest and in the PlayerAtlantian.entity file:
        NotOnPage
            count 7
            entityDefName "FrigateOrionModuleConstructor"
            entityDefName "FrigatePsiTradeShip"
            entityDefName "FrigatePsiRefineryShip"
            entityDefName "AIDUMMYFRIG_ATL_RESOURCEBOOSTER"
            entityDefName "AIDUMMYFRIG_ATL_PHSMBEAMBOOSTER"
            entityDefName "AIDUMMYFRIG_ATL_PLSMWVBOOSTER"
            entityDefName "AIDUMMYFRIG_ATL_RnDSHLDBOOSTER"

When I start as the Atlantians and using the Rogue as AI, I get no dump.  When I start as Rogue using Atlantian as AI, it dumps. Pastebin'd the 4 ships.  They have 2 research prerequisites each to cover 8 areas of research which I want to trick the AI to pursue.

http://pastebin.com/46MSvE3A

Instead of putting in these dummy ships, should I instead create research items as "FrigateAccess" to go at the end of strings of research in the hope that the AI will research towards unlocking the dummyfrig and do I even need to bother putting the dummy frig in the PlayerAtlantian.entity file?

Reply #30 Top

Quoting SemazRalan, reply 29
oh do shut up GoaFan. Since we're running around blind trying to figure out ways to tweak the AI to research better instead of being a complete fraktard even as an AI set to research, I'm also asking in Technical hoping some answers come up to those questions. Take off the troll hat, it's Christmas time. Either contribute to the discussion or go find a nice offtopic thread to create.

We're not flying around blind, you can either look at the values used by the regular AI to guess their range or experiment yourself like Zombie and Lavo are doing. There's no reason to spam the technical forum when we can find out the answers for ourselves. Indeed some of the answers are in this thread already.

Reply #31 Top

removed the ships from the PlayerAtlantian.entity file, no dump.  Running ATL as AI and hopefully they pursue the research paths that unlock the dummy ships.

Reply #32 Top

Quoting SemazRalan, reply 29
I don't mind rewriting 12 different races if it tricks the AI into researching better.  It's a pain in the ass is all, but more than doable since I've rewritten Atlantians, Empire, KzerZa, Rogue, Taalo, Arilou Wps, and a 12th Race for 7DS.

But that's wrong... You aren't "rewriting" a damned thing. All you're doing is adding in a bunch of research items. As you've rewritten all the races already, this in fact easier not harder. Hell, all you need is one single open frigate or capital ship slot in order to be able to make a single chain that spans every single tech item. I cannot confirm if NotOnPage does the trick, I don't think it does, though I'll test it at some point now that you mention it.

ZR, Lavo, can you pastebin the dummy ship and/or research item you are using to trick the AI.

Here you go.

Instead of putting in these dummy ships, should I instead create research items as "FrigateAccess" to go at the end of strings of research in the hope that the AI will research towards unlocking the dummyfrig and do I even need to bother putting the dummy frig in the PlayerAtlantian.entity file?

If there's no dummy ship the AI will have no reason to research and thus everything will be useless.

Reply #33 Top

Well, I really don't think we have any free ship slots tbh.  lol.  Dummy ships, not put into playerX.entity file at all, are going to have to do it.  I've got dev.exe running 8x speed and plan to check it in 6 hours when I wake up.  Hopefully, the AI has chased right.

 

Do you have a screenshot of your tech trees or a fraps?  Position 19,2... hmm.

Reply #34 Top

Quoting Lavo_2, reply 32
Hell, all you need is one single open frigate or capital ship slot in order to be able to make a single chain that spans every single tech item.

I think a structure slot will work as well, as they also move to get trade ports/culture centers/super weapons etc. fairly quickly as well.

Reply #35 Top

Quoting SemazRalan, reply 33
Well, I really don't think we have any free ship slots tbh.  lol.  Dummy ships, not put into playerX.entity file at all, are going to have to do it.  I've got dev.exe running 8x speed and plan to check it in 6 hours when I wake up.  Hopefully, the AI has chased right.

You don't have any open capital ship or structure slots? And in 6 hours, odds are the AI will have researched everything regardless. :P

Quoting SemazRalan, reply 33
Do you have a screenshot of your tech trees or a fraps?  Position 19,2... hmm.

I don't have a screenshot, but do refer to the hand-drawn image I posted earlier.

Quoting GoaFan77, reply 34
I think a structure slot will work as well, as they also move to get trade ports/culture centers/super weapons etc. fairly quickly as well.

I actually use a tactical structure slot as one of the fillers for the Imperials and Rebels, due to a lack of ship slots, and it does work. Though I'm not sure if it's as effective as a ship, the trials I've run have been inconclusive.

Reply #36 Top

I'm using NotOnPage with a hidden frigate and a hidden research subject. It's invisible to the player this way.

Note: NotOnPage has the same limit of 9 frigates which 3 are used by trade, constructor and refinery frigates.

 

While it would be nice to get a response from IC or stardock on some of the AI constraints, I think we can determine what values have an impact if any by observation.

Here's my initial iteration with influencing the AI...

NotOnPage
count 9
entityDefName "FrigateTechModuleConstructor"
entityDefName "FrigateTechTradeShip"
entityDefName "FrigateTechRefineryShip"
entityDefName "ResearchTechToughness0"
entityDefName "ResearchTechToughness1"
entityDefName "ResearchTechWeapons0"
entityDefName "ResearchTechWeapons1"
entityDefName "ResearchTechIndustry0"
entityDefName "ResearchTechIndustry1"


researchInfo
count 163
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_WEAPONSTECH0"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_TOUGHNESSTECH0"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_INDUSTRYTECH0"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_WEAPONSTECH1"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_TOUGHNESSTECH1"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_INDUSTRYTECH1"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_WEAPONSTECH2"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_TOUGHNESSTECH2"
entityDefName "RESEARCHSUBJECT_RESEARCHACCESS_INDUSTRYTECH2"

 

 

Reply #37 Top

My observations so far with this approach is the AI likes to research the 1st pre-requisite but doesn't seemed to concerned about the second pre-requisite. I'm going to do a bit more controlled testing here to confirm, but so far I've put high priority techs I want researched as the first subject.

I also have a couple other options I'm going to investigate after watching how the AI researches that won't require build menu slots. If they work I'll post back here.

 

Additionally ResearchSubject->priority seems to not be used as far as I can tell. Has anyone seen any behavior that contradicts this? I'm going to do a bit more playing here to see.

Reply #38 Top

yeah, after 8.5 hours, AI researched 100%.  I didn't have the 4 ships in the playerAtlantian.entity file and the ships use existing research as prerequisites.  Will test thursday for 4 hours and see how the AI has done after that.  Then Friday for 2 hours.  This is without changing gameplay.constants.  AI was researcher.

Reply #39 Top

Quoting SemazRalan, reply 38
yeah, after 8.5 hours, AI researched 100%.  I didn't have the 4 ships in the playerAtlantian.entity file and the ships use existing research as prerequisites.  Will test thursday for 4 hours and see how the AI has done after that.  Then Friday for 2 hours.  This is without changing gameplay.constants.  AI was researcher.

Well... All this really proves is the AI is capable of full research given enough time. 

What the frigate solution does if influence the AI to start research specific techs much earlier. Without giving the AI a specific goal to reach for it falls back onto the random research rules that are already in place for the engine.

 

BTW, I just tested your approach by removing the seed frigates which resulted in no extra non-random research benefits (i.e. BAU).

 

Reply #40 Top

Quoting ZombiesRus5, reply 37
My observations so far with this approach is the AI likes to research the 1st pre-requisite but doesn't seemed to concerned about the second pre-requisite. I'm going to do a bit more controlled testing here to confirm, but so far I've put high priority techs I want researched as the first subject.

I've seen that the AI researches both; though mind you most of the time I have one of the "chains" set to the second research pre-req.

Additionally ResearchSubject->priority seems to not be used as far as I can tell. Has anyone seen any behavior that contradicts this? I'm going to do a bit more playing here to see.

I can confirm this.

Reply #41 Top

Can anyone test these new AI stuff to see if this really changes the game. I might have time to do it but I think we need hundreds of people to try to see if the changes would really improve the AI temporary till the rebellion comes out and hopefully they tinker with the AI in it.

Reply #42 Top

Quoting ice27828, reply 41
Can anyone test these new AI stuff to see if this really changes the game.

You can force the AI to research things it would not otherwise research. This much has been confirmed and tested.

One can also use this to make an off-grid technology item that gives the AI a nice boost, whether it be economic, military, or both, to boost it's difficulty.

Reply #43 Top

Well, the Atlantians in 7DS have the most massive tech tree of any race so I'll be doing 2 hour tests on our maps without quickstart to see just how much the AI as a researcher researches.  Then I'll run another using unmodified tech tree for two hours with AI as researcher.  Should see a marked improvement in the tweaked than untweaked using identical maps. Should really see it when AI is not researcher, but econ/turtle/hawk.

 

Reply #44 Top

So after doing the shotgun approach I've scaled back and refined the implementation a little bit and like the results so far.

What I have now is.

Armor 3 levels

Hull 3 levels

Block Colonize (Was trying to get the AI to add this tech, bleh they like to upgrade weapons, hull and strikecraft 99%)

Crystal 2 levels

Cargo Ship 3 levels

Settlers (includes Arbitrate Tarrif)

 

So how did the AI fair.

8-8 Hull 3 levels

7-8 Armor 3 levels

8-8 Missile 5 levels (All tried to get the superweapon, meaning they overbuilt 8 labs in a cramped game).

3-8 researched block colonize

7-8 Crystal 2 levels

5-8 Cargo 1 level, 2-8 2 levels

6-8 Settlers, 5-8 Arbitrate Tarrif

 

The AI also still built pretty impressive fleets for the most part. In my previous testing I think I had way too many pre-reqs to fulfill which did appear to limit the ability of the AI to upgrade fleet supply and produce ships. 

I'll also note the AI did ignore several of the suggested research I wanted it to do, but this could have been due to the AI type or general AI logic as it also ignore other TECHS like Hoshikos and Cielo's.

 

In regards to pacts, the AI seemed INTENT on increasing relationships with the WRONG ally. If Pink had their relationship up to 20 on RED, then RED made sure to send it's envoy's to anyone but PINK. This resulted in extremely low pact utilization now that the same relationship is required on both sides. Does this dual relationship system make sense? I can see a target threshold to accept a pact, but making it the same relationship just doesn't seem to work.

If you want an AI to research a path in your tree link it that races superweapon. The AI gets a massive boner trying to get it's superweapon access ;)

 

I actually think the AI could be more effective if it didn't rush to 8 research labs so quickly and instead focused more on lower hanging fruit and fleet. I personally think this is another reason the AI got easier after the last round of Diplomacy changes for the pact system and enabling super weapons for the AI.

 

Reply #45 Top

This would actually be a really good mod for people who play solo often.  Hope ya'll release one.

Reply #46 Top

Quoting Sinperium, reply 45
This would actually be a really good mod for people who play solo often.  Hope ya'll release one.

No Sinperium, you have to learn to activate my zombie mod or you can't play it  }:)

Reply #47 Top

Quoting ZombiesRus5, reply 44
I actually think the AI could be more effective if it didn't rush to 8 research labs so quickly and instead focused more on lower hanging fruit and fleet. I personally think this is another reason the AI got easier after the last round of Diplomacy changes for the pact system and enabling super weapons for the AI.

I agree with this. Your bit on the supply/ship stuff is quite useful Zombie, I'll do tests on that if I get the time as well.

Reply #48 Top

Tinkered with research table

        table-Research
            BuildShip 5
            BuildModuleTactical 2
            BuildModuleCivilian 2
            BuildModuleResearch 3 (was 2)
            UpgradeResearch 15
            UpgradePlanetArtifactLevel 1 (was 2)
            UpgradePlanetPopulation 5 (was 3)
            UpgradePlanetInfastructure 2
            MaxBountyBidCount 7 (was 10)
            UpgradeStarBase 3

Normal Researcher AI Atlantians, with dummyships in, spent the better part of the time building 8 military labs, then built 1 civilian lab, pushed for the same damn ship unlocking item it has 5 times before (unlocks the atlantian buildable ships), poorly researched weapons, barely researched civilian items -ignored ice/volcanic research even though an Ice and Volcanic were next to homeworld. 

I'm so annoyed with the AI in general that I'm contemplating giving a race just 40 items to cover everything in the hope the damn AI will research right.  lol.

 

btw, giving a research item a priority of 5 didn't crash the game, but didn't seem to do anything at all. 

Reply #49 Top

Quoting ZombiesRus5, reply 46

No Sinperium, you have to learn to activate my zombie mod or you can't play it 

I have a salt shaker and some needle thread around here..watch it Zombie!

Seriously though, if you can make a basic vanilla mod of this it would be really great for most players--assuming you can refine it and get it going.

Reply #50 Top

Quoting Sinperium, reply 49
I have a salt shaker and some needle thread around here..watch it Zombie!

Seriously though, if you can make a basic vanilla mod of this it would be really great for most players--assuming you can refine it and get it going.

If he won't, I'm sure some modder around here will steal the idea, and all the karma it will generate. :-"