Doesn't the AI just assemble an army as big as possible, then check if it is big enough for its goal? So, the AI doesn't build an army which is big enough to accomplish a goal (capture a city), but instead builds a big army and then checks whether its big enough for a goal it then determines (such as capturing a city). Or am I mistaken?
Answering that question isn't easy. Back tracking to try and figure out how the AI is making decisions is complicated by the fact that it's a fairly complicated decision tree. A lot of what I'm reporting is factually incorrect because I'm trying to simplify it as much as possible.
For example, there are different AI settings that can be assigned to units. Some will directly get the UNITAI_CITY_ATTACK value, others will get UNITAI_ATTACK. The former is primarily aimed at attacking cities (obviously), although it can be assigned other tasks if necessary (it can attack adjacent units, etc). The latter is a more general attacker, but also can attack cities. It's attack choices are much different that the former, however.
However, to try and directly answer your question as much as possible, apparently the AI considers a group "ready to attack" if it has:
Code:
(AI_getBirthmark() % (1 + GET_PLAYER(getOwnerINLINE()).getCurrentEra())) + 4
If the AI uses a stupid formula to re-evaluate the attack order, then it will still perform suicide attacks. Maybe less suicide attacks, but it will still happen. Especially since the defender has all kinds of bonuses which are undervalued in a system where strength values are just added to determine stack strength. If a defender has twice the unit strength of an attacker (after modifiers), then it will on average kill more than 2 of such attackers.
I can't tell for sure, but it sounds like you're still a little confused about the strength values. Remember, these are modified strength values. So a Longbow in a city on a hill with CG3, and the city having 60% culture, is going to have a "strength" of 18.6.
I don't know if it's easy to learn the AI to split its army in a few mixed unit-groups.
Neither do I, but I suspect it's not a trivial task.
Pillaging is not very cost-effective, but when the decision is between pillaging and dying against a good city defence, then pillaging is probably better.
Certainly, but those aren't the only options. Again, waiting for reinforcements, retreating, or simply disbanding the stack are all alternatives. I'm just not sure that the damage you'll do to the enemy is worth the benefits they may gain, and the cost to yourself.
But it's probably hard for an AI to estimate these reinforcements.
That's an understatement.
edit: Oh, forgot something else, semi-unrelated to the previous, but also an issue. As it stands right now, if the AI attacks with a stack, it is committed to attacking with the stack. That is, it doesn't alter it's attack decision based on the results of previous fights. This probably also should be changed, yes?
Bh