## Expected Outcome in Damage Calculations

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
taro
Inactive Developer
Posts: 83
Joined: February 4th, 2007, 9:10 pm
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?
You usually attack a target with more than a unit. Because of the lack of option 2 (the display of the CTK for an attack of more then one unit) it's easier to add the values of the expected damages and compare it to the current HP of the target than to add up the differences between current and expected remaining HP. E.g. attack with 3 units:

Code: Select all

``````Display of expected damage:
damage1 + damage2 + damage3 <=> targetHP

Display of expected remaining HP:
remainingHP1 - (targetHP - remainingHP2) - (targetHP - remainingHP3) <=> 0``````
PS: I know you cannot simply add these values, it needs a calculation of the probabilities of all individual strikes (don't ask me for that, there are better experts in this thread ). But if it makes any sense to add such a value to the damage calculation window the expected damage is more easy to handle for the usual case of an attack with multiple units.
Yogin
Posts: 98
Joined: November 18th, 2005, 7:49 pm
WizardMagus,

I assume you mean poacher@night everytime you mention footpad.
And I agree with the tactics. It's obviously better to attack with two poachers vs. a 17hp unit than a thunderer and a poacher. In this case, I think mode and median would lead you to the same conclusion. And yes, both your example and my example are contrived, but also, do happen in Wesnoth quite a bit. As you said,
WizardMagus wrote:Whenever you are in a very special circumstance, you have to treat that circumstance individually.
Your example points to an inability to extend the present combat calculator through more than 1 combat.

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.
Neither have I, but the mode is critical in Wesnoth. The mode tells you the most likely outcome of the next battle. In Wesnoth, I love the mode.

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.
What would you attack a 6 hp 70def unit with? A 6-3 attack with EV of 7 or a 11-2 attack with EV of 7.6? In this example, mode provides the best answer: the 6-3 attack with mode of 6, rather than the 11-2 attack with mode of 0. Otoh, I've come to the conclusion that these examples are silly, I'm sure we could both come up with a dictionary of specific examples supporting each statistic. The question should be one of general usage.
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.
... 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.
Why do I love the mode? Because in Wesnoth, I have the advantage of being able to calculate my next battle conditional on my prior battle. Using the mean ignores this. How often do you re-evaluate what to do in battle situations? Most likely after each combat, since each combat is a unique set of rolls. You might get the mode, you might get that outlier. You have to re-evaluate what you plan to do next based on what happened already. If my grunt cut the opposing assassin from 20hp to 10hp, I'll attack with my second grunt, and go for the kill. Using EV, I never would have attacked an assassin with 2 grunts to go for the kill, since my EV would be less than 14 damage dealt. What is critical is that each planning step is contingent upon what happened in the previous step, and mode helps you best predict that, and best predict the next step.

Take a ghost on a village, for example, if it has 6hp, and my EV damage for attacking with a spearman is 3hp, I might consider attacking with 2 spearman to kill it. If the first spearman is unlucky, and the ghost is now at 10hp, would I continue? No, I would stop, and wait for better reinforcements, rather than continue to take punishment on a futile attack.

However, I do understand what you're trying to do with EV. You're trying to get an idea of how a certain sequence of combats average over time. If I understand correctly, it's not the extremely unlikely situation that I'm going to throw 10 spearmen attacks at a ghost over 2 turns in order to kill it, but rather, if I have a spearman, bowman, HI, and lieutenant, what combination of attacks and positioning will optimize my ability to kill the ghost that's in range of these guys? Honestly, I think you're using the wrong tool for the job. I'll describe a better tool for this in my followup post, and it's not the mode or median.

-Yogin
Yogin
Posts: 98
Joined: November 18th, 2005, 7:49 pm
zookeeper wrote:
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.
Yes, something like that would be very nice, but indeed most likely next to impossible to implement in a convenient manner.
Proposal:
(1) Add a button to the Damage Calculations window, Roll-over Defender HP's. This will save the vector of hp probability distribution that the defender has in memory.
(2) Add a 2nd button to the Attack Enemy window, next to the Damage Calculations button: Roll-over Damage Calculations. This will show the results of damage calculations using the saved hp probability distribution vector. This button will only appear if (a) there is a saved hp distribution vector, and (b) the defender matches the defender for which the hp distribution vector was originally assigned.

=========

The good news:
The back-end code is already done in the combat algorithm designed by rusty and myself. This is the exact same methodology the AI uses to calculate attacks, and the code for treating unit hp's as vectors is already there. Furthermore, I believe the UI that Decker wrote calls the same exact function, although I believe the hp are encapsulated in a unit object of some sort. So minor tweaking would be needed there.

-----

Possible drawbacks:
(1) Micro-managers who would take forever to play a game, essentially computing battles like the AI.
(2) The concept of hp distributions is too difficult for new players to grasp?
(3) Too much info? too many buttons?
WizardMagus
Posts: 34
Joined: September 10th, 2006, 11:06 pm
Yogin wrote:Why do I love the mode? Because in Wesnoth, I have the advantage of being able to calculate my next battle conditional on my prior battle. Using the mean ignores this. How often do you re-evaluate what to do in battle situations? Most likely after each combat, since each combat is a unique set of rolls.
Obviously you reevaluate after each round of combat, but that does not mean you don't plan beyond a single round. The best plan is one that gives you a general direction, but allows you to change and implement the details. This is why I was suggesting EV, because it allows you to get an idea of the bigger picture.

The mode obviously gives you the most likely outcome, but I find that less useful than a distribution because the outliers matter in Wesnoth. EV allows an approximation of the distribution.
Yogin wrote:Proposal:
(1) Add a button to the Damage Calculations window, Roll-over Defender HP's. This will save the vector of hp probability distribution that the defender has in memory.
(2) Add a 2nd button to the Attack Enemy window, next to the Damage Calculations button: Roll-over Damage Calculations. This will show the results of damage calculations using the saved hp probability distribution vector. This button will only appear if (a) there is a saved hp distribution vector, and (b) the defender matches the defender for which the hp distribution vector was originally assigned.
This is an interesting idea. Certainly more complicated than I was thinking, if you are actually multiplying the probability distributions, but also more informative. I'd personally like this feature, and would gladly support it.

Then again, I'd also settle for EV.
WizardMagus
Posts: 34
Joined: September 10th, 2006, 11:06 pm
WizardMagus wrote:Certainly more complicated than I was thinking, if you are actually multiplying the probability distributions, but also more informative. I'd personally like this feature, and would gladly support it.
Actually, if we are multiplying probability distributions, this would rapidly overwhelm the current Wesnoth display. I have not actually counted the maximum number of bars, but I know it gets exceeded already in the game without this proposed change. If we were to implement this feature, we would need to be able to show more of the distribution than we did before, since it would rapidly get out of hand. Just something to consider...
Becephalus
Inactive Developer
Posts: 521
Joined: October 27th, 2005, 5:30 am
Location: St. Paul, Minnesota, USA, Earth
I cannot possibly understand what more information you could want than the current display, which is perfect.
There are three roads to ruin: by gambling, which is the quickest; through women, which is the most pleasurable; and through taking the advice of experts, which is the most certain. -de Gaulle
Yogin
Posts: 98
Joined: November 18th, 2005, 7:49 pm
My proposal is basically the current display, calculated for any sequence of attacks.

eg. You can find out what the ctk and final defender hp distribution will be like for an elvish fighter and a wose attacking a 30 hp unit.
WizardMagus
Posts: 34
Joined: September 10th, 2006, 11:06 pm
Yogin wrote:My proposal is basically the current display, calculated for any sequence of attacks.

eg. You can find out what the ctk and final defender hp distribution will be like for an elvish fighter and a wose attacking a 30 hp unit.
Exactly, that would be an excellent tool. I still think we should slightly expand the number of outcomes displayed, however, to account for multiplying the two probability distributions.
AJosh The Amicable
Posts: 3
Joined: June 15th, 2007, 8:11 am
Location: Somwhere far to cold
uh guys why not simply bold they percentage with the highest chance of happening except in cases like the thunderer senario. this would tell you what probability dictates SHOULD happen which is really what this whole column is about.