Combat-odds analysis

Ali Ardavan

Mathematician
Retired Moderator
Joined
May 29, 2002
Messages
2,951
Location
Michigan, USA
To my knowledge no one has yet analyzed the probability of success when a unit attacks another.

The Civ2 manual tells us that when a unit with attack A attacks a unit withe defense D (assuming no fortification, vet status, and terrain bonus for simplicity) then the probability that the attacker wins a round is A/(A+D). Whichever side wins a round its firepower will be deducted from the loser's remaining strength which is 10*hitpoints for a healthy unit. Battle stops when one side loses all its strength.

Assuming the above is true, what is the probability that a given unit wins a battle against another? The answer is not simple and that is probably why it has not been analyzed yet.

This past weekend I analyzed this problem and I believe I have a solution. However, I would like fellow math enthusiasts in the forum (such as Peaster) to check my model.

For simplicity I am going to assume Firepower of 1 and hitpoint of 1. If my model is correct, we can enhance it for arbitrary firepower and hit points later.

The battle can last a maximum of 19 rounds. At the end of round 19 one of the sides must have been hit 10 times and be dead. I model the outcome of each round as A+D possible outcomes. So, in total, there are (A+D)^19 possible outcomes. Next I do a binomial expansion. The probability of the attacker winning is the sum of all those terms where the power of A is 10-19 over the total. That is:
(A^19 + 19*A^18*D + 19-choose-2 * A^17 * D^2 + ... + 19-choose-9 * A^10 * D^9
over
(A+D)^19

For example, if A=2 and D=1 (Horseman attacking a warrior) then the probability of a win is:
(2^19 + 19*2^18 + 19-choose-2 * 2^17 + ... + 19-choose-9 * 2^10) / (3^19)
 
To my knowledge no one has yet analyzed the probability of success when a unit attacks another.

The Civ2 manual tells us that when a unit with attack A attacks a unit withe defense D (assuming no fortification, vet status, and terrain bonus for simplicity) then the probability that the attacker wins a round is A/(A+D).

IIRC there's a detailed write-up on Combat in the GL at Poly, which claims this formula is at best a very rough approximation. I think the article includes a summation formula similar to yours for the probability of success (based on a revised probability). But it's not very practical unless you write a program to calculate it for you. IIRC Boco did that and has posted it as a free download. Some players say it works very well.

To be honest, I find the article hard to follow, and just use VERY rough estimates of attack/defense strengths. If it's really crucial, I'll do a few experiments, to see if my estimates are totally insane.

So, in total, there are (A+D)^19 possible outcomes. Next I do a binomial expansion. The probability of the attacker winning is the sum of all those terms where the power of A is 10-19 over the total. That is:
(A^19 + 19*A^18*B + 19-choose-2 * A^17 * B^2 + ... + 19-choose-9 * A^10 * B^9
over
(A+D)^19
Is B=D? If so (and if P=A/(A+D) is correct), your formula seems OK to me. You could test it by trying "horseman attacks warrior" about 50 times.
:goodjob:
 
Thanks for the response and the link you provided for the detailed right up over at Apolyton in the GOTM forum.
IIRC there's a detailed write-up on Combat in the GL at Poly, which claims this formula is at best a very rough approximation. I think the article includes a summation formula similar to yours for the probability of success (based on a revised probability). But it's not very practical unless you write a program to calculate it for you. IIRC Boco did that and has posted it as a free download. Some players say it works very well.
Now that I have managed to read and decipher their formula I realize that the idea is the same as what I have here but their formula, as stated, has some minor typos.

More specifically, their stated formula is:
SUMn(COMB(n-1,dh-1) * (p^dh) * (1-p)^(n-dh))

Where "n" is summed from dh to dh+ah-1.

ah = Attacker's modified hit points
dh = Defender's modified hit points
p = probability for attacker to win combat round
The correct formula is:
SUMn(COMB(dh+ah-1,n) * (p^n) * (1-p)^(ah+dh-1-n))

Is B=D? If so ...
Yes, thanks for pointing that out. I fixed the original.
 
As I recall, this is the source of the LEO controversy where a vet Musk (3*1.5=4.5) defends better than a rookie Rifle (4). If the Musk rounds down there's no difference in defense, better offense for the Rifle and thus no controversy.
If my understanding is correct, a vet Musket should never be better than a rookie rifleman. I did a search on the title and could not find anything relevant in Civ2 forums.
 
I think we just took the face value, that 4.5 is higher defense than 4. I'm not doubting you, but why wouldn't the vet musk be the better defender? The hp and fp of the units are the same.

Thanx.
 
here is the thread Peaster referred to in the GOTM 73 thread.

http://apolyton.net/forums/showthread.php?s=&threadid=22856

This is the thread where I got the idea that attack and defense factors are multiplied by 8 before calculating the combat outcomes so rounding is less of a problem. This factor makes sense to me since, by doing so, the numbers in the combat calculations will be whole numbers because there are three factors in the calculations (fortifications/walls, veteran, and terrain) and even if all three have a ".5" factor multiplying by 8 (2^3) will bring that to a whole number. My guess is that "normal" for each of those factors is x2, "x1.5" is really x3 and so on.

I didn't re-read the whole thing to see what sort of testing was done, but a pretty simple test is to line up 100 vet warriors on flat terrain and have them attack 100 non-vet warriors on the same terrain. Then do the same with the vets on defense (just to make sure it isn't an attack vs. defense issue). I would suspect the vets would convincingly win both rounds. If so, that would strongly indicate factors like veteran status are not rounded away.
 
Originally posted by Ali Ardavan
Now that I have managed to read and decipher their formula [the one of the Sodaq's thread at Poly] I realize that the idea is the same as what I have here but their formula, as stated, has some minor typos.
I think there are no typos. The problem is the Civ2 manual is not correct:

The Civ2 manual tells us that when a unit with attack A attacks a unit withe defense D (assuming no fortification, vet status, and terrain bonus for simplicity) then the probability that the attacker wins a round is A/(A+D).
Noo. The attacker has a 8*A-side die, the defender has a 8*D-side die. Both throw it, who gets a larger number wins, in case of a tie it is the defender who wins.

I really suggest you to read all the Info:combat thread at Poly.
 
The A/(A+D) formula is also given in the CivII official stategy guide, with the mysterious aside that "a random factor also exists to allow units with a Defense Factor of zero to occaisionally survive an attack".

Another thing stated therein is that fractional results are always rounded down. Unfortunately it doesn't specify where in the calculating process the rounding down gets carried out, which can make quite a difference.

If my guide is accurate in rounding down, all other things being equal the chances of victory for vet musketeers v/s rookie riflemen would then be 1/2

Hah, it's obiviously been a long time since I last did any serious thinking in maths. Given that A=2 and D=1 and that the formula gives 2/3 here and that all other things are equal, it's not clear to me that there is anything complicated in need of analyzing concerning the chances of who'll win. Even with binominal expansion there'd be something decidedly fishy were it to deviate from 2/3. All that you've introduced is that instead of merely win/lose there's also an in between condition; the amount of damage the winner sustains in victory. But then again, I'm no mathematician :)
 
Yech, I've just proved to my satisfaction that with 1 hitpoint meaning between 10 and 19 battles things definately will deviate from 2/3. So I hereby eat the part in my previous posts where I said otherwise

:blush:
 
Originally posted by Clausewitzian
The A/(A+D) formula is also given in the CivII official stategy guide, with the mysterious aside that "a random factor also exists to allow units with a Defense Factor of zero to occaisionally survive an attack".
There is no mystery in Civ2 combat system.

This is the exact citation from the Info: Combat thread:
Each unit gets a randomly generated number from 0 to its modified value minus one, multiplied by a constant. This constant has been best-guessed (based on play testing) to be 8. The unit with the higher random number wins the combat, ties going to the defender.

A 10-attack unit attacks a 0-defense unit:
The attacker has a chance 1:80 it will get "0" on its die. In that case it will lose the round (defender wins ties).

Another thing stated therein is that fractional results are always rounded down. Unfortunately it doesn't specify where in the calculating process the rounding down gets carried out, which can make quite a difference.
As TimTheEnchanter said and the Info: Combat thread shows, there is a constant 8 that causes attack/defense values are rounded down to eights.
For example 1.66 is rounded to 1.625 (=1+5/8).
 
As TimTheEnchanter said and the Info: Combat thread shows, there is a constant 8 that causes attack/defense values are rounded down to eights.
For example 1.66 is rounded to 1.625 (=1+5/8).
If the factor is truly 8, and especially if my assumption that the x8 actually represents a x2 on each of the 3 potential bonus factors (Veteran, Fort/walls, terrain) is correct, and given that all of the bonuses are in 1/2 increments, I don't think there should ever need to be any rounding. Anything with a normal factor gets an x2, anything with a 50% bonus gets an x3, etc.

I'm not sure how you would get a calculated factor of 1.66, unless that is somehow possible by altering the settings and game configuration in a scenario.
 
All talk of operations moving things to multiples of 1/8 is well beyond my knowledge map, just telling what I know from my primary source. But interesting stuff. I didn't know there was a 1/80 chance of a critical loss. It suggests there also ought to be 1/80 chance of a critical win. I'm also surprised that defense always wins the tie. Kinda unfair that.

On the other hand, an attack 1.66, well, that shouldn't be too hard to get, since it is my understanding that units with less movement than one but more than zero operate at 1/3 or 2/3 attack strength. So Crusaders with 1/3 movement left and no mod, for instance, should fit the bill.

Rounding down to 1.625 would make sense in a multiple 1/8 system. In the context of my guide, rounding down meant down to the nearest integer. Like I said, it is beyond my abilities to judge which is the right here.
 
On the other hand, an attack 1.66, well, that shouldn't be too hard to get, since it is my understanding that units with less movement than one but more than zero operate at 1/3 or 2/3 attack strength. So Crusaders with 1/3 movement left and no mod, for instance, should fit the bill.
Gotcha, I forgot about the movement allowance. Thanks.
 
Clausewitzian, I'm not clear how you use the term "critical" loss. In other game systems it is when a random generation causes disproportionate, catastrophic damage on a particular outcome (like "hull breach" if you get a 6). All SlowThinker is illustrating is that there is a 1/80 chance of a unit with zero defense "winning" a combat round.
 
Oh, I was just thinking out loud. My bad if it caused confusion.

OK, I think I get the illustration. If it was an 11-attack unit then it would have been 1/88. Correct me if I'm wrong.


cheers
 
Back
Top Bottom