Expanding on my previous irrelevant opinion from my reply 41 (not repeated here for brevity):
Data (not John_Hughes' android DATA, the not-capitalized numerical data) -- some is referenced in reply 41:
Strength is determined by # of units, their 'hit points', armor, weapons, strengths&weaknesses relative to attacker's units, etc.
Significant attack failure = more than half attacker strength lost in a failed attack, lesser failure is otherwise.
Upon significant attack failure the strength of the next created attack force doubles, lesser failure would increase by 50%.
And say the formula to determine which target to attack (attackValue) is (defenderStrength x 1) + (distance x 3) -- the lowest value is chosen [better to hit the nearer, stronger target -- up to a point].
And let's say there's 2 possible targets (cities for example):
target1: defenderStrength of 30 and distance of 10 (attackValue of 30x1 + 10x3 = 60)
target2: defenderStrength of 10 and distance of 20 (attackValue of 10x1 + 20x3 = 70)
Target1 is chosen as it's the lower attackValue.
So let's say the first attack was sent out and failed significantly. The AI would learn from this, modifying the next attack as defined above. But let's add in a few more options.
1- Next attack force would be doubled in 'strength' (as mentioned above)
2- A second possibility would be to give defenderStrength a different weight. Let's increase it to 2x (the strategy being to avoid the defenders strong points and hit her/him where she's/he's weakest, even if further away), all else unchanged, so recalculating attackValues:
target1: defenderStrength of 30 and distance of 10 (attackValue of 30x2 + 10x3 = 90)
target2: defenderStrength of 10 and distance of 20 (attackValue of 10x2 + 20x3 = 80)
Target2 is now chosen for the second attack. It's possible that in other situations this won't result in a different target being chosen (I fudged the numbers to get this result
)
We can even modify this a bit more by adding in consideration of distance and attack force composition -- if distance is over a certain value (dependent upon map size) then the attack force composition would shift to faster units (cavalry, or units with movement bonus items, etc.).
3- a third possibility is to combine both 1 and 2 -- a distraction attack, or feint, or an attempt to split the defender's forces. This would entail the AI waiting long enough to construct both attack forces (a disadvantage, but one countered by the advantage of a double attack).
Let's give choice 1 a weight of .5, 2 a weight of .4, and 3 a weight of .1 (weights total 1.0).
Recapping, after the significant failure of the first attack, the AI would learn and respond by:
-50% chance of hitting the same target with a doubled force
-40% chance of bypassing target1 to hit target2 with a doubled force (as the AI's initial assessment of what is required to defeat a certain defenderStrength was insufficient, it learned and adjusted for all subsequent attacks, not just repeats of the initial, failed attack -- and remember that significant success would result in attackStrength being reduced so it's not just a one-way adjustment). This doubled attack force would be comprised of faster units to try to catch the defender off-balance, unable to reinforce the new target in time.
-10% chance of doing both
==============
I don't see this requiring extra files or some special noggin to store and retrieve all that learned knowledge, just modify existing priorities/algorithims/weights/data values. The original values would be kept, and there could be checks made against them to keep the modified values from getting too far out of whack (to prevent unforseen interactions) and to 'start over' the next game (or the modified values could be kept to allow the AI to improve from game-to-game, as the human players skill increases).
This involves no 'cheating' by the AI, just the AI adjusting according to successes/failures -- ie learning.