The Great Apple
Big Cheese
So, I've been poking through the AI combat odds mechanism, comparing Warlords to Vanilla, and to what the human sees, and I have to admit I'm quite suprised at what I see.
Now as far as I am aware combat hasn't changed at all between 1.61 and Warlords. The human combat odds calculater hasn't changed at all, so I think this assumption is probably valid.
A comparison:
Vanilla AI:
Doesn't seem to have been updated to 1.52. As far as I can tell it gets the odds completely wrong, as there was a major change in the way combat works in 1.52. Pre 1.52 a strength 10 unit fighting a strength 5 unit would have a 66% chance of victory (post 1.52 it's ~ 99%). This was changed to be much more in favour of the higher strength unit, but the AI attack odds have not been updated. This means that the AI is overly causious when attacking with overwhealming odds, and overly optimistic when attacking with poor odds.
As you can see, ignoring first strikes gives us simply ((iOurStrength * 100) / (iOurStrength + iTheirStrength)) as the base (before the AI modifiers which are a combination of random numbers and leader behaviour)
Warlords AI:
Seems to have been updated to use the firepower method of calculating odds. As far as I can tell it's alot more accurate. This may be the cause of the vast improvements in the AI's military ability in Warlords - because it actually knows what it's chances of success are.
Human odds:
Excatly the same in both Warlords and Vanilla. Pretty similar to the Walords AI code, but calcualtes everything in a bit more detail. These are the true odds I think.
Now as far as I am aware combat hasn't changed at all between 1.61 and Warlords. The human combat odds calculater hasn't changed at all, so I think this assumption is probably valid.
A comparison:
Vanilla AI:
Doesn't seem to have been updated to 1.52. As far as I can tell it gets the odds completely wrong, as there was a major change in the way combat works in 1.52. Pre 1.52 a strength 10 unit fighting a strength 5 unit would have a 66% chance of victory (post 1.52 it's ~ 99%). This was changed to be much more in favour of the higher strength unit, but the AI attack odds have not been updated. This means that the AI is overly causious when attacking with overwhealming odds, and overly optimistic when attacking with poor odds.
Spoiler Vanilla AI Code :
Code:
// Returns attack odds out of 100 (the higher, the better...)
int CvUnitAI::AI_attackOdds(const CvPlot* pPlot, bool bPotentialEnemy) const
{
CvUnit* pDefender;
int iOurStrength;
int iTheirStrength;
pDefender = pPlot->getBestDefender(NO_PLAYER, getOwnerINLINE(), this, !bPotentialEnemy, bPotentialEnemy);
if (pDefender == NULL)
{
return 100;
}
iOurStrength = ((getDomainType() == DOMAIN_AIR) ? airCurrCombatStr() : currCombatStr(NULL, NULL));
if (iOurStrength == 0)
{
return 0;
}
iTheirStrength = pDefender->currCombatStr(pPlot, this);
if (getDomainType() != DOMAIN_AIR)
{
if (!(pDefender->immuneToFirstStrikes()))
{
iOurStrength *= ((((firstStrikes() * 2) + chanceFirstStrikes()) * ((GC.getDefineINT("COMBAT_DAMAGE") * 2) / 5)) + 100);
iOurStrength /= 100;
}
if (!immuneToFirstStrikes())
{
iTheirStrength *= ((((pDefender->firstStrikes() * 2) + pDefender->chanceFirstStrikes()) * ((GC.getDefineINT("COMBAT_DAMAGE") * 2) / 5)) + 100);
iTheirStrength /= 100;
}
}
return (((iOurStrength * 100) / (iOurStrength + iTheirStrength)) + GET_PLAYER(getOwnerINLINE()).AI_getAttackOddsChange());
}
Warlords AI:
Seems to have been updated to use the firepower method of calculating odds. As far as I can tell it's alot more accurate. This may be the cause of the vast improvements in the AI's military ability in Warlords - because it actually knows what it's chances of success are.
Human odds:
Excatly the same in both Warlords and Vanilla. Pretty similar to the Walords AI code, but calcualtes everything in a bit more detail. These are the true odds I think.