View Full Version : 33,3% damage odds calculator


Mik1984
Mar 13, 2008, 08:12 AM
What about having a calculator that not only shows you the odds of winning the battle, but also shows you the odds of inflicting at least 33,3% damage to the enemy, as well as the odds of suffering more than 33,3% damage.

This could not only have an informative value to the player, but would be a useful to the AI and could fix its deficiencies. The amazing ability of the AI to suicide large stacks in sea invasions combined with the inability of unblocking a city from a single undamaged privateer while having 12 caravels and 4 galleons inside is definitely linked to this issue. AI can't think properly about chances of inflicting damage. It is taught to suicide weaker units, if the odds are bad, but doesn't know the chances of wasting the unit without any effect.

This solution when implemented could help the AI to evaluate the stack battle odds better and improve the gameplay.

Mik1984
Mar 14, 2008, 06:08 PM
Out of first page without a response? Nah, can't be!
BUMP

Civfan333
Mar 14, 2008, 06:28 PM
well, A lot of people post here.......


I think that would be cheap because then you would know how much damage you could do which is impossible......

AfterShafter
Mar 14, 2008, 07:11 PM
well, A lot of people post here.......


I think that would be cheap because then you would know how much damage you could do which is impossible......

You know the chances of doing 100% damage ;) Besides, siege engines show you the chance of doing damage, not of killing the enemy. Doesn't seem that far fetched that regular units would show you a similar tab.

Mik1984
Mar 14, 2008, 07:32 PM
Well the same chance to do 100% damage is not the same chance to deal 33,3% and AI cannot estimate this efficiently. The AI makes its decision upon the chance of win only and cannot take other circumstances properly in consideration. Adding a 33,3% indicator would help the AI not to send 14 riflemen into an MG in a landing raid and to destroy a single privateer by sacrificing 2-3 caravels instead of allowing its capital to be blocked for decades or centuries until he discovers chemistry as well as in all sort of similar situations.

PieceOfMind
Mar 14, 2008, 11:38 PM
Sounds like an intelligent idea. It shouldn't be too much more complicated than the current odds calculator either. If you're building it for AI use though, why not make it a more general function? Hardcoding the 33.3% is pointless if you want to know, for example, the odds of dealing at least one blow of damage or taking at least one blow. If you want it for the player's use as well I think you might be trying to introduce something that would look nastily complicated. Are you making the suggestion for a mod or civ5 or what, or even the next Civ4 patch?

Roland Johansen
Mar 15, 2008, 12:18 AM
It might be interesting to get additional information when you have to decide whether an attack is useful or not, both for the human player and for the AI. But I don't get why you want to know whether you do 33% damage or not. That value seems a bit arbitrary.

Why not just let the computer tell you the expected amount of damage that you're going to inflict and the expected amount of damage that you're going to receive during that battle. (intuitively the same as the amount of damage when averaged over a lot of such battles) That might be a useful value to know. And it's really not hard to calculate.

PieceOfMind
Mar 15, 2008, 06:09 AM
RJ! you might know...
Is there a thread somewhere (I think I remember there being one) where someone went into how the combat odds calculator worked? I want to read over it a bit rather than trying to figure it all out from scratch. But I may be imagining things and it's all just in the head of one of the game programmers.

Refar
Mar 15, 2008, 06:42 AM
Do you mean Arathorns Combat Explained Thread (http://forums.civfanatics.com/showthread.php?t=137615) ?

Mik1984
Mar 15, 2008, 07:29 AM
Yeap, 33,3% is arbitrary. It could be any two other points, but I think 33,3% was the most practical one. Currently you have only the probability of one event, that is victory. By adding one lower event, that is dealing 33,3% damage and one superior event, that is winning and not receiving more than 33,3% damage you can easily visualize how steep the curve of events is. Calculating all probabilities would be too much work and that kind of accuracy is not required for the game purposes. On the other hand information limited to odds of victory seems insufficient, especially for the AI's decision making process.

Roland Johansen
Mar 15, 2008, 07:41 AM
RJ! you might know...
Is there a thread somewhere (I think I remember there being one) where someone went into how the combat odds calculator worked? I want to read over it a bit rather than trying to figure it all out from scratch. But I may be imagining things and it's all just in the head of one of the game programmers.

Do you mean Arathorns Combat Explained Thread (http://forums.civfanatics.com/showthread.php?t=137615) ?

The Combat Explained thread written by Arathorn and linked here by Refar contains an excellent explanation of the combat rules. The information contained in that thread is enough to exactly calculate the odds of winning or losing in combat. However, the thread describes how combat works and thus contains the information needed to calculate these odds, but it doesn't explicitly describe the formula to calculate the combat odds.

I don't know if anyone has explicitly written down this formula in a thread. I would just use from Arathorn's 'Combat Explained' thread to derive a formula. The odds-calculation that you can derive from Arathorns 'Combat Explained' thread should be the same as the one used internally by the game.

Yeap, 33,3% is arbitrary. It could be any two other points, but I think 33,3% was the most practical one. Currently you have only the probability of one event, that is victory. By adding one lower event, that is dealing 33,3% damage and one superior event, that is winning and not receiving more than 33,3% damage you can easily visualize how steep the curve of events is. Calculating all probabilities would be too much work and that kind of accuracy is not required for the game purposes. On the other hand information limited to odds of victory seems insufficient, especially for the AI's decision making process.

But why not just calculate the expected amount of damage that the winner and loser will inflict upon one another. That isn't very hard to calculate, it's not too much work.

You could still ask exactly what information you'd want:
For the one with the higher victory odds:
A The expected amount of damage that it will sustain when victorious
B The expected amount of damage that it will sustain

For the one with the lower victory odds:
A the expected amount of damage that it will inflict when defeated
B the expected amount of damage that it will inflict

Mik1984
Mar 15, 2008, 12:23 PM
By giving expected amounts of damage you omit the very thing that is lacking: the standard deviation from that expected amount.
Moreover the amount of damage the attacker is expected to inflict and the defender to sustain is not very informative, since all cases end up in a cap when one side runs out of health and there is no way to calculate beyond that cap, since your capabilities of inflicting damage depend on the ratio of your remaining :strength: to the enemy's.

Bushface
Mar 15, 2008, 05:24 PM
since your capabilities of inflicting damage depend on the ratio of your remaining :strength: to the enemy's.

No. The damage per hit is calculated on the ratio of unit strengths at the start of the battle and does not reduce as units weaken. Based on this and Arathorn's work, I have written a program which goes through combat round-by-round, examining the probabilities of success by each combatant as the battle progresses until one unit dies.
Running this program for an attacker with strength 1.01 and defender 1.00 gives odds of 62.92% for a successful attack. (There is no chance of either unit getting 33% damage, incidentally, as the attacker does 20 damage per hit and the defender 19.) In more detail, the attacker has :-
0.032 probability of surving undamaged
0.08 probability of surving with 81 HP
0.119 probability of surviving with 62 HP
0.138 probability of surviving with 43 HP
0.137 probability of surviving with 24 HP
0.123 probability of surviving with 5 HP
And the defender has :-
0.015 probability of surviving undamaged
0.046 probability of surviving with 80 HP
0.08 probability of surviving with 60 HP
0.108 probability of surviving with 40 HP
0.122 probability of surviving with 20 HP
Which means that the defender has 0.015+.046+.08 = 0.141 probability of taking 40% damage or less, and the attacker 0.032+0.08+0.119 = 0.231 probability of taking 38% damage or less during the combat.

Note that the actual strengths are not important, it is the ratio between them that matters.

A slight criticism of Arathorn's work is that he shows figures only to two decimal places, whereas even the fourth place can be important. Nor does he refer to experience points, for which there are simple formulae: a successful attack gives INT(4/R) XP and successful defence INT(2/R) with a minimum of 1XP in either case. (R being "attacker's strength" divided by "defender's strength"). For example, if R=2 an attacker gains 2 XP, but if R=2.0001 the gain is only 1 XP with a trivial increase in winning odds.

Mik1984
Mar 15, 2008, 06:21 PM
A slight criticism of Arathorn's work is that he shows figures only to two decimal places, whereas even the fourth place can be important. Nor does he refer to experience points, for which there are simple formulae: a successful attack gives INT(4/R) XP and successful defence INT(2/R) with a minimum of 1XP in either case. (R being "attacker's strength" divided by "defender's strength"). For example, if R=2 an attacker gains 2 XP, but if R=2.0001 the gain is only 1 XP with a trivial increase in winning odds.
Shouldn't the defender get INT(2/(1/R)) instead? The tougher the attacker was, the more XP you get.

Bushface
Mar 17, 2008, 11:29 AM
What should happen and what does happen are, perhaps regrettably, not the same thing. The basic idea is that you get only half the XP from a successful defence that you would from a successful attack involving the same units. Fortunately, a win always brings at least 1 XP.

PieceOfMind
Mar 18, 2008, 09:33 AM
The odds of inflicting at least 33.3% damage to an 80% damaged unit are zero. So are the odds of suffering more than 33.3% damage if you have 80% damage yourself.

Mik1984
Mar 18, 2008, 04:30 PM
The odds of inflicting at least 33.3% damage to an 80% damaged unit are zero. So are the odds of suffering more than 33.3% damage if you have 80% damage yourself.

Inflicting 33,3% damage in this case means reducing his health to 13,33%

Bushface
Mar 18, 2008, 05:53 PM
A unit which is 80% damaged has, very obviously, only 20 HP remaining. But the least damage that can be done is 8 HP, done by a lucky hit from a unit which is facing one which is at least eleven-and-a-half times stronger. Thus one hit will always bring it down to 12 HP or less, a reduction of more than 33.3%. Also, a unit of strength equal to, or better than, the poor battered one with only 20 HP will do 20HP damage or more and kill with just one hit.

PieceOfMind
Mar 18, 2008, 09:11 PM
Inflicting 33,3% damage in this case means reducing his health to 13,33%

But would you consider it useful information that your axeman has a, say, 50% chance of inflicitng 33.3% damage to an already 90% damaged modern armor?

I'm just saying that if you try to base any AI decisions off of a calculation of what percentage damage they do, then dealing 33.3% damage to an already severely damaged unit is very different (value wise) to dealing 33.3% damage to a healthy unit. Something doesn't seem consistent there.

Roland Johansen
Mar 19, 2008, 02:22 AM
My main objection would be the one that Bushface keeps bringing forward in many incarnations. When you're looking at the event of doing at least 33.3% damage, then that is pretty meaningless in a system where damage is done in huge indeterminate chunks. In practise (with healthy units) it means that the unit has inflicted an amount of damage between 34% damage and 66% damage and as close as possible to 34% damage. If the unit does damage in chunks of 17 hitpoints or 34 hitpoints, then it means doing 34 or more hitpoints of damage. if the unit does damage in chunks of 33 hitpoints, then it means doing 66 or more hitpoints of damage. There's a huge difference between those events.

If damage were inflicted in a more continuous manner, then it would be more interesting, but now you don't know the exact event that is being calculated for you. It's not clear whether you're looking at 34 or 66 hitpoints of damage (to healthy units).

Krikkitone
Mar 19, 2008, 02:48 PM
Yeah the 2 real stats of importance in deciding to do a combat are

1. Chance I will Win/lose/retreat
2. Average damage I expect to do

Bushface
Mar 19, 2008, 03:19 PM
Damage chunks are not indeterminate, but controlled by the strength ratio between the two units. To do 33 damage per hit needs a strength ratio of 2.93; to do 34 needs 3.16; and both would show odds of >99.9%.
Incidentally, I reckon the best strength ratio to be 2.00 or very slightly less. Then you get winning odds around 99% and 2XP for a win, whereas at 2.001 you only get 1 XP and a trivially higher winning chance.

Roland Johansen
Mar 19, 2008, 03:34 PM
Damage chunks are not indeterminate, but controlled by the strength ratio between the two units. To do 33 damage per hit needs a strength ratio of 2.93; to do 34 needs 3.16; and both would show odds of >99.9%.
Incidentally, I reckon the best strength ratio to be 2.00 or very slightly less. Then you get winning odds around 99% and 2XP for a win, whereas at 2.001 you only get 1 XP and a trivially higher winning chance.

Yes, I know that the damage is governed by the strength ratio of the combatants. The damage chunks are indeterminate in the sense that when you're writing a combat calculator, then you have to take into account that all values of damage between 6 and 60 (or something like that) can be realised and that you don't know what at least 33.3% damage means for a random fight. For some fights it will mean 34% damage, for some fights it means 66% damage. It's vague, it's not clear, for a random fight it's dependant on the strength ratio of the combatants and it won't mean the same for each fight. The value of the statement you have a 70% chance to do at least 33.3% damage is vague, indeterminate, dependant on what chunk of damage is the first that is more than 33.3%.

Bushface
Mar 19, 2008, 03:56 PM
I don't think the OP was concerned with generalities (such as those being considered by PoM, myself, and certain others) but simply wanted a way of considering another aspect of a particular fight beyond the plain chance of winning, probably in cases where the winning chance is low. What, for example, is the chance that a spearman will succeed in scratching the tank he proposes to attack, even though he will (almost) certainly get killed ? Has he a reasonable chance of doing enough damage that a subsequent attack has a decent chance of victory ? The in-game combat calculator gives no answers to these questions.
But writing my own combat program keeps me amused for a while . . .

Roland Johansen
Mar 19, 2008, 04:09 PM
I don't think the OP was concerned with generalities (such as those being considered by PoM, myself, and certain others) but simply wanted a way of considering another aspect of a particular fight beyond the plain chance of winning, probably in cases where the winning chance is low. What, for example, is the chance that a spearman will succeed in scratching the tank he proposes to attack, even though he will (almost) certainly get killed ? Has he a reasonable chance of doing enough damage that a subsequent attack has a decent chance of victory ? The in-game combat calculator gives no answers to these questions.
But writing my own combat program keeps me amused for a while . . .

If that is the case, then the chance to inflict a single hit is fairly interesting or the average amount of damage that you're going to inflict could be interesting.

But in a subsequent post, he also mentioned that he wanted to know more about the standard deviation of the battle. I can see why he would want to look at the event of inflicting (or sustaining) at least 33.3% damage. However, the fact that combat damage is inflicted in fairly large chunks makes this value less interesting.

Bushface
Mar 19, 2008, 04:17 PM
I agree with your last point. The damage steps are so large as to make SD valueless in this investigation.

Mik1984
Mar 24, 2008, 10:07 AM
I agree with your last point. The damage steps are so large as to make SD valueless in this investigation.

That's true, but going back to the point something like this would be useful anyway, mostly for the AI and a nice gadget for the human player.