Let's face it: we all know that 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 still put up a fight without resorting to ludicrous resource or stat bonuses. This post contains the following: my attempt at an AI-improvement mod for vanilla Sins of a Solar Empire, observations for players and modders about various in-game AI settings, and observations for modders about various moddable settings and a trick or two that influence how the AI behaves.
Even though my notes may seem thorough, both the research and the mod are 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.
Quick links:
Section 1: Artificial Unintelligence (mod v0.62 for Rebellion v1.82)
This mod takes advantage of the settings and tricks mentioned in Section 3 to make the vanilla Sins of a Solar Empire AI more competent; every single parameter mentioned has been altered, and every single trick mentioned has been used to some extent. The mod also has two gameplay-altering addons that help the AI (they are optional because they actually change gameplay) as well as a standalone addon that changes the way it behaves: The Quick Start modification addon adds a Culture Center to the Quick Start buildings. This was added to make it harder to quickly steal planets near an enemy capitol early in the game, something that the AI is very vulnerable to, and also because AIs will start building culture buildings much quicker if an opponent has already built one, so the Quick Start modification also enables them to get into the culture game faster. Ideally, I would have made the Home Planet improvement add flat culture in addition to its regular bonuses, but I have not found a way to do this, so for now, the Culture Center Quick Start is my best solution. The Kostura modification addon makes Kostura Prototype (the research that unlocks the Kostura Cannon) require 2 levels of NME Warheads. This not only brings the Kostura more in line with TEC and Advent superweapons in terms of how much research is required to unlock it (eg. you can't just build a ton of military labs and rush it, only TEC Loyalists can do that now), but also makes the AI more likely to research phase missile upgrades, since it is hardcoded to prioritize techs that eventually unlock new ships or buildings. The Rabid AI addon forces the AI to use some fallback, faction-generic routines for vanilla Sins factions instead of the usual, faction-specific ones. It is called "rabid" because these routines make the AI both a lot more aggressive and a lot more illogical, as well as introducing bugs into its handling of capital ships. Ship production, tactical structure production, and fleet management are all governed by fallback routines, while faction-specific routines still govern all other aspects (eg. research, starbases, logistical structures). This addon functions independently of other parts of the mod, including the main mod. Enable this addon at your own peril.
Sins Artificial Unintelligence v0.62 [for Rebellion v1.82] can be downloaded here (mirror).
Changes since the last version (v0.60):
Known issues:
Section 2: In-Game AI Info
In the absence of any official information on how the AI's operate, all info had to be acquired through weeks of running test games in various configurations.
General:
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.
Factions:
The AI has a lot of faction-specific behaviors associated with it; not only do AIs of the three/six vanilla factions behave differently based on the factions themselves, but they follow different routines as well. However, if the AI cannot determine which faction it is controlling (eg. as a result of controlling a non-vanilla faction or extensive modding of a vanilla faction), it will instead resort to fallback, faction-generic routines that make it completely differently, to the point of being considered its own "faction" entirely. Note that the AI will not always switch 100% to fallback routines: in some cases, only certain fallback routines will be used, while faction-specific ones will still govern other parts of the AI.
Section 3: Modding AI Info
Since I do not have access to the AI's source code, all statements are based either on in-game observations from tweaking various values and/or on experimentally verifiable observations made by other players and modders.
As a modder trying to get into the AI's head, the Player Info menu ([d] inside the dev menu) is your friend: the four items [a] Show Mission Queue, [b] Show Fleet Comparison, [e] Show Spending, and [f] Show Build Lists are invaluable in relaying what the AI is thinking at any given time.
The AI operates using AI ticks: all AI orders are given out at regular time intervals. To clarify, this means all orders, from selecting techs to retreating fleets, are all given out at the same time, and the AI will wait a few seconds afterwards before giving out its next batch of orders. AI ticks happen roughly once every 10 seconds (9 to 11 income ticks), but they are out of sync between different AI players. To my knowledge, the time interval cannot be modded.
Missions:
The AI gives orders to its ships based on missions the AI creates for itself to complete: it will populate its mission queue with missions, then produce and assign ships based on its current mission queue, rated by priority. Modders can view an AI's mission queue via [d] Player Info > [a] Show Mission Queue from within the dev menu, then selecting a unit, module, or planet belonging to the AI in question. Scout frigateRoleTypes will be sent on Explore missions with targets on enemy, neutral, or undiscovered gravity wells, Colony frigateRoleTypes will be sent on Colonize missions to nearby neutral, colonizable planets, combat ships might be sent on ClearOrbitForColonize missions to nearby colonizable, neutral planets with hostiles in orbit, etc. Note that the AI will never remove missions, only alter their priority; this is why AIs tend to be more and more schizophrenic the longer a game lasts, as their mission queue expands to sizes it can no longer handle properly. The only way for a mission to be removed from an AI's mission queue is if it is completed or if its objective is no longer valid (eg. attack a planet that is now allied, clear orbit for colonization of a planet that was just colonized by an enemy).
Mission .entity Files:Some missions have their own .entity files, allowing modders a limited amount of control over them. Each mission has its own entityType, but all mission entityTypes have only one parameter, missionType. For the game to recognize a mission, its name must match its entityType, so multiple entities corresponding to the same mission are not possible. The missionType parameter is used to direct the AI to the appropriate algorithms. The framework means that, in theory, modders could redirect AI missions. For example, having the MissionAttackPlanet entity have a missionType of Explore would redirect the AI to its Explore routine whenever it wants to attack a planet. In practice however, the different mission types use different internal arguments, so redirects often cause the AI to lock up in the best case (eg. when redirecting MissionAttackPlanet to MissionFosterRelations) or the game to minidump in the worst case (eg. when redirecting MissionBuildMines to MissionBuildStarbase).
Gameplay.constants:
Abilities:
The AI will automatically enable autocast and use certain abilities on ships and buildings of certain roleTypes. For example, abilities will automatically have autocast enabled for CANNON planetModuleRoleTypes. Scout frigateRoleTypes will automatically be assigned to Explore missions (see Missions subsection), even if they lack an Explore-type ability. Colony frigateRoleTypes (and possibly capital ships with the COLONY roleType) will automatically use Colonize-type abilities for Colonize missions. Otherwise however, if an ability does not have autocast turned on by default, the AI will never use it.
Leveling Capital Ships and Titans:The AI will choose a random ability from its unlocked abilities that are at the lowest level, unlocking new abilities only if it cannot do anything else. Abilities with isUltimateAbility set to TRUE will be prioritized over those that are not. As a result, AI capital ships in the base game will always end with two random abilities and their ultimate maxed and will never have a non-ultimate ability more than one level higher than their other unlocked abilties. The same logic appears to govern the way Titans are leveled.
Planet Modules and Ships:
AIs strongly depend on frigateRoleType, planetModuleRoleType, roleType, and role values assigned to ships and planet modules. "Strength" calculations are never done when the AI is deciding what to build. Modifying these values will affect what ships/buildings the AI will create, also influencing its army composition. For example, setting the culture module's planetModuleRoleType to "REPAIRPLATFORM" should have the AI building it as if it were an orbital repair platform, while adding the frigateRoleType "AntiModule" to carriers will have the AI building carriers to try 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, while the roleType value for capital ships is barely used outside of determining which capital ships can colonize.Note that 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.
Frigates with Bombing Damage:The AI handles these 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 game will crash if an AI is playing a faction with no frigates that have a particular frigateRoleType, such as "ResourceCollector" (thanks Seleuceia!); this is likely due to it searching for particular frigateRoleType ships when queuing possible missions (see Missions subsection).
Building Capital Ships:The AI is quite straightforward with building capital ships: if it has no capital ships or its lowest level capital ship is level 3 or higher, it will queue up a random capital ship at its home planet (thanks Lavo_2!). This queue is not the same as the in-game build queue, and the capital ship type will randomly change every AI tick until it actually gets queued in-game. In-game stats have so far shown that capital ship choice is truly random, both for the first capital ship built and for any subsequent capital ships. Giving the AI the means to reach capital ship level 3 quickly, eg. by making the XP cost of the first two levels 0 via gameplay.constants, will force the AI to spam capital ships. Note that if the AI has no capital ship factories, it is hardcoded to prioritize a new capital ship factory in a similar manner; the implementation is a bit buggy though, see the Build List Bugs subsection under Overall Production and Resources.
Building Titans:The AI is prioritized to research titan-unlocking techs; however, it will only actually start construction of a titan once it has enough capital ship slots. Since the AI only upgrades its capital ship slots if it currently has 0 slots, Titan construction is only possible once the AI has researched the first capital ship supply tech that gives 2 capital ship supply, or if it loses a capital ship while having the necessary techs unlocked. By default, this is capital ship supply tech 4, meaning the AI must either lose a capital ship after all titan-unlock techs have been researched or have at least 3 capital ships level 3 or higher before it will even consider titan construction. Once a titan is in a build list, it is hardcoded to have a higher priority than even capital ships, so gathering enough resources for it usually is not a problem for the AI.
Fleets and Army Management:
When managing armies, AIs make constant use of fleets. Though AIs can manage individual ships just as well as fleet groups, fleets will be an AI's smallest army element 99% of the time, so AIs will usually move to target planets as a fleet, retreat as a fleet, and move to locations within gravity wells as a fleet (attacking is a bit different). All AI fleets will adopt a cohesion range of All Standard, regardless of what is set as defaultCohesionRange in Fleet.entity. AI ships will organize into fleets regardless of whether or not autoJoinFleetDefault is set to TRUE or FALSE. However, AI ships that only have certain frigateRoleTypes will never make or join fleets, even if autoJoinFleetDefault is set to TRUE: these frigateRoleTypes are Scout, Colony, ResourceCapturer, ModuleConstructor, Cargo, Envoy, and StarBaseConstructor; Scout is a special case outlined two paragraphs down. Flagships are still included in fleet management processes, but the AI forces them out immediately afterwards, so they are practically exceptions.
Making and Rearranging Fleets:AIs will fire off fleet creation and rearrange routines throughout the entire game. Most creation and rearrangement routines will only fire if any ship in the gravity well has no current order. When a non-fleet combat frigate (any frigate that is created for a frigateRoleType that isn't Colony, Scout, ResourceCapturer, ModuleConstructor, Cargo, Envoy, or StarBaseConstructor) with no current order is in a gravity well or phase jump region that has no fleets and at least one other combat ship, it will initiate a fleet creation function at the next AI tick (roughly once every 10 seconds): either the originator of the creation function or a higher ranking (Titan > highest level Capital Ship > lowest level Capital Ship > Frigates and Corvettes), non-fleet combat ship in the same gravity well (ships in phase space count as being part of the gravity well to which they are jumping) will create a new fleet and invite all other non-fleet combat ships to that fleet. When a combat frigate enters a gravity well or phase jump region that already has at least one fleet, it will initiate a fleet rearrangement process on the next AI tick (roughly once every 10 seconds); every ship that takes part in the fleet rearrangement process (ie. has at least one frigateRoleType that is a combat frigateRoleType) will be part of a fleet after it is completed. All ships in the same gravity well assigned to the same mission (see top of Section 3) will be placed into the same fleet. Note that ships already in the same fleet can still be (re)assigned to separate missions. The AI will periodically check if ships in a fleet are still both in the same gravity well and on the same mission and if not, they will fire off a fleet rearrange. As a result, large fleets phase jumping to a gravity well will often be split up, since even though the ships are on the same mission and in the same fleet, the ships currently in phase space technically are not in the same gravity well as those that are preparing to jump; this triggers a fleet rearrange, splitting up the large fleet,
Scout frigateRoleType Issues:Although the AI treats the Scout frigateRoleType as a non-combat frigateRoleType, the moment a ship with it enters into a fleet with one other ship, even if that other ship is also a scout, it will switch over to a combat frigateRoleType for that ship. Since the AI will not attack with ships that do not have auto-attack turned on, those scouts are dead weight for the rest of the game. The AI will also not build any new scouts, thinking its existing ones (that are dead weight) are enough. A small workaround is to have an explore ability with autocast turned on by default; this will force the AI to still try to keep scouting with its dead weight scouts. However, the AI still recognizes those ships as combat ships, so they will often try to jump back to a gravity well containing normal fleets. If aiUseTime is set to Always on the explore ability, the scout ships will waddle back and forth between trying to scout a gravity well and trying to assist an allied fleet; though this is still no solution, it is better than nothing, and there is little modders can ultimately do to fix the scout grouping bug.
Giving Orders:The AI will only give fleet leaders explicit orders, making non-leader fleet member behavior fairly predictable; the sole exception is any frigate with planet bombing capabilities, who will always be ordered to bomb a planet. Unless the fleet is planning to jump to another gravity well, fleet members will move with the fleet leader at all times, matching the fleet leader's speed. This means that if a fleet member is faster than the fleet leader, it will move slower than usual. If the fleet leader is targeting an enemy that is not in the same fleet as a member's target, the member will move into formation with the leader (matching speed as well) until an enemy that is part of the fleet the leader is targeting enters the member's attack or autocast range; if the member cannot attack (eg. carriers) or doesn't have auto-attack turned on by default (eg. scouts), it will simply stay in formation with the fleet leader.
Overall Production and Resources:
To determine what it wants to spend resources on, the AI keeps track of six total spending queues, or "build lists": one for ships of all types, one for research, one for building research labs, one for building logistical structures that aren't labs, one for tactical structures, and one for planet upgrades of all types. These can be viewed at any time from the dev menu via [d] Player Info > [f] Show Build Lists. Build lists are where the AI queues up stuff it wants to buy but cannot. Every AI tick, the AI will choose a build list to focus on (highlighted in red), trying to buy whatever it can from the focused build queue. The build list to be focused on is determined by a combination of chance, AI preset, current spending allocation, current fleet stance, and the priority of the highest priority item in each build queue. Priority within build queues is largely dependent on hardcoding and AISharedDef values from gameplay.constants. The maximum size of each build queue is determined by AISharedDef values from gameplay.constants, but not in a 1:1 fashion (eg. a value of 3 for BuildModuleResearch will not force the AI to only have 3 items in its labs build list).
Resource Tracking:Credits are the main currency for the AI: they 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. For instance, while Credits spent on buying Metal and Crystal on the Black Market are kept track of in the AI's spending log, Metal and Crystal sold for Credits are not.
Resource Allocation:Current resource allocation can be seen under the [e] Show Spending in the player info menu, while ideal 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. 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 in the first few minutes of the game. Things get really wonky with 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 and non-TEC 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 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.
Black Market: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.
AI Biases From Resource Cost:Due to set-in-stone ideal resource allocations and the fact that only Credit spending is kept track of, the AI will prefer ships and structures that cost less credits but more metal and/or crystals over those that cost more 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, theoretically building about 45 more ships than normally desired. 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).
Extractor Build Order: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).
Build List Bugs:Normally, the AI is programmed to only place items on build lists that are available to it at the time. For example, it will not place frigates in its ship build list that it has not unlocked yet, it will not place social upgrades on its planet upgrade build list when it has already chosen industrial upgrades for all its current planets, etc. There are, however, a few exceptions: the AI does not check if research prerequisites are met before queuing up extractors, frigate factories, capital ship factories, military labs, and civilian labs. While most of these will simply be queued up and forgotten, capital ship factories with research prerequisites will actually cripple the AI until it finally builds one. This is because capital ship factories are given hardcoded priority, meaning the AI will barely build any non-labs logistical structures, including extractors, until it finally satisfies its lust for a capital ship factory.
Research:
AIs have a very set-in-stone method of researching techs, and there is little modders can do to alter the process. Though the AI will not consider a research's cost, it will not try to research anything that it cannot afford outside of the hardcoded stuff mentioned later and the Research Victory tech. Due to the AI's reliance on resource allocation when determining whether it should research a tech or not, AIs will usually research lower tier techs first. Observations indicate that when the AI wishes to research something, it will queue up all techs that are currently available to it in its Research build queue (see Production and Resources subsection), though never queuing up more than one level of a tech at a time. It will then treat its research build list just like any other: rearranging it every AI tick, giving it focus based on the highest item on the build list and its current resource allocation, etc.
Hardcoded Priorities:The AI is hardcoded to greatly prioritize certain techs under certain conditions (they will always occupy the top of the research build list and will often cause the AI to shift focus to it). AIs are hardcoded to research every single tech and its prerequisites that unlock ships or planet modules, though it will only do so once it has enough labs to research all the necessary techs required: 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 once 8 civilian labs are built (unlocks Deliverance Engine), and all missile weapon upgrades for TEC Rebels once 8 military labs are built (unlocks Novalith Cannon). 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. Other techs included in AI hardcoding are as follows: supply cap and capital ship cap techs if the AI has maxed out the respective supply, techs that unlock the colonization of planet types the AI has discovered and wishes to colonize, wormhole travel unlocking techs if the AI has discovered wormholes, and interstellar travel unlocking techs if there are multiple star systems. All vanilla faction AIs in Sins are also hardcoded to research the relationship-improving techs from the Diplomacy tech tree. The AI is hardcoded to only ever research pacts if it has a ceasefire treaty with at least one other player, but said pact unlock techs get hardcoded priority when this is the case.
The priority parameter:This parameter in a tech's .entity file dictates its priority in the research Build List: a tech with a priority of 2 will always be placed above techs with a priority of 1. Techs with a priority of 0 will never be researched by the AI unless they have hardcoded priorities. The game will accept both negative and decimal values for priority (possibly up to the limits of a double-type variable), but it will treat negative priority values as if they were 0. Techs with hardcoded priority are always placed at the top of the list irrespective of their priority parameter value. The AI will rearrange its build list every AI tick, meaning that two techs with equal priority have an equally random chance of being researched before the other. Note that giving a single tech a higher priority value than others may effectively stop the AI from researching completely: since the AI will only ever compare the top items in each build list, and giving a single tech higher priority than all others will place it at the top of the research build list (under hardcoded techs), if the AI never wants to research mentioned single tech, it will never give focus to the research build list, stalling all research.
Dummy Research Ladder:A while back, a coding trick for prioritizing certain techs was developed by a group of enterprising modders, including Lavo_2, GoaFan77, and Zombie. The 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 place tech buttons in an off-UI area so that human players will never see them, but the AI can still research them. It involves making a ladder of 0 cost dummy techs, with the bottom of the ladder populated with actual 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 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), and the effects usually only kick in once the AI has enough labs to research the highest tier tech at the bottom of the ladder, the payoff is that the AI will highly prioritize certain techs, regardless of its preset. Modders who use this trick must choose between two options: either having a smaller ladder, which results in the AI greatly prioritizing certain key techs and relying on the usual process for all others, or a large ladder, which results in the AI prioritizing all techs regardless of preset, but losing focus as a result.
Once again, the contents of this post are subject to change as current observations are reevaluated and new ones are noted down. If you see something missing or not aligning with your own in-game observations, please let me know.
Played some games with this mod and I have to say it does seem like an improvement. The mass carriers built by the AI now makes singleplayer substantially more challenging. My only issue was that in one game I had an AI fall into the jump-in-jump-out loop you described above, causing its entire fleet to be decimated with ease even though it probably could have put up a decent fight if it had tried to do so. I am not sure if this behavior is a result of the mod, however, or if it was already present in the vanilla game. I suspect the latter, although the mod may have made this behavior more likely by changing the retreat threshold.
The AI sometime attacks with too few initial forces, perhaps betting on reinforcements. For example, I've seen it attack a fairly well defended Volcanic (3 Cobalts, 3 Krosovs, 2 Gardas, 2 Javelins) with just 3 Disciples. When these initial forces see themselves overwhelmed, they retreat, which is probably what creates that loop. In that case, the AI also had a capital ship en-route, but before it arrived the Disciples had done two full attack/retreat loops.
We're getting into asides for this thread, but you cannot compute total hp [except in the simple case where each of the opposing fleets consists of a single ship] without taking into account the enemy's [optimal] fire strategy [which can cycle targets on purpose to lower your mitigation], i.e. even at this level of simplification [without even consider maneuvering] the problem is a two-player game in the sense of game theory, not a simple optimization problem. For some fun on that see my thread: https://forums.sinsofasolarempire.com/453834/page/1/
That's usually what happens when attacking neutrals. When attacking players however, the loop is usually caused by something else: the AI wants to move to a gravity well that doesn't contain the enemy fleet, but because it doesn't realize it is order its ships to go through a danger-filled gravity well, it doesn't calculate alternate, safer routes. When the fleets arrive at the enemy-filled gravity well, they do a fleet strength calculation due to the presence of enemies, realize they're outgunned, and order a full retreat back the way they came. When they successfully escape, the AI will probably still choose the same target planet and send the fleet back along the same dangerous route as before, rinse and repeat.
Looked into how shield mitigation changes, the equation is wrong. Problem is that the smallest element of control is a fleet, not a ship, and because multiple ships in the fleet will have different levels of shield mitigation, there is little way the AI can be made to calculate effective HP. On the other hand, if shield mitigation decreases were treated as "passive" DPS, things could still work out (the AI will choose targets to maximize its DPS, so thinking that a ship will receive DPS even if it isn't being fired on would help in calculations). Regardless, this is something for Ironclad to work out, for us modders, the only thing we can do is try to work around faulty AI logic.
Updated main post with research on AI fleet management (lengthy) and also a bit on capital ship ability upgrade logic (short). In the process, I also found an (AFAIK, undocumented) AI bug caused by its grouping of scout ships: in short, the AI will occasionally put scout ships in fleets with other scout ships and/or other ships in general, after which it will no longer use them for scouting, but knows neither how to attack with them nor that it should build more scout ships, resulting in a fairly large handicap when this happens earlier into the game (since certain gravity wells will remain unexplored for a very long time, and the AI never jumps non-scouts to unexplored gravity wells). Head hurts too much to do any further research right now, but I'll see if I can find anything later.
I've witnessed that scout phenomenon. I considered it exceptionally weird for the AI to be jumping in 24 seekers to fight me which then remained stationary and refused to attack. I blew them all up with my Corsev just for lulz.
That scout bug can probably be fixed by turning the autoJoinFleetDefault to FALSE on the scouts.
Nope, the AI ignores autoJoinFleetDefault settings when managing its fleets. For example, Siege frigates have autoJoinFleetDefault set to FALSE, but the AI still groups them into fleets and such. From what I can tell, the only way to fix the bug from the modder's side is to force the AI to send the scout ships into separate gravity wells, which will trigger a fleet rearrange and put the scouts into separate fleets. Having an AI-only scouting ability with autocast turned on might do the trick. Need to test it first though.
EDIT: It kind of works. Got "lucky" with my very first test game, the AI made a 2 scout fleet about 5 minutes in and started doing the usual scout grouping antics. Having Explore on autocast means that the scouts will now spend their time warping back and forth between two gravity wells instead of sitting around doing nothing. It's not really a solution, but having them warp back and forth is better than nothing, plus it makes it more likely that they'll participate in a fleet rearrange and be put into a smaller fleet. Still takes a while for them to get split up into fleets of only one scout ship, but at least it's possible. However, the AI will still treat them like combat vessels, so even once they've split into their fleets of one, they'll spend all their time jumping back and forth between gravity wells: jumping forward due to explore, jumping back due to wanting to help out an allied fleet, rinse and repeat. aiUseTime of Always instead of OnlyWithNoOrder makes them fire off the scouting ability more frequently, so they'll slowly inch their way towards their scouting target, but it's still subpar compared to what I want. I'll need to see if altering their frigateRoleTypes will also work, since I assume the AntiMine frigateRoleType is to blame for them participating in fleet rearrange processes to begin with.
Ah, k, sorry. Guess I misunderstood in that the AI was deliberately putting them into combat fleets, not just the auto-join kicking in (I personally never form fleets... just use the ctrl-# grouping... because their behavior annoys the crap out of me).
Yeah, you'll probably have to bring this to the devs attention as I doubt they'll see this on their own.
Added a bit more info on AI ticks (AI gives orders at regular intervals, roughly once every 10 seconds) and also some info on a neat trick I found out to make low-health capital ships retreat independent of their fleets by exploiting the Explore ability. To be honest, I don't think there's much left for me to analyze in terms of settings to be modified. There are still a few situations I would like to analyze that I have yet to see pop up (GoaFan's capital ship hoarding thing is one of them), but in all other aspects, I think I've covered everything I can.
I'll upload a slightly updated version of the mod itself a bit later, but I doubt I'll make anymore changes afterwards. I'll keep the .entity files in text format though, so as to invite people to make their own modifications; the size difference would be just a few megabytes anyway. It also means modders have to perform one less step when comparing my modified files to the vanilla ones to see what changes I've made.
Very nice work. As a SP-only player this is the only mod I've seen that has really interested me and it does improve the SP gameplay imo. Thanks for your effort.
Uploaded version 0.60 of my mod and included a few more details about the fallback, faction-generic AI in Section 2. The biggest change in version 0.60 is the addition of the Rabid AI standalone addon, which forces AIs controlling vanilla Sins factions to use the fallback, faction-generic routines. It does this via blinding the AI of its faction-specific tactical structures (Shield Generator, Temple of Renewal, Nano Weapons Jammer) by changing their planetModuleRoleType values to REPAIRPLATFORM; since the AI thinks it no longer has access to faction-specific tactical structures, it assumes it is no longer playing as the vanilla factions, causing it to switch over to fallback routines.
In the meantime, I'll be cleaning up my original post a bit, removing "fluff" language, shortening unnecessarily long paragraphs, and generally trying to improve readability.
Great mod.
Can you update the download link please? It's still that of v0.50.
Whoops, link must not have updated, it's fixed now. I've also finished the de-fluffing.
Really, that is what tells the game which AI to use? Or you've just found it to be the most efficient way without really changing anything?
Also, are you sure you WANT to use the generic AI? I'm hardly an expert on it but the faction AIs seem more competent.
From what I've seen on test runs after uploading v0.60, the fallback AI is likely split into multiple parts, and this only triggers some of them. Removing the factions-specific tactical planetModuleRoleType definitely alters the way the AI behaves, but I doubt it is the only way fallback routines can be forced. It's also likely that there are multiple fallback routines, and the AI will gradually adopt all of them as certain key things are removed or altered (I'm guessing Vasari AIs will run even more fallback routines if phase gates are removed or hidden). Either way, I still need to run quite a few tests to confirm or deny my suspicions.
It's why I kept it as an add-on. Some people might like the super-aggressive AI, especially on small maps.
EDIT: Confirmed, the Rabid AI addon makes the AI use fallback code for ship production and management, but it still uses faction-specific code for other things, eg. research (still has same priorities as faction-specific variations) and logistics structures (eg. non-Aggressor Advent heavily prioritize culture centers even if there are no enemy cultures present).
Sorry for the double post, but it turns out I was flat-out wrong about the whole tech roulette thing. Work-in-progress and all that. The actual tech procedure is much more simpler than I thought, though the priority tag still plays an important part. I have updated the original post's Research section to reflect my new findings. Also, I'm suspicious that the playerAISharedDef stuff is also much simpler than I first realized due to guilt by association (the original, complex research process I drafted up turned out to be wrong, so this complex process I drafted up might be wrong as well); I've been double checking my notes and re-running tests as a result.
I have also started delving into diplomatic AI logic; the gameplay.constants section has been updated with the playerDiplomacyAIDef parameters that I have found to directly affect the way the diplomatic AI behaves (things like timeBetweenTreatyOffers are actually quite important and will be addressed in the next version of the mod).
It seems that this change (at least sometimes) results in some undesirable behaviors, like the AI building too many of those units. My friend who's using this mod told me that in his game one of the AIs built like 50 hoshikos.
If it was solely due to AntiMine, the alternative would have been the AI building 50 scout frigates; not exactly the rosiest of situations either way. It's not something I've ever seen before, but it might be because the AI doesn't use as many mines as some human players might. I'll probably spread the frigateRoleType out in the next versions if the AI does actually heavily favor this frigateRoleType in certain situations.
So far, my old playerAISharedDef observations have held up. The playerAITable values definitely increase both build list size and how often build lists change, signalling that the AI does indeed use those values for updating its build lists. The values do not seem to affect which build lists get focus; however, since larger values mean larger build lists, when a category does get focus, an AI with a higher playerAITable value in the category will build more items from that category than if it had a lower value.
Currently mucking about with missions, as in the missions the AI gives itself to complete. Sure, I can't add any new missions, but I can still change the missionType of a mission to that of another one while keeping the .entity file's name. I don't know whether the AI recognizes the old mission .entity or simply ignores it due to mission .entity files containing duplicate missionType values; if it's the former, I'm golden, but if it's the latter, then my redirect attempts won't work.
EDIT: Yup, it's the first one. Redirected the AttackPlanet mission to the Explore mission, now the AI is trying to clear its asteroid with 12 scouts. Too bad there are only 9 missions to play with, 8 if you don't want to rely on a flagship.
EDIT #2: Some missionTypes are more equal than others. If you redirect certain missions to certain other missions, the AI will bug out and not know what to do. A nasty side effect is that its mission queue keeps growing, meaning you'll get ungodly lag within a few minutes of gameplay.
Added to the "Modderss Get An Answer" thread header.
Nice work.
And it's ok...my eyes just stopped bleeding. ; )
Thanks, I've been working on the eyebleed thing for a while now, trying out font sizing, spacing, bolding, etc. Also removed bullet pointing from research section because it was pointless, I think I've done all I can with my limited styling options, reading walls of white text on black background will always be an eyesore. If bolding key words and phrases hurts more than it helps, let me know and I'll remove them (first sentences of each paragraph reveal what the paragraph is about, don't know if keyphrase bolding is redundant).
More AI observations: mission entities are really weird. When matching a mission entityType with an "incorrect" missionType, sometimes the AI knows what to do, sometimes it locks up and fills its mission queue with endless copies of the same mission, and sometimes the game minidumps the moment the AI wants to queue up the modified mission. It's very much a minefield, especially since the .entity files don't contain any information about the mission's arguments (what faction types accept it, what its target is, what valid members are, etc.). I assume wonky behavior and minidumps are caused by argument mismatching (eg. the AI selects the mission entityType with an enemy planet as the target, but the redirect caused by missionType only accepts colonizable neutral planets). MissionBuildMines seems to be especially volatile, likely a result of rigid coding the devs had to do to have one routine cover all building styles (minefield tactical structure, minelayer frigate, minelayer squadron).
Always appreciate people who dig into things.
Updated the main mod to v0.62. Changes include allowing pirates to unlock up to 4 techs every raid instead of up to 2, drastically reducing the AI's diplomacy cooldown times (ie. it will give missions and offer pacts much more frequently), and spreading out the AntiMine frigateRoleType to multiple frigates. The second point was sorely needed by the way: with the default wait time of 5 minutes, AIs would often have all pacts researched and still take forever to offer them to their allies, since there would be a 5 minute wait after each one. Combined with Ship Vision and Planet Vision, it would take over an hour at best for AI allies to agree to all the necessary pacts. With the new cooldown times, best case scenario is now 11 minutes instead of 65 minutes.
The main post has also been updated with some pirateRaidDef info, info on the AI's Titan construction logic, and mission .entity files. I've also made things look a bit cleaner, replacing bolded keywords/phrases with subsection titles and using more consistent formatting.
I know I've said this before, but I think I've covered most things that need to be covered. pirateRaidDef entries related to raid strength and composition aren't going to be covered, since they are all self-contained (the AI will use the highest pirateRaidComposition whose raidStrengthThreshold has been reached via sum of strengthPerOwnedPlanet*ownedPlanets, strengthPerCargoShip*cargoShips, and strengthPerBounty*highestBounty). I'll be keeping an eye on things I might have overlooked or misjudged, but changes to the mod and the main post will hopefully be few and far between.
I really love this mod.... I just have one thing that's been driving me crazy that I would really appreciate some help with.
Normal is too easy and hard is too hard. Or rather I should say, hard isn't too hard but I don't enjoy the way I'm forced to play.
I would like the AI to behave like the hard AI but without the resource bonus. So I've been trying to write a research tech that will implement "IncomePercLost". I have written one but it looks like the AI never uses it.
The question is, is there somewhere in the Artificial Unintelligence mod where I can implement an "IncomePercLost" penalty on the AI? This may be easier for me to implement, because I am not generally a modder and so I am having trouble figuring out how to force the AI to research my tech.
In fact I'm not even completely certain that the tech I created is really an option for the AI to research, because I have yet to see it show up on the research developer screen. Any help here would really improve my enjoyment and would be greatly appreciated.
There's no way to force the AI to research the tech: the best you can do is make it zero cost and tier 0, since the AI, especially Hard AI, will usually research all tier 0 techs. Stick the research into the GameInfo folder, update the six factions' entity files to include the new tech in their tech trees (you probably forgot about this step), and you should be set.
I don't know what you mean by you wanting the AI to play like Hard, but without any resource bonuses. Outside of resource bonuses, Hard is identical to Normal. If you remove the resource bonus for a Hard AI, you'll just end up with a Normal AI. You might have actually been playing against two different presets: the Normal AI was probably Researcher or Economist, while the Hard AI was probably Aggressor or Fortifier. Presets actually do matter quite a bit, so if you want to fine-tune your AI experience, you'll want to set presets manually instead of relying on Random Preset.
There are many great features available to you once you register, including:
Sign in or Create Account