I'll try to upload a fixed DLL tomorrow.
v0.96d is available now. Sorry – this took a bit longer because a few other bugs had come to my attention. Some annoying UI issues in networked multiplayer, a problem with the AI closeness cache and, in Elkad's savegame with random personalities, I noticed that the displayed total relations values were counting the hidden modifiers (first impression, rank) and, worse, that none of the memory-based modifiers (e.g. "you declared war on us") were displayed. Also the "Tech" tab showed all rival technologies although tech trading was disabled.
To pick or tie up some other loose ends:
The retreat formula could use some tweaks.
The formula is based on K-Mod's localAttack/DefenceStrength functions. Those functions mostly add up the combat strength (including the various modifiers from abilties and tile defense and adjustments for collateral damage and first strikes) of the individual units, i.e. they assume that two Swordsmen are as strong as one Grenadier. Strategically, I'd say the Grenadier is more valuable than even three Swordsman because it can often engage just one Swordsman at a time (defeat in detail). That's reflected in my war planning code by taking unit power values (which are usually equal to combat strength) to the power of 1.66. When a stack with Grenadiers is already facing a stack of Swordsmen though and the question is mainly which stack is stronger, then I think it's better to assume that the Grenadiers are outnumbered and will have to fight multiple times in a row. (If they aren't outnumbered, they'll have the higher strength value in any case.) Still, a Grenadier is going to be better than two Swordsman. I'm using an exponent of ca. 1.25 now. This change applies not just to the city evacuation check, but in several (probably not all) situations when stack-vs-stack combat is evaluated. Therefore, I'll have to test it more and it's not included in v0.96d. Also not included is code for counting unassigned promotions in the evacuation check and anticipating their healing effect. I did include safety checks before spending Great People and there is (not new) a parameter called AI_EVACUATION_THRESH in GlobalDefines_advc.xml for tweaking the AI behavior. So if the AI generally evacuates too readily, you (
@Elkad,
@Cruiser76) could increase that parameter (at least as a temporary measure).
There are two main issues I have noticed. One, the AI is not understanding the strategic value of certain cities, i.e., the war will likely be lost even when retreating, so it would be better to make a stand or capitulate. This issue will be hard to address. The AI does properly capitulate most of the time. I've been surprised how well it recognizes a lost cause once you deeply penetrate its territory with an overwhelming force.
Evacuation is based on a function called ... "AI_cityValue", which counts the population and per-turn production and commerce yield. I convert that into a percentile rank between 0 and 1 with the least valuable city receiving a 0 and the most valuable a 1. From there, the behavior is simply this:
This requires the attacker's strength to be 150% of the defender's strength even if the city is pretty worthless. I thought of that as a pretty conservative threshold. One problem could be that the strength calculation is off, but perhaps you're also right that sometimes cities with a low-ish rank in terms of population and yields can be worth defending at a 150% strength advantage for the attacker.
If the AI is going to retreat, leaving units behind makes no sense. The AI will often leave 4 or more units behind. Makes some sense from a realism point of view, but none from a gameplay view.
Some 2-4 city defenders left behind can be a bit of a headache for the attacker. You don't want to throw siege units at them and don't want to lose time bombarding the defenses, but if you just attack, you lose, well, probably just 1 unit per defender – after that they're all damaged. However, trading 1 for 1 is pretty good when badly outnumbered overall. Perhaps the problem is that the AI sometimes leaves so many units behind that collateral damage can be employed efficiently.
If cities were vacated, I worry that the attacker could conquer all the peripheral cities at 0 cost and then make peace. Even if this is not such a bad outcome for the defender, who also doesn't lose units, it's unfair (for lack of a better word) to the civs not involved in the war.
Another AI war issue, and this is a long standing issue with the vanilla game, is the unprotected siege attacks in AI territory. The AI will send a small stack (sometimes 1 unit) of siege to attack. These attacks would have much more value if the AI would do it from a city, rather than in open terrain.
Off the top of my head, I couldn't even say which UnitAI routine is responsible for such attacks. Mental note taken, but it doesn't sound like something I can easily improve.
when takingon a city - very hard to win, i had 1 enemy swordsman (why did he defend the city instead of an Axeman?)
and i lost 5++ troops over one unit, and that unit was barely scratched.
very hard to win combats, sometimes the strength value of the enemy will barely change after my unit had died.
Based on the savegame I looked at, this was probably due to Japanese combat modifiers and first strikes (Protective trait, unique unit).
ai is dead in the water. due to islands - no wars. and on the islands that have 2-3 - no wars.
It's not unexpected on island maps and I think not that irrational either. That said, my war planning code assumes weaker resistance from civs that are spread out across multiple landmasses and this was supposed to lead to more/ earlier naval warfare. I'll try to check why this isn't really working.