In all of my mods, making the AI the most functional it can possibly be is amongst my highest priorities. Without going too deep into my game design concepts, AI is a part of a four-section ring, including Gameplay, Graphics, and Sounds, that a mod should strive to deliver.
But the AI in sins is vastly hardcoded. All we have to work with are some values in Gameplay Constants and the roletypes of ships.
After hounding the forums with the search function, I have been unable to find any consolidated source (surprise surprise, looks like this is the way for nearly everything sins-related) of information related to discovering how exactly the AI functions.
From what I've been able to gather, I've made the following concept of how the Ai works in my head,
- The AI functions similarily to the Ai in Age of Wonders 2 in which it calculates some kind of attribute in individual ships to weigh their "power" when engaging enemy forces. This is definitely not damage, because in my current test build of my mod, the AI was suiciding small fleets into a duo of Fear megaships and Blood Moons over and over again who, while they did not have modded health, 1-shotted the smaller capital ships instantly. I suspect it may have to do with health or cost values. When Blood Moons and Fears were not put into the equation, the AI's hid in their systems sins-style in a cold war military-style buildup but did not build that many ships very quickly.
However, the cost thing doesn't make a lot of sense either. With 3 Gorekhans, that cost 2.5k credits a piece, and a slew of Vallus' and a World Eater, all with extremely high damage and the former two with extremely high health, the AI tried to stand and fight with nothing but modded light corvettes that have 6k health but do only 16 damage, and some LRM frigates and his one level 1 capital that died five seconds into the fight. However, when a small Pirate fleet showed up, he ran away.
This will require further experimentation or the input of another individual to formulate a concept of. Since my mod will have three tiers of capital ships, ranging from basic capitals to "Megaships" that are at the end of the tech tree and are exceptionally powerful, I want to see if I can avoid having the AI suicide its units unnecessarily into high-tech fleets. They seem to be reasonably good at avoiding that in vanilla sins, except for starbases, which they don't seem to account for starbase upgrades.
- The values in gameplay.constants potentially function similar to the priority in Starcraft AI handling. So, with the initial values of 5's and 2's and 1's, the 5's have an exponentially greater value than the 2's, which are double the value of the 1's. No wonder why in an 8 hour long game an "Unfair" AI doesn't even get halfway through the upgrades! I set all of theses to 50's and 30's and 45's, but have not yet tested it thoroughly enough to judge if it's making a difference. So far the difference is minimal.
This will require further experimentation and perhaps reducing certain values to try to encourage other values. In particular I want the AI to build a lot of frigate factories (which I set to cost 1 logistics slot) and build many more ships faster. My mod will play more like an RTS and involve much more intense fighting than vanilla sins. The AI will have to keep up in order for the mod to go anywhere.
- The biggest problem of all I ran into was the AI using "fleet" groups. With any capitals even slighter larger than a regular capital, the units would bunch up right around them and try to move "inside them", even to the point of refusing to engage enemy forces that are attacking them. I liked how the AI stuck close to the artillery ships while they bombed the enemy from afar, but if I can figure out how to disable the fleet formations or at least extend the radius of their clustering, I will do that. I found a file called Fleet.entity that I think sets the default formation value for ships. I searched the forum for information on this file and found absolutely nothing of value except for one person referring to a formation setting as "loose". So I changed it from Near to Loose. I haven't tested the changes yet, it's on my slate for today. I am hoping this also changes the AI formation settings. I have no idea if this is the highest maximum setting or not. Why the devs didn't post this kind of information confounds me. Well, really, why anyone would hardcode AI at all confounds me, especially in a game as complex as this.
- What I really want to do right now is figure out how to feed the AI more cash (infinite cash if possible). More cash must mean more ships and better upgrades and researching, right? But I think that's hardcoded. Maybe Diplomacy and it's two additional difficulty levels are what I'm searching for.
Ultimately I don't care if the AI can't micro. If I can get them to build a ton of ships and upgrade fully, I'll be happy. I always play with Locked Teams because I prefer the RTS portion of the game. I'll be removing stuff like allegiance and influence and focusing exclusively on economic, strategic, and tactical elements. If I can turn the AI into an unstoppable killing machine, I'll have achieved my goal. Since this mod will massively increase the depth of researching and upgrading (system stuff like population, mines, ect. will be very numerous and grow exponentially more expensive as you invest into them, allowing end-game to keep growing into the very high-end stuff, while preventing tech rushing at the same time). The first step is to get the AI to invest in the current gameplay elements before increasing their complexity to a point where I'll have no idea how the AI will react.
Now, here's some questions I have;
- I know the AI reads "roletypes" for ship usage. Is it possible to give a ship multiple roletypes?
- When two roletypes exist, how does the AI decide between them? Randomly, cost, cost-effectiveness, strictly from stats, or is this largely unknown? At the very least, has it been observed that they construct both ships with the same roletype?
- If the AI starts off with three capitals - Carrier, Colony, and either Battleship or Support or something, will they build between these three ships or try to tech to build one of the other ones? I noticed in some mods, especially the Star Trek one, that the AI will often disregard getting early capitals and sit there on its ass until it techs to a point where it can build what it wants. This could be bad news.
If there is interest in this subject I will update this thread with my findings as I progress through development, at least until sc2 beta comes out. I consider AI to be one of the most important things of a game, and it is my greatest disappointment in Ironclad that they've hardcoded it to this ridiculous extent. Still, I've worked with Hardcoded games before and pushed above and beyond to deliver the ultimate AI experience (Age of Wonders 2, Starcraft, Diablo 2...), I will try to do so here if it's possible.