Expected Outcome in Damage Calculations
Moderator: Forum Moderators
Forum rules
Before posting a new idea, you must read the following:
Before posting a new idea, you must read the following:

 Posts: 14
 Joined: April 27th, 2007, 5:38 pm
Expected Outcome in Damage Calculations
I personally would find it very useful if in the damage calculations window the was an "expected outcome" line.
I have already created a patch for this, but I wanted to know if there was any support on the forums for such a feature.
Here are a couple of screenshots I took from the version I compiled with this feature:
http://psionicsliver.googlepages.com/Sc ... _00000.jpg
http://psionicsliver.googlepages.com/Sc ... _00006.jpg
I have already created a patch for this, but I wanted to know if there was any support on the forums for such a feature.
Here are a couple of screenshots I took from the version I compiled with this feature:
http://psionicsliver.googlepages.com/Sc ... _00000.jpg
http://psionicsliver.googlepages.com/Sc ... _00006.jpg
I am not sure if this is a good idea since I can't see how it would make sense if I get your proposal right. In Wesnoth you can hit or not hit, a part of a hit is not possible. So let's say you have an 18hp unit on 50% defense terrain and a thunderer considers to attack it. Now your calculation would tell him that this unit will probably have 9hp left after this attack which does not make sense to me since this unit will of course either live with 18hp or die so I fail to see how your patch would be an improvement for a player trying to make the right decision.
I was working on the proof of one of my poems all the morning, and took out a comma. In the afternoon I put it back again.  Oscar Wilde

 Posts: 14
 Joined: April 27th, 2007, 5:38 pm
There are 3 situations that I had in mind when proposing this:
1. Two different attacks of a unit deal similar damages, it would be nice to know which one is expected to deal more.
2. Also, if the enemy retaliates with different attacks, which one are you likely to have more HP left after?
3. When attacking with a berserk attack (Dwarvish Ulfserker), how much HP are you expected to have left after the battle?
Often times in these cases the HP bars alone do not provide easily understandable data. However, I agree that it would not always be useful, that is why I wanted to see if there was support for this feature.
1. Two different attacks of a unit deal similar damages, it would be nice to know which one is expected to deal more.
2. Also, if the enemy retaliates with different attacks, which one are you likely to have more HP left after?
3. When attacking with a berserk attack (Dwarvish Ulfserker), how much HP are you expected to have left after the battle?
Often times in these cases the HP bars alone do not provide easily understandable data. However, I agree that it would not always be useful, that is why I wanted to see if there was support for this feature.
 Wintermute
 Inactive Developer
 Posts: 840
 Joined: March 23rd, 2006, 10:28 pm
 Location: On IRC as "happygrue" at: #wesnothmp
this would be pretty easy to impliment, wouldn't it? Just sum up the EV of individual outcomes, which are already calculated and displayed anyway. Personally, I often try to do this in my head, and sometimes it is quite easy:
a grunt attacking might look something like this:
25% no damge
50% 9 damage
25% 18 damage
so overall EV on the attack would be 9. Some cases are harder to do mentally. Why not display the calculation at the bottom of the attack stats?
a grunt attacking might look something like this:
25% no damge
50% 9 damage
25% 18 damage
so overall EV on the attack would be 9. Some cases are harder to do mentally. Why not display the calculation at the bottom of the attack stats?
"I just started playing this game a few days ago, and I already see some balance issues."
If I understand your proposal, you're looking for a statistic for the center of the distribution. You either want mean, median, or mode of the distribution.
Mean makes no sense, as Winter provided with the Thunderer example. Mean also makes no sense if you look at your first screen shot. The attacker obviously is expected to die (82% chance). A 2hp EV is extremely misleading, especially since it's not even possible.
Mode I could see, but it should be pretty obvious: the longest bar.
Median is a possibility, and might be what you're looking for in the berserker attack situation.
I have seen prob. distributions that look uniform over the whole range of unit hp, and in a case like that, a median might be useful.
Mean makes no sense, as Winter provided with the Thunderer example. Mean also makes no sense if you look at your first screen shot. The attacker obviously is expected to die (82% chance). A 2hp EV is extremely misleading, especially since it's not even possible.
Mode I could see, but it should be pretty obvious: the longest bar.
Median is a possibility, and might be what you're looking for in the berserker attack situation.
I have seen prob. distributions that look uniform over the whole range of unit hp, and in a case like that, a median might be useful.

 Posts: 14
 Joined: April 27th, 2007, 5:38 pm
Yes, it is easy to implement, and I've already done an implementation of it.Wintermute wrote:this would be pretty easy to impliment, wouldn't it?
I agree completely, as previously stated, this is meant to be for those cases when it's hard to calculate or compare.Wintermute wrote: Just sum up the EV of individual outcomes, which are already calculated and displayed anyway. Personally, I often try to do this in my head, and sometimes it is quite easy:
a grunt attacking might look something like this:
25% no damge
50% 9 damage
25% 18 damage
so overall EV on the attack would be 9. Some cases are harder to do mentally. Why not display the calculation at the bottom of the attack stats?
I tend to disagree with you about the mean, I find that EV is fairly useful for risk assessment. Like Wintermute I often at least try to calculate it in my head, but it's not always easy. However, I agree that median might be useful.Yogin wrote:If I understand your proposal, you're looking for a statistic for the center of the distribution. You either want mean, median, or mode of the distribution.
Mean makes no sense, as Winter provided with the Thunderer example. Mean also makes no sense if you look at your first screen shot. The attacker obviously is expected to die (82% chance). A 2hp EV is extremely misleading, especially since it's not even possible.
Mode I could see, but it should be pretty obvious: the longest bar.
Median is a possibility, and might be what you're looking for in the berserker attack situation.
I have seen prob. distributions that look uniform over the whole range of unit hp, and in a case like that, a median might be useful.
Someone also just suggested to me displaying the Expected HP remaining if still alive.
So what do people think of these three ideas: Mean HP remaining, Median HP remaining, Mean/Median HP remaining if surviving?

 Posts: 34
 Joined: September 10th, 2006, 11:06 pm
I think the confusion here is the way people are thinking about the concept of "expected value."
It is absolutely essential to point out that the expected value is the mean value of this process, if it were repeated infinitely many times. Earlier posts implied that this value was meaningless, since we can only do a discrete amount of damage, but this is what we all need to remember: Wesnoth is a repeated game. This single attack is not the only action that counts, the outcome of the game is a collection of hundreds of these EV calculations. If we repeat these throughout the course of the game, our damage will eventually converge on the EV.
This is why it is an absolutely vital statistic to calculate  not for the purposes of a single attack, but to calculate your grand strategy. In the earlier stages of battle, when you're not looking at killing a unit (which I will get to), you are looking at wearing down the opponent's hp. This is when EV comes especially important as a statistic  when faced with many possibilities, which one gives you the most bang for the buck?
There was a lot of talk surrounding dead vs. alive, and how that makes EV worthless. This is absolutely true  you need to consider things besides EV at that point (and the current distribution is very helpful). Whenever you are in a very special circumstance, you have to treat that circumstance individually. However, that is not a valid reason to scrap it altogether! That just means we need to be rational and take all strategy into account, of which EV is just a part  but an important part nonetheless.
Since we do these calculations in our head anyway, at the very least at some level, I think it would be nice to have a quick ingame calculation to do it. The implementation would not be difficult, and even if it saves a split second of mental calculation each interaction, it begins to add up. Personally, I've wanted this done for some time.
(A note of caution on the implementation: I would suggest taking expected damage dealt, not the expected opponent's HP (which is what we see currently). The EV function becomes nonlinear when you have a floor of 0, so the EV would necessarily be less than their remaining HP. This implies that you'd be expected on average to kill things less than half the time, even if your actual chances were 99.7%! Clearly this is nonsense. Plus if we wish to compare damage between many different units, it is more readily comparable to look at expected damage dealt and not the cumbersome expected HP remaining.)
It is absolutely essential to point out that the expected value is the mean value of this process, if it were repeated infinitely many times. Earlier posts implied that this value was meaningless, since we can only do a discrete amount of damage, but this is what we all need to remember: Wesnoth is a repeated game. This single attack is not the only action that counts, the outcome of the game is a collection of hundreds of these EV calculations. If we repeat these throughout the course of the game, our damage will eventually converge on the EV.
This is why it is an absolutely vital statistic to calculate  not for the purposes of a single attack, but to calculate your grand strategy. In the earlier stages of battle, when you're not looking at killing a unit (which I will get to), you are looking at wearing down the opponent's hp. This is when EV comes especially important as a statistic  when faced with many possibilities, which one gives you the most bang for the buck?
There was a lot of talk surrounding dead vs. alive, and how that makes EV worthless. This is absolutely true  you need to consider things besides EV at that point (and the current distribution is very helpful). Whenever you are in a very special circumstance, you have to treat that circumstance individually. However, that is not a valid reason to scrap it altogether! That just means we need to be rational and take all strategy into account, of which EV is just a part  but an important part nonetheless.
Since we do these calculations in our head anyway, at the very least at some level, I think it would be nice to have a quick ingame calculation to do it. The implementation would not be difficult, and even if it saves a split second of mental calculation each interaction, it begins to add up. Personally, I've wanted this done for some time.
(A note of caution on the implementation: I would suggest taking expected damage dealt, not the expected opponent's HP (which is what we see currently). The EV function becomes nonlinear when you have a floor of 0, so the EV would necessarily be less than their remaining HP. This implies that you'd be expected on average to kill things less than half the time, even if your actual chances were 99.7%! Clearly this is nonsense. Plus if we wish to compare damage between many different units, it is more readily comparable to look at expected damage dealt and not the cumbersome expected HP remaining.)
WizardMagus, thanks for the nice post.
It sounds like what you want is an expected damage for possible onscreen matchups window, not an expected battle outcome window. Something similar to the current "rollover" of a unit's damage types that tells you resists. However, you'd want something more detailed. eg. for an elvish archer, you'd like to see EV vs. every opposing unit in the game for their possible defenses, ignoring current hp. This would help you in strategic decisions. Does this sound more accurate?
It sounds like what you want is an expected damage for possible onscreen matchups window, not an expected battle outcome window. Something similar to the current "rollover" of a unit's damage types that tells you resists. However, you'd want something more detailed. eg. for an elvish archer, you'd like to see EV vs. every opposing unit in the game for their possible defenses, ignoring current hp. This would help you in strategic decisions. Does this sound more accurate?

 Posts: 34
 Joined: September 10th, 2006, 11:06 pm
Well, I was just thinking in the battle window itself, possibly right above the distribution. It would be difficult to construct a comprehensive list of EV(damage) values in a rollover, because of the number of unit types on the battlefield as well as the different terrains they can inhabit. Any given EV will be highly contextual.Yogin wrote:WizardMagus, thanks for the nice post.
It sounds like what you want is an expected damage for possible onscreen matchups window, not an expected battle outcome window. Something similar to the current "rollover" of a unit's damage types that tells you resists. However, you'd want something more detailed. eg. for an elvish archer, you'd like to see EV vs. every opposing unit in the game for their possible defenses, ignoring current hp. This would help you in strategic decisions. Does this sound more accurate?
I guess my use of "grand strategy" was a little misleading. Mainly when I am doing EV calculations I am on the front lines trying to optimize damage allocation. Obviously this alone is a tactical choice, not a strategic one. My point was just that over many tactical encounters, you will trend towards the EV, and the "grand strategy" involves maximizing that EV in every encounter. Over the long run, you will do more damage, which will wear the opponent down faster and more effectively.
I think the most valuable application would be in dealing with drain units. The distribution shown is meaningless since there are so many branches it cannot display them all and the ones they show often read 23%. An EV would allow you to steadily wear down ghosts, etc, when you don't have an obvious counter like a mage available.
Agreed. I was thinking of a possible secondary screen or option, not just in a rollover, but I hadn't thought about implementation at all.WizardMagus wrote: Well, I was just thinking in the battle window itself, possibly right above the distribution. It would be difficult to construct a comprehensive list of EV(damage) values in a rollover, because of the number of unit types on the battlefield as well as the different terrains they can inhabit. Any given EV will be highly contextual.
I disagree. A poacher at night(54) does more EV to a 17 hp spearman than a thunderer(171), yet the thunderer has a much higher ctk. I'd go with the thunderer, and use the poacher elsewhere, dependent on terrain, of course. On the tactical front line, EV is often misleading. Much of the time, you want kills, and often kills for specific units of yours, and EV doesn't tell you enough. This needs to be calculated per strike, including likelihood of some series X of strikes from units A,B,C.WizardMagus wrote:I guess my use of "grand strategy" was a little misleading. Mainly when I am doing EV calculations I am on the front lines trying to optimize damage allocation. Obviously this alone is a tactical choice, not a strategic one. My point was just that over many tactical encounters, you will trend towards the EV, and the "grand strategy" involves maximizing that EV in every encounter.
Long run, yes, but it doesn't apply to tactical front lines. See above.WizardMagus wrote: Over the long run, you will do more damage, which will wear the opponent down faster and more effectively.
Agreed, but does it really give you more than median or mode?I think the most valuable application would be in dealing with drain units. The distribution shown is meaningless since there are so many branches it cannot display them all and the ones they show often read 23%. An EV would allow you to steadily wear down ghosts, etc, when you don't have an obvious counter like a mage available.
I think my argument for mode, is that it tells you the most likely single outcome of an individual battle. Most often in Wesnoth, players are considered with single battles, and not an infinite string of the exact same battle setup. For "grand strategy," it should be battlenonspecific. For local tactics, it needs to be battlespecific. Mode and Median both satisfy the latter. Mean does not.
The ghost vs. ulf is the problem you're referring to, I believe. I've seen practically uniform distributions coming out of ghost/ulf attacks. Can you make a case for mean over median/mode in this case? I haven't thought about it enough. Remember, the distribution you see in the combat window isn't the true EV as defined above, since ghost hp can't go over 18hp or under 0hp.
If such a display is added to the damage calculation window I also would prefer the display of the expected damage, not the remaining HP.WizardMagus wrote:A note of caution on the implementation: I would suggest taking expected damage dealt, not the expected opponent's HP (which is what we see currently). [..] Plus if we wish to compare damage between many different units, it is more readily comparable to look at expected damage dealt and not the cumbersome expected HP remaining.
That would be really nice to have. E.g. select 3 of your units, select a target unit and get a display of the CTK and maybe the expected remaining HP of that unit . But the user interface for that is probably hard to implement.Yogin wrote:Much of the time, you want kills, and often kills for specific units of yours, and EV doesn't tell you enough. This needs to be calculated per strike, including likelihood of some series X of strikes from units A,B,C.
I don't really see what good would it be to have a display of the expected damage. I mean, what can you do with that information? The expected remaining HP of the opponent on the other hand is useful information, since you can see what are the odds of dropping the enemy to exactly 9 or less HP so your orcish grunt could then kill it in one blow. What good is knowledge of the amount of expected damage dealt for you?taro wrote:If such a display is added to the damage calculation window I also would prefer the display of the expected damage, not the remaining HP.WizardMagus wrote:A note of caution on the implementation: I would suggest taking expected damage dealt, not the expected opponent's HP (which is what we see currently). [..] Plus if we wish to compare damage between many different units, it is more readily comparable to look at expected damage dealt and not the cumbersome expected HP remaining.
Yes, something like that would be very nice, but indeed most likely next to impossible to implement in a convenient manner.taro wrote:That would be really nice to have. E.g. select 3 of your units, select a target unit and get a display of the CTK and maybe the expected remaining HP of that unit . But the user interface for that is probably hard to implement.Yogin wrote:Much of the time, you want kills, and often kills for specific units of yours, and EV doesn't tell you enough. This needs to be calculated per strike, including likelihood of some series X of strikes from units A,B,C.

 Posts: 34
 Joined: September 10th, 2006, 11:06 pm
Two responses to this. The first is to quote myself, because I already acknowledge your point:Yogin wrote:I disagree. A poacher at night(54) does more EV to a 17 hp spearman than a thunderer(171), yet the thunderer has a much higher ctk. I'd go with the thunderer, and use the poacher elsewhere, dependent on terrain, of course. On the tactical front line, EV is often misleading. Much of the time, you want kills, and often kills for specific units of yours, and EV doesn't tell you enough. This needs to be calculated per strike, including likelihood of some series X of strikes from units A,B,C.
The second is that EV could still play a significant part of a slightly more complex (and I think more realistic) scenario. This is a scenario I have run into from time to time, and it is not meant as an attack at you, but just another way to look at things. Let's take your numbers above, but consider the following:WizardMagus wrote:There was a lot of talk surrounding dead vs. alive, and how that makes EV worthless. This is absolutely true  you need to consider things besides EV at that point (and the current distribution is very helpful). Whenever you are in a very special circumstance, you have to treat that circumstance individually.
You are doing battle at a choke point. The spearman is blocking the single hex path through, which is exposed to two of your hexes. You have your footpad, your thunderer, but you also have an additional unit, maybe another footpad. Now, you only have two chances to attack this spearman and kill him. Suppose our CTH is 40%. The thunderer is an allornothing attack, which will admittedly not have a bad CTK. However, if you miss with that shot, it is extremely unlikely that your footpad unit will be able to kill that spearman alone (2.6%). However, consider the case where you have your footpad and the additional unit both attack  each has a low individual CTK, but combined it is actually higher than the thunderer. This could be difficult to calculate alone, but the EV should give you a rough baseline idea.
This could even have further strategic implications: if the previous chokepoint defender (another 17 hp spearman) retreated a few tiles to heal, your thunderer could now slip through the opened breach and kill him with a single shot. You go from a somewhatgood chance of killing one unit and a tiny chance of killing two, to a quite good chance of killing two.
Obviously my example is just as contrived as yours  and if we added a single hit point to the spearman this is all moot.
Now here comes the mathematics, if you don't buy the intuition:
Let's break out the odds and see what strategy comes out on top. Suppose Plan A is go with thunderer on first spearman, then attack with footpads on each target as needed. Plan B, by contrast, is footpads first, thunderer later (if need be). The CTH is 40%. Note that there are rounding errors at each step of these calculations:
Plan A:
CTK both = ~25.8%
CTK one = ~15.9%
CTK neither = ~58.5%
Plan B:
CTK both = ~26.7%
CTK one = ~37.4%
CTK neither = ~35.9%
The problem is variance. The EV of the thunderer is 6.8, but the standard deviation is ~8.33. The EV of the footpad is 9.152, but the standard deviation is ~5.07. Although the footpad is going to do more damage in the long run, the thunderer would have an easier time getting that onehit kill. In your earlier example, we'd want that, since CTK is a definite boon. In my example, however, we'd want to consider the odds of two footpads. It would be 64.1% given the above assumptions, versus a 40% chance for the thunderer. That is a significant difference. However, just knowing that the EV of my two footpads equals 18.3, which greater than his 17 HP, tells me that there MUST be a greater than 50% chance of killing the unit, compared to our straightforward 40% for our thunderer. These kinds of quick and simple calculations using EV can always help you get an idea of things.
My point in this entire exercise is to show that strategy is NEVER that straightforward, but having the EV included can even help during those tricky lifeordeath situations.
I disagree. When your frontlines first meet, you are not immediately thinking about kills  you should be positioning yourself for kills. If you are facing level 3 units, you will not normally be in a position to kill them for some time. This means you want to be concerned with dealing damage quickly and efficiently, and using the highest EV over the course of the battle will do this for you.Yogin wrote:Long run, yes, but it doesn't apply to tactical front lines. See above.
I confess, I have really never liked the mode  I have never found it to convey useful information. Within the Wesnothian context, we already have the distribution, and the mode is clearly the longest bar. Now, in complex cases this will not necessarily be shown, but do we care about a mode of 2%? Not really. What we need is a better idea about the distribution, and the mode conveys absolutely nothing about that.Yogin wrote:Agreed, but does it really give you more than median or mode?
I think my argument for mode, is that it tells you the most likely single outcome of an individual battle. Most often in Wesnoth, players are considered with single battles, and not an infinite string of the exact same battle setup. For "grand strategy," it should be battlenonspecific. For local tactics, it needs to be battlespecific. Mode and Median both satisfy the latter. Mean does not.
The ghost vs. ulf is the problem you're referring to, I believe. I've seen practically uniform distributions coming out of ghost/ulf attacks. Can you make a case for mean over median/mode in this case? I haven't thought about it enough. Remember, the distribution you see in the combat window isn't the true EV as defined above, since ghost hp can't go over 18hp or under 0hp.
The reason I think EV is useful in these cases is because over repeated attacks you will converge to that value, and sometimes it honestly takes repeated attacks on a draining unit without a good counter.
Median is a great measure, but I think that we can make a case for EV in these circumstances. The major reason for using the median is because the median is not sensitive to outliers, which is an extremely important property. However, the outliers are extremely important in Wesnoth. I cannot stress this more highly. There really are times where you get off four blows at 30% CTH to kill that annoying footpad, who never hits you once in return. However, this is a rare event, and so will not weight heavily on the EV, but is still extremely critical to take into account.
We just need to be aware of the implications of the median as well: it will most likely be giving you a discrete value, or at best the average of two discrete values. Repeated attacks will NOT converge to this value with any likelihood. This could give you unrealistic results when the distribution is skewed. Remember that for a lefttailed distribution, the median is to the right of the mean, and vice versa. This is going to be a huge problem for using the median, since it will always overestimate damage when attacking targets with less than 50% CTH, and will always underestimate damage for more than 50% CTH. This is precisely the opposite of what we should be thinking!
Consider attacking an Orcish Assassin with a 30% CTH. Suppose you're some random unit with three hits of 10 damage. This gives you eight possibilities: 30, 20, 20, 20, 10, 10, 10, 0. If you take a simple median of these numbers, you get 15. The EV is only 9. Clearly this does not work. If you take the weighted median, you get 10, which is much closer. But then look at the case if you only had two hits of 10 damage. Now you have: 20, 10, 10, 0. The EV is only 6, but the simple or weighted median is 10. That is clearly misleading.
I don't think we can escape the inevitable fact that damage will ultimately converge to the EV. Issues of strategy aside, if we have ANY measure, it needs to be EV.
(Edit: made my 40% CTH assumption clear earlier in the explanation.)
Last edited by WizardMagus on May 4th, 2007, 6:13 pm, edited 1 time in total.

 Posts: 34
 Joined: September 10th, 2006, 11:06 pm
Expected remaining HP and our current distribution are absolutely helpful and indispensible, I completely agree with you there.zookeeper wrote:I don't really see what good would it be to have a display of the expected damage. I mean, what can you do with that information? The expected remaining HP of the opponent on the other hand is useful information, since you can see what are the odds of dropping the enemy to exactly 9 or less HP so your orcish grunt could then kill it in one blow. What good is knowledge of the amount of expected damage dealt for you?
Expected damage is just a supplement. It allows you to make rough calculations on the fly, and it also helps you most effectively wear down your opponent's HP.