When I started out my goal was just to patch a few egregious issues I was noticing (more on that below), but it ended up growing to include a few other improvements as well. Making the AI run a perfectly optimal economy was never really the goal, so it will still do some suboptimal things. That said, suggestions on how to improve it are welcome.
What started this mod was that, at a certain point in vanilla games, pretty much every AI empire crashes their mineral economy by attempting to build fleet bases on all their systems, even rockballs with maybe 1 or 2 population. This mod attempts to address that and also introduces a few other improvements:
- When deciding what ship to build, the AI now considers the number of turns it will take to build, and recognizes that if a ship takes e.g. 10 turns to build, setting a planet to build that ship will only produce at most 1/10th it's value every turn. It also factors in an opportunity cost related to the fact that getting a ship later is inherently less valuable.
- The AI estimates how long a ship will take to build not only on it's production cost (hammers), but also projects it's current metal income into the future and includes possible future metal shortages in it's build time estimation. Together with the first item, this enables the AI to account for metal costs when deciding what to build.
- The AI incorporates the already completed progress on a ship when estimating it's build time. Together with the first item, this greatly reduces the tendency of the AI to switch production constantly. In fact I find it usually lets ships build until completion, unless e.g. more metal became available, so it can afford to switch to omething better, or the desire for a colony ship or transport took priority, etc.
- The AI now calculates the value of potential ships to build using things like the ship's potental damage output, shields, armour, etc.
- When deciding to build defences on a planet, it includes ships in the possible designs to pick from. After all, ships are just as capable of defending as bases are, and so the decision between the two is based on combat value vs build time instead of being limited to bases. When the AI considers to build a base, the opportunity cost is harsher than for ships though since static defences are strategically inflexible.
- The AI also now considers build time when deciding what planetary improvements to build - to an extent. Since improvement slots are limited, as they fill up the AI considers build time to be less important. Once half the improvement slots are full, the AI chooses what to build based only upon what it would like that planet to have, regardless of how long it will take.
- Also adjusted the vanilla improvement build spread. For example, it will now build labs on plants that can have 10+ population, depending on how strongly it desires more research. Also reduced the AI's desire to build farms on poor fertility worlds, though it is still possible.
- The AI estimates roughly how much ship production it can sustain given it's current metal production, and will try to build less factories if it doesn't have enough metal income to sustain them. If it has an excess of metal, it will try to build more factories.
- If the AI doesn't know what to build on a planet, it will try to set either mining, research, or trade focus, instead of setting the planet to auto build.
- The AI now calculates a desire for metal, and may set fully developed planets to focus on mining if wants more (e.g. to meet the estimated metal income needed to sustain production). Non-fully developed plants may also be set to mining focus if the AI is starved of metal (i.e. no metal left and net metal income is negative).
- Removed some limits on AI ship production that seemed unjustified. Now as the AI gets more ships, it's desire for ships will become less urgent, but it only stops producing ships if it won't be able to afford the upkeep.
- If the AI sees that it will run out of coins in two turns, it attempts to set planets to trade focus until its coin income is positive again.
- I've tried to cut down on the scout and colony ship spam. It still builds a lot of scouts though.
- The AI adjusts it's desire for research based on the research of known other empires, instead of being fixed. This desire now affects the amount of labs it builds, instead of only affecting it's decision to focus on research.
- The AI now decides to city plan or manufacture population if doing so would produce more resources than building an improvement.
- The AI now compares it's naval power with that of other empires it knows about when determining the priority to assign to shipbuilding.
- Reduced scout spam.
- AI now accounts for ship industrial cost modifiers when determining it's desired industrial output to metal income ratio.
- The AI will now move population between worlds if doing so would increase the population cap of the destination world and doing so would leave at least 1 pop of that species left on the source world.
- Reworked planetary improvement selection to encourage the AI to build more factories. The AI no longer cares about the build time of improvements, I don't think it was helping. The AI no longer cares about max sustainable hammer production - if it has more production capacity than it can supply with minerals, it just tries extra hard to get more mines.
- When determining it's desired mineral income, the AI only looks at planets that have at least one factory.
- Overhauled ship construction desire, to accommodate some important bugfixes in vanilla. I've tried to strike a balance between building up naval power while also allowing for construction of colony ships/outposts/etc.
- If the AI doesn't have enough transports to meet it's food import needs, it assigns a higher priority to civilian transport production.
- The AI will no longer attempt to build ground units on planets that are not fully developed when revolt chance is 0.
- Removed pop transfer code in favour of the vanilla version.
- Reverted some changes related to AI resource pooling, as it was causing the AI to favour cheaper ships excessively. The AI still uses resource pooling, but makes build decisions as if it doesn't.
- Made the AI less afraid of metal shortages
- A fairly critical fix to the strategic ship combat power calculation, that was causing the AI to act somewhat erratically compared to vanilla.
- More tweaks to how the AI handles metal shortages
- Fixed the AI setting mining focus on undeveloped worlds.
NOTE that the latest indev version requires r22220 or later.
LAST UPDATE: 01/05/2018
NOTE: the earliest versions of this mod came in a folder called "StrategyAI", but it has since been renamed to "EconomyAI" (as it does not deal with fleet AI). If you still have the old "StrategyAI" folder in your Mod directory, please make sure to delete it when installing newer versions of this mod.