Sins of a Solar Empire: Rebellion

Sins of a Solar Empire: Rebellion

123 ratings
AI Info for Players and Modders - from Artificial Unintelligence
By Delnar_Ersike
My research and observations about Sins of a Solar Empire's AI, useful for players and modders alike
2
3
2
   
Award
Favorite
Favorited
Unfavorite
Introduction
Let's face it: Sins of a Solar Empire's AI is stupid. Unfortunately, their most fundamental parts are locked into an exe or dll file, their source code most likely never to be released for modders to examine, alter, and fix. However, there are still ways to push the AI, however dumb it may be, to put up a fight without resorting to ludicrous resource or stat bonuses.

This guide is split into two main sections: one is about various in-game AI settings that both players and modders might be interested in, the other is about various parameters modders can change that will influence how the AI behaves.

If you want a mod that uses all my listed tricks to improve the game's AI, I recommend you check out Artificial Unintelligence[forums.sinsofasolarempire.com], the mod I worked on in tandem with my AI research.

Due to the lack of official sources, all observations are based on hours (and by hours, I mean weeks) of running test games in all sorts of setups, taking notes the entire time.
Keep in mind that even though my notes may seem thorough, the research is very much a work-in-progress: as I continue to expand and double-check my notes, others will undoubtedly also start reporting their own observations, which I will try to aggregate and verify as much as possible. If I am missing something or you think a certain observation/conjecture is incorrect, let me know and I'll see what I can do.
In-Game: General Info
  • The only thing increasing the AI's difficulty level does is change its income: as of Rebellion v1.82, AI's receive unmodified income on Normal, 2x income on Hard, and 7x income on Vicious . Other difficulty levels' incomes are harder to test, but they are most likely 0.75x for Easy, 3x for Unfair, and 5x for Cruel. As mentioned later, the AI also has no cap when buying levels for capital ships; it is possible that the level an AI will buy up to is determined by the AI's difficulty level.
  • If you are playing solo, it is highly recommended you enable Quick Start. The main reason is that the AI almost never upgrades their capitol population, so they start at a huge disadvantage income-wise. Since Quick Start starts everyone off with maxed population at their capitol, this helps the AI a metric ton in singleplayer games without giving it an unfair advantage. Note that playing on a higher difficulty without Quick Start is also a viable option, since the income advantage the AI has is mitigated by the fact that it doesn't upgrade its capitol population.
  • Pirates are mixed bag when it comes to how the AI reacts. A single pirate raid can be a death sentence for a Normal Economist or Researcher AI earlygame, while in the lategame, the AI's will never give the Pirate faction missions, even though they have the necessary research unlocked, resorting instead to still do bounty races. However, pirates can spice the game up a lot, and they are especially handy for leveling your capital ships. I tend to turn pirates off in my games, though you might still consider keeping them turned on.
  • When it comes to victory conditions, the AI is a bit odd. Left to their own devices, AIs ignore occupation planets almost entirely (save for the occasional scout). They are also incapable of properly playing with Flagships enabled, feeding enemy capital ships with XP by suiciding frigates one-by-one into enemy flagships, while also never using their own flagships for offensive purposes. If Allied Victory is turned off, AIs will be just as inclined to form alliances; the only difference in their behavior is that they will automatically unally a player if the player is nearing a non-research victory or starting a research victory, and if an AI has no opponents, they will automatically unally the player with whom they have the lowest standing. The AI will never actively pursue a diplomatic victory, though this is because doing so would require non-standard uses of envoys, missions, and sending resources, as well as interaction when human players are concerned. The AI will occasionally start off a research victory, but if they do, the other AIs will not respond, happily leaving their opponent to win a research victory without so much as a single gang-up to take out civilian labs. Capitol victory is the only special victory condition that the AI truly understands: it will place a huge emphasis on eradicating opponents' capitols and will immediately rush their fleets to defend their own capitol if threatened.
  • No matter the difficulty level, AIs will always enjoy some advantages over human players. For example, they can start researching techs even before they have labs built, as they only need to initiate the construction to start the research; however the effects of techs researched in this way will only trigger once the labs are complete (eg. if an AI queues up a military lab at the beginning of the game, it can have the first damage upgrade techs researched within the first 30 seconds of the game, but the actual damage increase only takes place once the first military lab is built). They can also see all phase jumping ships in the game even without the phase jump detection researches, though their algorithms only ever pay attention to jumps up to 2 planets away (like the maxed TEC or Advent phase detection techs). The AI can give missions to other players before unlocking the necessary research. Finally, the AI can buy upgrades for its capital ships past the upgrade limit of level 3 (4 with tech), though they will only do so once all their capital ships have reached the uprade limit (thanks Lavo_2!).
  • The AI also has one huge advantage that I need to mention because of how game-breaking it can be (it could technically be classified as a bug): it essentially has unlimited capacities for starbase upgrades. AIs spend resources on starbase upgrades in spurts: they will queue up all the upgrades they want and can afford in an instant, just like how they increase bounties in spending spurts. The problem is the game only checks if a starbase has maxed its upgrade capacity after the AI has done its spurt, meaning that if the AI has enough resources, it can queue up more upgrades than the starbase's capacity would allow. As a result, it's quite common for AI starbases to have 10-14 upgrades.
  • From what I've seen, the AI is terrible at multi-star maps. It is incredibly slow at expanding to non-home star systems and is even worse at protecting said expansion systems. This is mainly because of how it calculates where it wants to send its fleets: the calculations have a large emphasis on travel distance, eg. the AI is much more likely to send its fleet to a well-defended planet that is roughly 5 map units away than an ill-defended planet that is 25 map units away. This is also why the AI does not use wormholes that often: the travel distance is simply much longer, even if travel time is instantaneous. Even if interstellar travel is made instantaneous, the AI does not realize it and will still send its fleets to clash with well-defended planets over colonizing neutral planets that are much further away but could be traveled to within seconds, though it does help out a bit by affording the AI more flexibility, since sending a fleet to another system is no longer a minute-long commitment. On original maps, I would recommend playing either on a single-system map or a map with a large amount of star systems (eg. Voruk's Labyrinth), since having the AI easily conquer its home system makes sure it will properly deploy forces to expansion systems (since all close targets have been conquered). However, if you are making maps, placing star systems closer to each other (eg. on the z axis) could eventually have the AI start treating expansion systems properly, though keep in mind that stacking star systems on the z axis might actually increase travel distance due to gravity wells being cylinders instead of spheres.
  • The odd jump-in, jump-out loop that AIs often exhibit is caused by unsafe pathfinding. After retreating from a fight, the AI will give new move orders to the just-retreated fleets. Often it will tell those fleets to move to a target gravity well to which the shortest path requires moving through the gravity well the fleet had just retreated from. Instead of finding a safe way around or choosing a different target, the AI will blissfully send its fleets back into the danger zone, only to have them order a retreat the moment the fleet completes its jump... back to their starting gravity well, where the AI once again orders the fleet to move through the enemy-filled gravity well. This will repeat ad infinitum until the AI chooses a different target planet or the enemy fleet moves to a different gravity well.
In-Game: Behavior Presets
Keep in mind that these descriptions only fit well on lower difficulty levels: at higher difficulty levels, the fact that one preset is better or worse at building their economy is made pointless by the fact that they're showered with resources anyway. When I mention "economy upgrading", I mean building, researching, or upgrading anything that increases income or decreases ship/module cost.
  • Aggressor AIs are situational. They expand rather quickly and spend most of their income on building ships; however, this means that they don't tend to upgrade their planets or their economy, so even though they focus on building ships, they tend to lag behind AI presets that do focus a bit more on economy upgrading. They are actually worse than Economist AIs with the vanilla Gameplay.constants settings, but with a few tweaked settings, the situation improves greatly, though they still lose to the Fortifier preset 80% of the time. I would only recommend using them on tiny or small maps (or medium maps with pirates turned on) where their quick expansion and larger earlygame fleet size is the most important. The disadvantage of not having a properly upgraded economy also slowly fades away as you increase the difficulty level, so they are just as viable on larger maps at Cruel or Vicious.
  • Fortifier AIs are your Aggressors that are still capable late-game. Contrary to their name, they are actually quite aggressive with their expansion (they expand just as fast as the Aggressor preset) and don't focus nearly as much on tactical structures as the Aggressor preset, and although their planets are more easily taken earlygame since they don't concentrate as much on building ships either, they are much more able in the lategame due to their economic upgrades, and are much harder to defeat due to their use of upgraded Starbases (other AI presets don't tend to upgrade Starbases nearly as much as the Fortifier preset). They are more research-focused than Aggressors, and although they are generally less research-focused than the Researcher preset, the economic advantage that comes with early expansion can get them to end up having more techs unlocked than the Researcher preset. In short, they are like a hybrid between the Aggressor and the Researcher presets, with an extra emphasis on starbases and mines. I would recommend using them on medium or larger maps.
  • Researcher AIs are useless without any modding, but with modding, they are much more powerful and behave like your typical late-game Boomers. They are not as fast with their expansion as Aggressor or Fortifier presets, but still a bit faster than the Economist preset. Unmodded, their fleet sizes are laughable and they are easily taken out by other presets, but with some modification, they can hold their own against other AIs earlygame while they build up their prowess. They make up for their lack of units by concentrating a lot on research, especially military research: it is not uncommon for Researcher AIs to have twice the amount of total researches as Aggressor or Economist presets in the first 15-90 minutes of the game (depending on map size), especially if they're Advent. In some cases, this advantage makes them snowball when factions start fielding larger fleets, and at normal difficulty levels, they are often the only AI preset that can stand toe-to-toe with a human player's offense. Their research and their upgrades will push their economy to levels where they will usually have the largest fleets out of all the AI presets after the first hour or so. However, their slow expansion makes them vulnerable to a containment strategy on smaller maps, especially without any modifications to Gameplay.constants, so once again, I would recommend using them on medium or larger maps.
  • Economist AIs are OK without any modding, but useless with modding due to how much other presets improve compared to this one. From my observations, Economist AIs perform the worst in a lot of situations out of all four AI presets; they are generally on par with the Aggressor AI in terms of fleet size, but lack in economy compared to Fortifier and lack in research compared to Researcher. The "Economist" part of their name only applies to their earlygame income, which they spend on ships anyway. In all other aspects, other presets tend to have a much better economy. Economists tend to either be very passive and defensive or overly aggressive to the point of sending their earlygame fleet to harass an enemy's capital instead of taking neutral planets. They expand incredibly slowly and spend most of their income on building ships and tactical structures; if the Researcher preset has been modified to not be such a wuss, Economists tend to be the first to get wiped out in AI FFA's due to their ridiculously slow expansion and suicide mission antics. I recommend you only use this preset sparingly.
In-Game: Faction-specific Behavior
The AI tends to have certain hardcoded behaviors associated with each Sins faction; things get interesting when a modded faction no longer resembles any of the vanilla factions, since the AI then defaults to a 'generic' one. Details/observations for the 'generic' AI are listed in the modding section, though people playing total conversion mods could be interested as well.
  • TEC Loyalists are a beast when it comes to the AI. Not only do they have the economy advantage inherit from being TEC, but they also take advantage of it much more quickly than TEC Rebels (eg. building Trade Ports, conquering neutral planets), since they don't get distracted as easily. Though they don't attack as often as TEC Rebels, when they do, they attack with a massively greater force, especially due to them spending more of their income on bolstering their economy. Their bonuses are also used a lot easier by the AI: it knows how to rush Novalith Cannons and research survivability-boosting techs (I haven't really seen multiple starbases though), and since the AI is very reactionary in its behavior, it will take advantage of the "if enemies in gravity well" bonuses as well. In fact, their only real downside compared to TEC Rebels is that because their cannons don't need missile tech, they won't upgrade missile tech as much in the unmodded game as TEC Rebels. TEC Loyalists is the best AI faction in vanilla Sins, period. I recommend using them with the Fortifier or Researcher presets, though they are so good at bolstering their economy that even the Aggressor and Economist presets are viable.
  • TEC Rebels are usually incredibly aggressive, sometimes overly so: when presented with the opportunity, they are much more likely to start harassing enemy planets, even if they have no siege ships, than to conquer neutral planets. If they start near an opponent, they are much less likely to bolster their economy as TEC Loyalists, plus they don't take advantage of their specialties nearly as much, either (since most, like Truce Among Rogues and Pirate Mercenaries, require tactics that aren't implemented into the AI). I do not recommend you use them on smaller maps, since they are much more likely to send suicide missions to other players' capitols instead of capturing neutral planets while there are still neutral planets to capture. On larger maps, they can get quite formidable, especially if they don't suicide their entire fleet halfway through the game; TEC Loyalists are still better overall though. If you do use TEC Rebels, I recommend the Aggressor or Researcher presets.
  • Advent Loyalists suffers from the fact that while Advent units work by synergizing abilities, the AI has no concept of such synergy, and as such it will play Advent significantly worse than any competent human player. In addition, while human Advent players might know how incredibly powerful Illuminators are, the AI is very slow to get them into play; the case is similar with the Solaris (human players know bombers are better choice for taking out structures in most cases, yet the AI will field them instead of bombers even if they only need to destroy a single starbase). That said, Advent Loyalists suffer even more due to their reliance on lategame techs for their economy coupled with the slow pace AIs generally do research; the lack of unlockables tied to economic techs is also a huge problem in unmodded Sins, since this means the AI will tend to research useless techs instead of economy-improving ones. Oddly enough, Advent AI economies tend to take off later into the game compared to other faction AIs, so while it's generally not too good an idea to use Advent for AIs overall, they aren't completely useless. If you do want to use Advent Loyalists, I recommend the Fortifier presets due to them actually being more research- focused than the Researcher preset, but because of how easy it is to spam Disciple vessels, both Aggressor and Economist AIs are viable on smaller maps.
  • Advent Rebels suffers from the fact that while Advent units work by synergizing abilities, the AI has no concept of such synergy, and as such it will play Advent significantly worse than any competent human player. In addition, while human Advent players might know how incredibly powerful Illuminators are, the AI is very slow to get them into play; the case is similar with the Solaris (human players know bombers are better choice for taking out structures in most cases, yet the AI will field them instead of bombers even if they only need to destroy a single starbase). I tend to find that Advent Rebels perform much better than Advent Loyalists, sometimes better than even TEC Rebels or Vasari Rebels, due to their unique techs being both mostly unlockable earlygame, requiring a lot less specialized tactics than the Advent Loyalist techs, and synergizing quite nicely with the whole Disciple-vessel-spam tactic Advent AIs usually employ at the beginning of the game. The fact that said techs generally help Advent players' economies earlygame adds to this advantage on lower difficulty levels. Oddly enough, Advent AI economies tend to take off later into the game compared to other faction AIs, and couple this with the earlygame economy boost from Advent Rebels' techs, and you have yourself a quite capable Advent AI. I tend to find that for Advent Rebels, the Fortifier preset concentrates the most on overall research while still properly expanding and maintaining a fleet (the Economist preset concentrates on Civilian Research, while the Researcher preset concentrates on Military Research, but both are eventually beaten in their focused categories by the Fortifier preset), so I would highly recommend using the Fortifier preset.
  • Vasari Loyalists are just below TEC Loyalist AIs with being the most capable, and for similar reasons. Except for the whole mobile labs/planet stripping thing, none of their unique techs really require any "specialized" tactics to use; they even provide a tiny economic benefit by getting credit income from capital ships. This is in addition to how powerful Kosturas are compared to other superweapons and how Vasari don't need to send out colony ships to capture neutral extractors (it's not that this ability is so powerful, it's that the AI knows what to do with scouts more than it does with colony ships); since the AI tends to build colony ships instead of getting a colony capital ship, the fact that Vasari use colony ships for starbase construction only makes things easier for Vasari AI compared to other factions' AIs. However, in longer games, Vasari Loyalist AIs lose out to AIs from other factions due to not upgrading their economy well enough to maintain proper fleets and Vasari ships in general being the least economically efficient. Similarly to TEC Loyalists, Vasari Loyalist AI is good with any preset, though it is still generally better with the Fortifier and Researcher presets.
  • Vasari Rebels are either as capable as Vasari Loyalist AIs or worse than TEC Rebel AIs, depending on whether they have allies or not. Though they don't know how to use Starbase mobilization, arguably the most overpowered tech in the entire game, they know how to use all their other special techs, especially since AIs are usually quite eager to join allies in battle, and they move between phase lanes quite a lot. Of course, Vasari Rebel AIs still have all the advantages of being Vasari for AI (Kosturas, scouts capture extractors, one tech improves both metal and crystal extraction, etc.). Without allies though, a lot of the special techs that the AI knows how to use are worthless, hence why they perform worse than TEC Rebels in those cases. I recommend using the Fortifier or Researcher presets for reasons similar to Advent Rebels.
Modding: Gameplay.constants
aiRetreatThreshold:
This value represents how quickly the AI will retreat: a lower value makes it retreat less often and a higher value will make it retreat more often. More precisely, it is the ratio of total allied time-to-kill to total enemy time-to-kill below which the AI will order a full retreat. 0 will mean the AI never retreats, while values higher than 1 will mean the AI retreats even when it faces a weaker force; though you can set the value to a negative number, it has the same effect as setting it to 0. The actual time-to-kill calculations are highly flawed: for example, they do not consider hit chance, miss chance, or regeneration, they highly overvalue the DPS of anything with a squadron-like attack, they do not consider weapons being on separate banks (this is mainly why AIs overvalue capital ships and Titans), they will disregard allied tactical modules, etc. Decreasing this value does make the AI more consistent, it also makes the AI more reckless, willing to keep fighting even when it would be better to just cut losses, retreat, and regroup. Increasing the value makes the AI preserve its ships a lot more, especially its capital ships, but it also makes its attacks more inconsistent, with occasionally moving units back and forth between an in-combat and an out-of-combat gravity well. As side effects, increasing this value also slightly slows down AI expansion rates, but simultaneously increases AI Capital Ship longevity and overall fleet sizes. Lower values are generally better on smaller maps, while higher values are generally better on larger ones. Also note that the AI will never retreat individual units: retreats are always full retreats, hence why the AI tends to lose its capital ships so often.

PlayerAITable: (under playerAISharedDef)
These are a list of four tables used by the four different AI presets for various stuff. All parameters except for MaxBountyBidCount work in a similar fashion.
  • All values except MaxBountyBidCount: (eg. BuildShip, BuildModuleTactical, etc.)
    Even though these values seem like weights, as in how much a preset emphasizes a certain action, they actually are not. Instead, they are most likely update frequency values: the higher a parameter's value, the more often the AI checks if it can perform that action and if it should. Though this does indirectly affect priorities (an AI with a higher BuildShip value will check to see if it should build ships more often than one with a lower priority, therefore it will eventually have a slightly larger army), it is important to keep in mind that these are still update check frequency values, not priority values (eg. increasing UpgradeResearch to 1000 times its original value will not force the AI to concentrate on Research, and multiplying all values by the same amount shouldn't really change the AI's overall resource allocation, but should let it react more quickly to its environment). Also keep in mind that increasing values to a very high amount will have a performance hit, as the AI needs to do thorough checks a lot more often. Testing shows that the values do not increase check frequency linearly: multiplying a value by 10 has shown to approximately double frequency checks (results seem to roughly correspond with C/log(x+1), where x is the value and C is a time constant determined by various parameters, like game speed). All parameters are rather self-evident in what they control (BuildModuleTactical controls building tactical structures, BuildModuleResearch controls building labs, UpgradePlanetInfrastructure controls building bombing defenses, etc.), but BuildShip only affects military Frigates, Corvettes, and Cruisers and does not affect capital ships or civilian ships. Setting any parameter's value to 0 makes the AI never perform that action, and setting it to a negative number has the same effect.
  • MaxBountyBidCount:
    This is actually pretty straightforward: it is the amount of "bidding spurts" the AI is willing to do before a pirate attack is launched. Changing its value to a different non-zero value will not change the amount of money the AI is willing to spend on bounties, only the number of times it is willing to overtake the existing bounty leader. Setting the parameter to 0 or a negative number will have the AI never spend money on bounties.
Modding: Generic Faction, Ships, and Modules
Generic Faction AI:
This AI is an odd one, not just because it behaves any of the regular faction AIs, but also because it can be triggered in peculiar ways. Though the AIs for the various factions in total conversion mods all use the generic faction AI, modifying the existing, vanilla factions can have the generic AI take over. Generally, if a vanilla faction is changed drastically enough, it will switch to a generic faction AI, though what constitutes a "drastic enough" change is still very much a gray area. For example, mods that remove Titans or Starbases or that completely change superweapons (like my DEFCON mod[forums.sinsofasolarempire.com]) are drastic enough, but disabling corvettes isn't. Due to how the generic faction AI is coded to work with any faction, it is hard to pinpoint exactly how it behaves, especially concerning the presets. However, from various observations mentioned on the Sins forums, the generic faction AI tends to be incredibly aggressive, concentrating a lot on massing a giant fleet and attacking relentlessly, similar to TEC Rebels or Advent AI. Oddly, although AIs for vanilla factions are hardcoded to research the relationship-improving techs from the Diplomacy tree, the generic faction AI might not have such hardcoding, which might be one of the reasons it behaves so aggressively.

Planet Modules and Ships:
AIs strongly depend on the *RoleType values assigned to ships and planet modules; contrary to common sense, "strength" calculations are rarely, if ever, done when the AI is deciding what to build. As such, modifying these values (and adding or removing values in the case of ships, which allow multiple *RoleTypes to be defined) will affect what ships/buildings the AI will create, also influencing its army composition. For example, setting the culture module's planetModuleRoleType to "WEAPONDEFENSE" should have the AI building it as if it were a tactical, weapons platform module, while adding the frigateRoleType "AntiModule" to carriers will have the AI building carriers to counter starbases and static defense in addition to actual antimodule frigates like the Ogrev. Keep in mind though that altering these values may have other gameplay effects, notably on autocasting when the "IsDifferentRoleType" aiUseTargetCondition value is used; ships with the "AntiModule" frigateRoleType can only attack structures, so use it only sparingly, even if the AI does love it. For strike craft, the "role" value for the strike craft's squad is used.

An additional thing to note is that the AI handles frigates with bombing damage in an odd fashion: if a frigate can deal damage to enemy planets, the AI will order them to attack the planet upon entering the gravity well, even if they don't have the "Siege" frigateRoleType and/or there are high priority targets (ie. Colony Ships) nearby (thanks Seleuceia!). The AI will also cause the game to crash if it is playing a faction with no frigates that have a particular frigateRoleType, such as "ResourceCollector" (thanks Seleuceia!), and the AI will also be completely immobilized if its faction has no frigates with the "Scout" frigateRoleType.

Messing around with modules' planetModuleRoleType is a lot more risky than messing around with frigates' and capital ships' roleTypes: the game seems to be very particular about certain roleTypes, and will crash if modules of a certain planetModuleRoleType do not comply with its expectations. For example, structures with the WEAPONDEFENSE planetModuleRoleType must have a weapon, otherwise the game will crash when the AI wants to build one. The planetModuleRoleType CANNON will also always have autocast turned on for all their abilities (even if the ability has autocast turned off by default, the AI will turn it on again) and is subject to restrictions set by cannonsPerGravityWellRatio and cannonGravityWellRatioDenominator in Gameplay.constants.
Modding: Abilities
It is important to keep in mind that the AI will automatically use and enable autocast for abilities on ships and buildings of certain roleTypes (eg. Cannon, Scout, Colonizer); otherwise however, if an ability does not have autocast turned on by default, the AI will never use it (thanks GoaFan and Seleuceia!). Consequently, many parameters that affect autocast usage will affect how the AI uses these abilities as well.
  • aiUseTime:
    This parameter controls when an ability is autocast. There are multiple values it can take, you can read up on them in Zombie's soaseplugin wiki here[code.google.com]; the situation each value represents is self-evident from its name. "Invalid" is only used if the ability cannot be autocast, while "NoEnemyShipsInGravityWell" will occasionally get bugged and still trigger if the enemies are militia or civilian ships. Keep in mind that as of now, there is no way to logically manipulate aiUseTime values (ie. use "and", "or", "not", etc.), so you must choose only one, pre-defined value and work with that.
  • aiUseTargetCondition:
    This parameter controls under what conditions the ability is autocast, provided the "when" condition is also met. There are multiple values it can take, you can read up on them in Zombie's soaseplugin wiki here[code.google.com]; the situation each value represents is self-evident from its name. "Invalid" is only used if the ability cannot be autocast and "IsDifferentRoleType" will choose a target that has no common *RoleType (eg. frigateRoleType, planetModuleRoleType) values with the caster entity. Keep in mind that as of now, there is no way to logically manipulate aiUseTargetCondition parameters (ie. use "and", "or", "not", etc.), so you must choose only one, pre-defined value and work with that. Together with two other, specific parameters mentioned later, aiUseTargetCondition is the only logical gate you can really use in tandem with aiUseTime for autocasting.
  • isAutoCastAvailable:
    As per the name, this boolean parameter enables or disables autocasting. If set to FALSE, autocasting is disabled, and both aiUseTime and aiUseTargetCondition must be set to "Invalid". By default, the game only really sets this to FALSE for passive abilities, even for abilities with bugged autocasting (eg. Advent's Resource Focus).
  • isAutoCastOnByDefault:
    As per the name, this boolean parameter controls whether the ability has autocasting turned on by default. The only reason I am mentioning this is that the AI will automatically use and enable autocast for abilities on ships and buildings of certain roleTypes (eg. Cannon, Scout, Colonizer) regardless of whether this parameter is set to TRUE or FALSE; otherwise however, if an ability does not have autocast turned on by default, the AI will never use it (thanks GoaFan and Seleuceia!).
  • ignoreNonCombatShipsForAutoCastTarget:
    As per the name, this boolean parameter controls whether the ability ignores civilian ships (Construction Frigates, Trade Ships, and Refinery Ships, possibly also Colony Frigates, Envoys, and Starbase Constructors) for autocast targetting. Together with aiUseTargetCondition and onlyAutoCastWhenDamageTakenExceedsPerc, these are the only logical gates you can really use in tandem with aiUseTime for autocasting.
  • onlyAutoCastWhenDamageTakenExceedsPerc:
    This decimal parameter controls when an ability is autocast depending on the hull damage the caster has taken as a fraction of its total hull. Despite the name indicating total damage, only hull damage is taken into consideration. Values zero or a negative number will disable this parameter, while values 1 or greater will make the ability never autocast (the caster will be destoyed before the ability is cast). Together with aiUseTargetCondition and ignoreNonCombatShipsForAutoCastTarget, these are the only logical gates you can really use in tandem with aiUseTime for autocasting.
Modding: Black Market and Resources
Credits are the main currency for the AI: from wondering where resources should be spent to whether something should be bought or sold on the Black Market, Credits are what the AI keeps track of, while Metal and Crystal are only considered to the extent that the AI can afford what it wants to do. As a result, while Credits spent on buying Metal and Crystal on the Black Market are kept track of, Metal and Crystal sold for Credits are not.

The AI is very liberal when using the Black Market. When considering what it can afford, the AI will always take the Black Market into account, even if it would result in spending three or four times as much on something. More often than not, the AI will decide what to do and try to find a way to afford it rather than choose something to build or research that it can already afford without splurging on the Black Market. This is why Aggressor Vasari AIs tend to spend mounds on buying metal (Vasari LFs have a fairly high metal cost for their build times and supply usage, so Aggressor AIs who keep spamming LFs will run out of metal real quickly, and their drive to build more ships results in their Metal buying sprees), while Researcher AIs, especially Advent, will tend to spend loads on Crystal.

Resource allocation is driven by the AI's preset. An Aggressor AI is hardcoded to spend more Credits on ships, while Researcher AIs are hardcoded to spend more Credits on research. Note that spending Credits on the Black Market is tracked independently of everything else, so an AI that spends twice as many Credits on a tech due to having to buy Crystal from the Black Market will still only note down the tech's credit cost as "spending on research". The ideal allocations set by each preset don't appear to change over time, resulting in things like the Researcher preset researching every tech up to level 3 right from the getgo. Where things get really wonky are ships that build structures or have abilities that cost resources. Specifically, the AI will not keep track of credits spent on abilities or structures built by ships instead of from planets: in particular, this applies to starbases, Advent mines, and Vasari mines (TEC mines are built from the tactical structures menu, so the AI logs its spending as spending on tactical structures). Spending on ships will always be logged down as such, even if the sole purpose of the ship being built is to construct something, eg. starbase constructors. Starbase upgrades, on the other hand, are kept track of in their own category with its own allocation expectation. This is why, for example, Aggressors tend to have a lot of unupgraded starbases (their hardcoding prioritizes spending on ships, so they will spend lots on starbase constructors, not log down the cost of building a starbase, then not upgrade those starbases because they are hardcoded to not spend as much on starbase upgrades). The AI also has no resource allocation for diplomacy: spending on envoys is recorded as ship spending, spending on unlocking diplomatic actions and abilities is recorded as research spending, and sending resources to other players to complete missions is not kept track of at all.

Due to the resource allocation system and the fact that only Credit spending is kept track of, the AI will like ships and structures that cost a lot of Metal or Crystal compared to those that cost a lof of Credits. For example, if a ship costs 100 Credits and 1000 Metal, the AI will spend 4500 Credits or so on buying the Metal, build the ship, and log it all down as 100 Credits spent on ships and 4500 credits spent on buying Metal. If the AI is an Aggressor AI, it will want a rather large chunk of its spending in the ships category, so it will keep buying the ship until it thinks it has spent enough credits on ships; it will buy 45 more ships than it would otherwise have wanted to had it factored in the credits spent on the ship's metal cost. The extra credits spent on buying metal are logged as Black Market expenditures, which lower the percent of expenditures in all other categories, even the one in which the bought resources were spent (in the case of the example, this would be ships).

Minor note: the AI will always build extractors in the same order, no matter their current income ratios. They will always build metal extractors first and crystal extractors second. When there are multiple asteroids available, the AI will alternate between building the two, but if possible, one metal extractor will always be built before a crystal extractor. This does not appear to apply to capturing neutral extractors (since autocast targeting is what controls AI behavior there).
Modding: Research
Know that when it comes to how quickly the AI will research something, there is very little you can really do to alter the process. Though the AI will not consider a research's cost, it will rarely ever research anything that it cannot afford outside of the hardcoded stuff mentioned later. Observations indicate that AIs select research based on a sort of "tech roulette": at every x second interval, the AI will choose a random tech out of all possible techs in can research. It will then consider if it wants to research that tech or not based on factors not yet known to me; if the AI wants to research the tech, it will queue the tech up, but if it does not, it will wait until the next interval before repeating the process. As a result, the AI will usually research lower tier techs first, but actual research speed's effects are barely noticeable (eg. although Advent AIs usually max the research speed increasing tech pretty early, this has no real long-term effect on their observed research count). Note that techs with hardcoded priority (see "hardcoded stuff") are selected independently from this process.
  • (Hardcoded stuff): (not a parameter)
    The AI is hardcoded to greatly prioritize (read: they will always research, no matter the preset) certain research types under certain conditions. AIs are hardcoded to research every single tech and its prerequisites that unlock ships or planet modules (contrary to certain forum posts though, I have not observed the AI generally taking ship unlocks over building unlocks): for example, this includes the first few levels of the extraction bonus techs for Vasari (unlocks Orbital Refinery), all the regular culture techs for Advent (unlocks Deliverance Engine), and all missile weapon upgrades for TEC Rebels (unlocks Novalith Cannon), but only if it has enough labs to research the prototype (eg. Advent AI will only start researching culture techs after it has 8 civilian labs); however, since the AI can research techs before their labs complete, it may appear that the AI is unlocking techs even before it can research a prototype. Also, AIs are hardcoded to research supply cap and capital ship cap techs, but only if they are at maximum supply and wish to build more ships, to research techs that unlock the colonization of planet types the AI has discovered and wishes to colonize, research wormhole travel unlocking techs if the AI has discovered wormholes, research interstellar travel unlocking tech if there are multiple star systems, and to research planet population cap increases only if they have a planet of that type with maxed population and population upgrades (last one rarely triggers properly). All vanilla faction AIs in Sins are also hardcoded to research the relationship-improving techs from the Diplomacy tech tree. It is possible that the AI is hardcoded to only ever research pacts if it has a peace treaty with at least one other player, but further testing is required to confirm this.
  • priority: (parameter in ResearchSubject)
    This is quite an interesting value and, much like the Autocasting parameters, is often overlooked by people trying to modify AI behavior. Put simply, the value influences a tech's weighting during the tech roulette process: for example, if the AI has two techs available to research, one with a priority of 1 and the other with a priority of 2, the tech with a priority of 2 is twice as likely to be the one selected during the tech roulette. A zero or negative value will tell the AI to never research a given tech unless a hardcoded trigger has been activated: this is why the AI will never research things like planet colonization techs or wormhole travel techs until it discovers wormholes or planets of a given type and why the AI will only ever research supply cap techs if it hits the existing supply cap (the priority value is 0 for all these techs in unmodded Sins). Most techs have a priority value of 1 in unmodded Sins, but as far as I'm aware, the game will accept and properly use any decimal value (possibly limited to the limits of a double-type variable). Note that just because you increase a tech's weighting doesn't mean the AI will want to research said tech, just that it is more likely to be selected during the tech roulette. As a result, if you greatly increase the priority of a tech that the AI rarely finds desirable (for example, Advent's research speed increase on an Aggressive preset), you will actually see a decrease in tech spending, as the AI will keep selecting and discarding the same tech during its selection process. Hardcoded priorities still take precedence however (eg. techs that unlock ships and planet modules, techs that unlock planet colonization, etc.), and they seem to operate independently of the random- tech-selecting algorithm.
  • Dummy Research Ladder: (coding trick)
    This modding trick is probably the main reason people haven't really looked into the priority parameter. I can't remember who came up with the idea (I think it was Lavo_2, GoaFan, and/or Zombie), but for those who don't know, this trick takes advantage of the AI being hardcoded to prioritize techs that unlocks ships/buildings, being able to define 2 research prerequisites for each tech, and being able to "put" research buttons in an off-UI area so that human players will never see it, but the AI can still research it. It essentially involves making a ladder of 0 cost dummy techs, with the bottom of the ladder populated with the game's techs (endpoints for each tech chain are enough) and the top of the ladder containing a tech that unlocks a dummy ship or building that is too expensive for the AI to ever actually make in-game. Since the AI is hardcoded to prioritize unlocks, it will try to unlock the dummy ship, even if the ship is actually too expensive to ever purchase. To do so, it needs to climb up the dummy research ladder, and to do that, it needs to complete every single research in the game. Though the trick renders setting priority values useless and requires a long, ardous setup time (you need to set up a different ladder for each tech tree, requiring about n-1 dummy techs for n total "real" techs), plus you will often get errors in the Dev exe if make multiple-rung ladders (the errors are from the game not knowing what arrows to use to display prerequisites, even if said arrows would not be displayed anyway due to the techs being outside the UI), the payoff is that the AI will highly prioritize certain techs, regardless of its preset. As such, the trick is recommended for a few techs that emphasize a faction's specialization.
Conclusion and Running Test Games
If you want a mod that uses all my listed tricks to improve the game's AI, I recommend you check out Artificial Unintelligence[forums.sinsofasolarempire.com], the mod I worked on in tandem with my AI research. Other mods I have made include DEFCON mod[forums.sinsofasolarempire.com] (the polar opposite of a "Disable Superweapons" mod) and Mundanely Better Rebellion Textures[forums.sinsofasolarempire.com] (a texture and particle effect optimization mod).

Once again, I stress that due to the lack of official sources, all conclusions are based on observations, not analyzing the AI's source code. As a result, it is possible that at least one of my conclusions is very, very wrong, and I am prepared to alter my conclusions should contradictory evidence arise.

Again, the research is very much a work-in-progress: as I continue to expand and double-check my notes, others will also start reporting their own observations, which I will try to aggregate and verify as much as possible. If I am missing something or you think a certain observation/conjecture is incorrect, let me know and I'll see what I can do.

Running test games is an interesting challenge due to some crucial problems with the game's Developer .exe: any time a human is controlling a player with AI enabled, it will automatically set that AI's difficulty level to Vicious, the highest possible. Since the way the AI manages its economy is crucial to the way it behaves, only analyzing Vicious AIs warps your results; the best thing you can do is set all game speeds to Faster and income rates to slow, but this will still give you an incomplete picture. In addition, playing on non-random maps will bias the AI towards certain behaviors, not to mention potentially giving certain AIs an unfair advantage if you are not playing on a fair map (eg. if you are testing presets for a faction, and one player starts near a lot of good planets and/or a large amount of neutral extractors, that preset will perform much better than it should). Right now, the best way I have found to test AIs is to set up a "fair" map in the in-game Map Editor, but add an extra star system with one player and at least 8 pirate bases; then, enable rendering of all objects in the developer menu (third choice under rendering), set up the AIs you want to test, start the game, and hope that you are the one player who starts in the star system with the pirate base. If you are player in the pirate system, pan over to the proper system and start observing; if you aren't, keep restarting the game until you are. Though the setup time is quite long due to all the restarts, especially if you're observing 9 AIs, you have a much greater amount of control when it comes to testing AIs at various difficulty levels.
Saving replays of test cases and watching the same game from multiple perspectives is also viable for testing, but I find it is quite time-inefficient. By enabling the rendering of all objects from the dev menu, you can easily keep track of what all the AIs are doing all the time, and if you're curious about an AI's research path or the abilities it chose for its capital ships, you can just switch active players to that AI at any point in time. Plus in the end, since every game can be vastly different (in AI vs. AI games, the first capital ship chosen and the amount of labs built for both types are both crucial to the game's outcome and, to my knowledge, completely random), it is often better to spend four hours watching two separate test cases than watching a single test case twice.
18 Comments
Eisengratz 5 May @ 10:21am 
Extremely helpful information, thank you!
Hannizio 5 Dec, 2023 @ 6:39pm 
Is the starbase thing really so strong? I never played on higher difficulties, but having like 10 extra upgrades doesn't seem too strong to me, because the amount of upgrades that actually affect combat is still kind of limited, with the rest being mostly utility upgrades. I imagine the time window in which the few upgrades really matter is kind of thin
Techhead7890 9 Aug, 2022 @ 6:55am 
3 years after the last comment but this is still great info, I always wondered why the enemy fleet would just keep bouncing between planets after I trapped them with a fleet on both sides!
Zara Malak 9 Nov, 2019 @ 12:09am 
Great job and great info, thx.
nateyolo98 18 Jul, 2019 @ 2:51pm 
i wish steam allow us to add mod on here
Cytrix, Holder of Pasta 15 Jul, 2017 @ 5:01am 
could we have a version of this guide for the Sins of the Prophets AI? because it feels like that AI is completely ignoring fleet cap, as it fields so many ships that it's impossible to deal with even on Normal
RudiXXX 7 Nov, 2016 @ 6:30am 
Is this mod compatible with version 1.85?
Rivet 30 Mar, 2016 @ 11:28pm 
Delnar_Ersike: I think I get you, I assumed it was preferable to handicap them.
Delnar_Ersike  [author] 30 Mar, 2016 @ 4:42pm 
Rivet: Quickstart should be enabled because player capitols start with all infrastructure upgrades built, whereas with quickstart disabled, you only start with 3 out of 4 infrastructure upgrades. The AI does not know that it should immediately start building the 4th infrastructure upgrade in its capitol, so it'll start at a significant handicap with quickstart disabled.
Rivet 30 Mar, 2016 @ 4:17pm 
When you say you recommend enabling quickstart because the enemy rarely upgrades their capital, do you mean you recommend disabling quickstart?