This is the Alpha release of a public-code, fairly feature-complete AI that works with Vanilla. It largely replaces all of Vanilla's AI systems under the hood at this point, including some support for System AIs that call Vanilla's System AIs. While this AI isn't perfect, it substantially improves the performance of Starsector in large battles.
It's Alpha, and there are a few bells-and-whistles that don't work or are in need of improvement, but I think it's finally ready for some public testing and comment.
This mod is part of my Mod Pack.
Historically, this AI is an extension of and refinement of the AI I originally wrote for
Vacuum, with a lot of improvements and support for Vanilla features I didn't have in Vacuum (in particular, friendly fire being a thing).
This mod provides:
1. A common framework for developing new mods for StarSector that is mainly
public code, except where StarSector's API is utilized.
I.E.: the code comes with the mod and yes, you can feel free to modify it and redistribute it, so long as you're using it within StarSector. You may also include specialized builds for specific modded ships, in your mods, etc., if you're that ambitious.
Feel free to study how it works if you want to develop practical game AIs, too, but please don't just copy-pasta the core of it into a commercial game, thanks.
2. A fairly well-documented codebase for building new AIs to handle various behaviors in Vanilla without having to reinvent too many wheels.
3. An AI that, while imperfect (see Caveats, below) will give most players a reasonably-good game challenge and better performance in large battles.
4. Very fast performance; the AI and its sub-components are fairly well-optimized, if not perfectly so.
5. AI support for auto-fire weapons that is pretty lean and mean, using the structural optimizations in the base AI.
6. AI support for most, but not all, Missiles (see Caveats), using the structural optimizations in the base AI.
7. AI support for most, but not all, Drones (see Caveats), using the structural optimizations in the base AI.
8. AI support for all of the Vanilla Systems, using the structural optimizations in the base AI.
9. Supports modded Systems that have an AI script defined in the .system file.
10. Unless Alex does something radical to how ModPlugins work or how fundamental calls to Global work, it's pretty future-proof, so we can use this as a base for future work on this area of SS modding.
11. Now supports "blacklisting" of specific hull ids; hulls blacklisted will not use the AI for the ship, the ship's weapons or Systems.
Structure
Each weapon on Autofire, ship on Auto-Pilot and guided missiles / drones (with a few exceptions, see Caveats, below) is assigned an AI via data.scripts.SS_AI_ModPlugin. This is fairly well-documented code, explaining how and why different AIs get assigned to different things, etc.
Once the AIs are assigned, depending on the AI, different things happen, obviously, but:
The AIs all use a common data system; this is part of what makes the AI very fast, by reducing search scopes, etc. This is located in data.scripts.plugins.ShipThreatPlugin.
The AIs call some common methods that are useful and that I (gradually) have cut out duplicates of, etc. to de-clutter the source.
Each ship AI instance calls a number of methods in various classes outside the main class. This was done mainly to de-clutter the main ship AI class so that it's easier to read.
Auto-fire AIs operate completely independently of Ship AIs; this is by design.
System AIs operate completely independently of Ship AIs; this is by design.
Caveats / Mea Culpa
1. The AI doesn't currently support the Avoid command and is, in general, a little weaker in terms of supporting Command Point commands than it should be. You'll see that this is somewhat less-necessary than it is in Vanilla, however; the current (crude) threat-management system does a pretty good job of keeping Frigates from attacking far-more-powerful enemies, for example.
2. The AI's support for Omni Shields is pretty basic atm, and rather easily exploited.
3. MIRV missiles aren't supported at all atm, due to being unable to get the data I needed from the SS engine atm. Alex says there will be a fix for that, probably not until the next major SS update, though.
4. Drones that use a strict formation aren't supported at all because of other engine-side info I need but can't get (easily / quickly).
5. The Phase Cloak AI is pretty lame right now. I think it'll have to wait until I re-write my threat system.
6. There are probably a bunch of other little problems, goofs, extraneous / inelegant code sections and areas where my documentation fell a little short of ideal. The threat system is very inefficient and inelegant atm and there are some ugly kludges in places where we'll almost certainly have some proper JSON support later on, like missile engine-ignition timers, etc., where I couldn't be bothered this round. Please don't hate on me, I've been Rather Busy for the last year and a half and have only just now had a period of something like free time to get this thing
finally ported out of Vacuum, fixed up and moderately polished so that it's something moderately like Ready.
7. If you think X sucks, fix it, document how the fix works... and send me a fix. Eventually you'll be able to just fork this, when I think it's ready for Git access, but until then, treat this work in the spirit it was given to you.
8. The AI probably has some major ways to exploit it that I don't know about, because I couldn't test every possible squirrel case or weird tactic that could break it. That's OK; we can learn from these things. Just let me know how you exploited it, so that we can all discuss fixes.
9. If you want to write a System AI that makes use of the structural improvements that make the base AI fast, that's non-trivial; we can talk about that later on, if this proves to be a popular project and we all want to use this. Right now, just leave your System AIs alone and they'll Just Work, so long as they don't need AI Flags set.
Lastly... I don't
think there are any crash bugs left, but if there's anything I've learned from SS modding, it's that a public release inevitably means
that Nature will provide the millionth monkey, hah.