This mod focuses mainly on target prioritization for the AI, nothing terribly fancy, but I think it does help out the tactical AI in a few areas, especially when using missiles.
EDIT: this post is starting to get out of date, I will eventually get around to updating it but please see the posts later on in this thread for information on more recent updates. please see the changelog at the bottom of this post.
- Ship movement is mostly unchanged; ships pretty much just move towards the closest enemy. However, they now calculate a desired engagement range and stop once they are within that range. This means that ships armed with longer ranged weapons such as missiles or fighters will tend to hang back a bit instead of rushing into close range. Ships attacking with lasers will try to get closer than in vanilla.
- The AI will now assign priority to potential targets in range based on how dangerous they are versus the amount of shields and armour they have. This especially helps the AI when assigning missile targets, since I found it used to be pretty exploitable by throwing some expendable craft ahead of your fleet.
- PD weapons preferentially attack missiles and fightercraft. Most PD weapons just go for the nearest enemy missile, but anti-missiles make an attempt to prioritize.
- Interceptors choose whether to attack missile/bombers or ships by comparing the priority of friendly ships vs the priority of other potential targets. They also take into account how much damage they would deal to an enemy ship vs the damage dealt by the incoming missiles.
- In most cases the priority of a ship is calculated using the amount of damage it can dish out vs the amount of "useless" damage that needs to be chewed through before damaging systems (and thus affecting the combat power of the target). Adjustments are made for a variety of factors, such as hit chance (handles cloaked ships nicely), beam attentuation, etc. Currently the AI doesn't understand shield piercing or armour piercing, so it doesn't take those into account yet. Weapon mods that affect range or fire rate are accounted for by the AI.
- Priorities are dynamic so the AI does a decent job at ignoring crippled ships when there's bigger fish to fry, while concentrating fire on already damaged ships. It's only updated once each turn right now, but I'd like to improve that - just need to figure out a way to do it so that only relevant priorities are updated outside of the once-per-turn recalculation. done.
- Fixed a bug where if stand_off_and_bombard got tripped to true for one side, it would affect both sides and never untrip. I can't be sure if this did affect vanilla since I'm working with modded code, but even in the vanilla lua files I couldn't figure out where stand_off_and_bombard is supposed to be reset.
- Modified stand_off_and_bombard slightly to encourage picket ships to move forwards, providing a bit more of a PD screen.
Obviously this mod adds additional AI calculations to tactical combat. I've tried my best to avoid any egregious performance hits and haven't noticed any slowdowns in my own games, but feedback on this front is appreciated.
More changes since OP (collected from later posts):
Update:
- AI now considers bombers that have not yet launched when deciding what to do with interceptors
- stand off behaviour is limited to the first 30 turns and the AI attempts a cease-fire after 50 turns.
- Carriers now try to move in closer, and targets that are within 1 turn range are treated with much higher priority for fighters/bombers.
- Missiles that are already targeted by interceptors have reduced priority when choosing targets for the next weapon or interceptor
- Interceptors/strike fighters treat missiles/bombers that are farther away with lower priority.
- Major tweaks to the priority calculation used when targeting fightercraft with weapons. Fightercraft now have an inherent priority that reflects the fact that unlike missiles, destroying a fightercraft is like destroying a weapon system, it reduces the offensive capability of the opposing fleet. This priority is calculated much like that of ships, in order to ensure they are mutually comparable. It's based on the damage dealt by the fighter/bomber group vs it's health.
- Shield regeneration now matters more when considering how vulnerable a potential target is.
- Now any non-PD weapon that can target missiles/bombers may choose to do so.
- The AI now considers reserving direct-fire PD for missiles/craft not yet launched if the PD weapon's own ship is within strike range of the missile launcher/craft carrier. Should help the AI deal with energy torpedoes aka plasma launchers.
- AI now considers hit chance when deciding to attack missiles/craft with direct fire weapons.
- Reduced "stand off and bombard" turn limit to 20, cease fire turn limit to 40.
- Interceptors now consider the distance to hostile carriers/launchers when deciding to reserve, while also considering that the hostile missiles/bombers will likely be closer once launched.
- Interceptors now check if they can reach their target in time before it reaches it's target, when considering to intercept in-flight craft.
- Prevents interceptors and PD from all reserving for the same target. They are now aware if other weapons are reserving for the same launcher, and will consider other options.
- Fixed a vanilla bug that was preventing the AI from using assault shuttles/transporters against non-immobilized ships.
- Added threat assessment for ships equipped with boarding modules/shuttles/transporters. Might need tweaking, though it rightly considers military transports very high priority, given their ability to take ships out of combat in a single turn.
- AI now considers reserving PD for enemy assault shuttles. Though I haven't seen PD be particularly effective at destroying them yet.
- Improved the boarder threat assesment. Now based on an estimation of crew damage that would be dealt by a capture attempt. Boarders still tend to be high priority, but it's not as extreme as before.
- The decision to capture vs raid is now based on the estimated crew damage vs the remaining crew of the target ship.
- AI attempts to account for enemy ship movement when determining if it is at risk from assault shuttles or missiles/crafts when reserving PD.
- Removed the simplified algorithm for PD allocation. It's been around since the very first version of the mod, and now that the AI is better able to weigh hostile missiles/crafts against ships I don't think it's needed anymore. Removing it does seem to improve the AI's handling of ships that are equipped entirely with PD weapons, or missile fleets that have run out of missiles.
- Fixed a stalemate bug that occurred when all crafts and all non-PD weapons on all ships have been destroyed.
- Direct fire weapons now also consider the amount of missiles currently launched at a ship when deciding to target it
- Defence value calculation now includes the amount of useless system health (bulkheads, etc) that might soak up system damage
- Combat boarders now use boarding priority to pick the ship they move towards (note that all ships still only ever pick the best of the closest 3 when deciding what to move to).
- Planets are now always considered lowest priority when deciding what to move towards, unless if they are already in weapons range.
- When deciding to attack missiles/craft or reserve PD for unlaunched missiles/craft, the amount of damage the weapon does vs the amount of damage the missile/craft group does has more weight (It's now calculated as missile damage/weapon damage squared).
- For the last item above, now only the individual missile/craft/weapon damage is squared, since the count of missiles/craft can be unreliable. For example if there are multiple craft groups near each other, or multiple launchers on the same ship, the AI only sees each one individually. So now the multiplier is = [ (# of missiles/craft)*(individual missile/craft damage)^2 ]/[ (# of weapons)*(individual weapon damage)^2 ]
- The AI now always moves ships with boarding modules/assault shuttles/transporters last.
- The AI attempts to estimate the survival rate of it's missiles vs PD and overcommits missiles to targets accordingly, instead of using a hardcoded overcommit multiplier.
- The AI will not enter "stand off and bombard" mode if it's estimated missile/bomber survival rate is less than 25%.
- Overhaul of how missiles and fightercraft adjust their targeting priorities based on the distance to potential targets, now takes advantage of the AI's ability to assess the amount of hostile PD.
- Ships armed with missile weapons now adjust their desired engagement range based on the AI's hostile PD assessment.
- A small change that seems to significantly improve how effective the AI is at using PD: Ships that have interception warnings are moved by the AI last, after boarding ships.
- The AI now decides when to retreat ships based on an estimate of the total combat power of all allied ships vs the combat power of all hostile ships
- Unarmed (or disarmed) ships that are not severely damaged now only retreat if the AI thinks it is outnumbered 2:1 now 1.5:1. This means that the AI can now attack defended planets without all the transports running away at the beginning of combat. Unarmed/disarmed ships that are severely damaged always attempt to retreat.
- Armed ships that are severely damaged may retreat only if the AI thinks it is stronger than it's opponent and if removing those ships will not swing the balance of power.
- When the AI orders a general retreat (such as when either the player or strategic AI chooses autoretreat), the AI will attempt to retreat all ships at the same time. This means that if there are any ship types that take multiple turns to retreat, other ships will continue to move forwards and fight to cover them.
- The AI may also decide to order a general retreat if it thinks it is outmatched between 3:1 to 5:1, depending on a couple of factors: the presence of a friendly planet, and the proportion of its combat power that comes from immobilized ships and starbases.
- When retreating, ships that can cloak attempt to do so.
- The AI can now make ships move or face towards missiles/fightercraft that it wants to shoot at with fixed weapons.
- Made carriers even more cautious about launching fighters when heavy PD is present. Now they will not launch fighters at targets that are outside of point blank range in the most extreme case.
- Fixed an oversight that was causing the AI to overestimate the combat power of carriers.
- The AI now factors in the speed of missiles/torpedoes/fightercraft when evaluating weapons, since it does affect how easily those objects are shot down.
- Improved the damage assessment calculation used to decide when a ship retreats.
- Made sure space harpies and ancient super-dreadnoughts don't retreat.
- Fixed fightercraft and missile launchers underestimating the distance to their targets.
- The AI can now move ships and attack with them later after other ships have moved and attacked. It tries to move its tougher ships first, while attacking with its more powerful ships.
- Many tweaks and fixes.
- Bugfixes.
- The AI now factors in armour and shield piercing effects when calculating the priority of potential targets.
- Bugfixes
Special thanks to zolobolo for feedback and testing. This mod has been massively improved because of your feedback.
Note the hash in the filename below is the latest revision. If you downloaded an older version please see the download link below, it may contain bugfixes.
LAST UPDATED: 2018/04/27
Git repository: dropbox link