Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Library of Enlightenment > Thread: Damage calculation challenge
Thread: Damage calculation challenge
citrusmind
citrusmind


Hired Hero
posted January 23, 2009 08:38 PM

Damage calculation challenge

so I was pondering how to make an equation that could graph the health of two combating stacks of troops.  The y-axis would be the health of stack 1, and the x-axis would be the health of stack two.  The "rounds" I suppose could either be a third axis z or simply non existent on the graph.  I'd like equation generic enough where you could put in the health of a single unit, the number of units, the attack and defense of the unit and go from there.  

I suppose damage would have to be taken at an average OR, you could set up the answers to come up in with a shaded area, which would basically be the area between one stack doings its best and worst and vice versa.  I tried to come up with this equation myself, but I was only able to get as far as one instantaneous moment of health and I wasn't sure how to calculate the rate of change of x and y considering they are directly affected by each other... anyway, I know it's possible since given the same parameters every battle can go the same.  Good luck and I'd love to help anyone come up with this if they get some ideas.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Ecoris
Ecoris


Promising
Supreme Hero
posted February 04, 2009 11:34 AM
Edited by Ecoris at 11:37, 04 Feb 2009.

It is known in great detail exactly how combat damage is calculated. All you need to do is implement this.

A single equation is not feasible.

Edit: One would plot this as follows: # of rounds along the x-axis and health along the y-axis; one graph for each stack.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Zolmir
Zolmir


Hired Hero
posted February 04, 2009 04:49 PM
Edited by Zolmir at 17:16, 04 Feb 2009.

What you should do will depend on whether you are willing to calculate all possible results and the attached probabilities, or just taking the expected value of damage that is to be dealt, which would of course ignore variance.

By the way, I have a question. Has anyone empirically tested how randomness of damage works? Is it a uniform distribution? i.e. if the damage range is 1-3, are all 1, 2 and 3 equally likely?
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted February 05, 2009 07:36 AM

Quote:
Is it a uniform distribution? i.e. if the damage range is 1-3, are all 1, 2 and 3 equally likely?

Yes, for a single creature. However, for more than one creature middle values are more likely to appear (i.e. from 10-20 damage range 15 appears more often than 10 or 20)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Warmonger
Warmonger


Promising
Legendary Hero
fallen artist
posted February 05, 2009 07:58 AM

I don't think so. There is randomly chosen number from the stacks damage range, then multiplied by creatures count.
That makes tier1 and 2 creatures a little bit unbalanced though.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted February 05, 2009 08:25 AM

Let's see.

1 Pikeman do 1-3 ÍP of damage (A = D, no bonus)
What's about 2 Pikemen?

1 + 1 = 2
1 + 2 = 3
1 + 3 = 4
2 + 1 = 3
2 + 2 = 4
2 + 3 = 5
3 + 1 = 4
3 + 2 = 5
3 + 3 = 6

2 (1/9), 3 (2/9), 4 (3/9), 5(2/9), 6(1/9)

So, 4 is more likely to appear. It's obvious.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Warmonger
Warmonger


Promising
Legendary Hero
fallen artist
posted February 05, 2009 08:53 AM
Edited by Warmonger at 08:56, 05 Feb 2009.

But that's not the formula in H3. It goes like I write and I'm pretty sure of that.

Two Pikemen will always do 2, 4 or 6 damage.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted February 05, 2009 10:18 AM
Edited by AlexSpl at 11:30, 05 Feb 2009.

Damage is calculated for each unit in a stack separately. It's well known fact. If the number of units in the stack is greater than 10 then only 10 random numbers are generated.

Quote:
Two Pikemen will always do 2, 4 or 6 damage.

Not true. Just check.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
citrusmind
citrusmind


Hired Hero
posted February 05, 2009 08:20 PM

you haven't taken calc 2 on the college level then.  When there is a possibility of variability you make a graph with a range and a shaded portion.  in some circular equations you get a three dimensional equation for something like a donut.  The bottom would be the lowest possible situation and the top would be the high possible situation, which is then of course shaded in.  The only mathematical challenge is to show that even with 201 health angels would do 100 base damage.  It would probably be easier to write this in C++ then do one single equation.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Binabik
Binabik


Responsible
Legendary Hero
posted February 05, 2009 09:17 PM
Edited by Binabik at 21:34, 05 Feb 2009.

Quote:
Has anyone empirically tested how randomness of damage works? Is it a uniform distribution? i.e. if the damage range is 1-3, are all 1, 2 and 3 equally likely


It's a steep, symmetrical bell curve. So there's a very high probability that the damage will be in the center and extremely low probability it will be at the high or low end.

I don't know the cut off value, but with low damage this won't be the case. For example a single harpy will make a lot of attacks with 1 or 4 damage.

Also (again, only with higher damage values) not all damage values are possible. It takes the range of possible damage and divides it. This will be easier to explain with an example. (this is real test data)

This example is a large group of marksmen with a high attack value (106 attack). The sample size is 279 attacks. The damage range is 800-1200.

In this example the only possible damage values are 800, 840, 880, 920, 960, etc.  The AI takes the difference of 400 between the high and low damage ( 1200 - 800 = 400 ) and divides that by 10. This gives you an increment of 40. So the possible damage is [ 800 + ( N * 40 ) ].

The divisor is not always 10, but all the ones I've seen are divisible by 10. However the "increment" is not necessarily a nice round number like the marksman example. My dread knight test had a damage range of 4650-9300. The range was divided by 150 giving an increment of 31. So the possible damage is 4650, 4681, 4712, 4743, etc.

Here's the results of the marksman test. The left column is the damage, the center is the number of occurances, and the right is the percentage. Note that there's a 68% chance that the damage will be one of the 3 center values, and an 89% chance it will be one of the 5 center values.



Another thing to consider is when the creature gets luck. When the marksmen got luck the damage was NOT an increment of 40, it was an increment of 50. This tells me that the AI first determines if the creature gets lucky, and then does the damage calculation afterwards.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
dimis
dimis


Responsible
Supreme Hero
Digitally signed by FoG
posted February 05, 2009 09:31 PM

about the things that were discussed in the past

and
____________
The empty set

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Binabik
Binabik


Responsible
Legendary Hero
posted February 05, 2009 09:39 PM
Edited by Binabik at 22:02, 05 Feb 2009.

I haven't seen that one by Ecoris. I'll take a look and see if his results are the same as mine.

edit: lol, obviousely I DID see Ecoris' thread before because I posted in it. But I don't remember the thread or my post either one.


____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted February 06, 2009 12:51 PM

Nice work. Thanks for real tests. Here are my theoretical values for 4 Serpent Flies [2-5]:

dmg %
8 0.39
9 1.56
10 3.91
11 7.81
12 12.11
13 15.63
14 17.19
15 15.63
16 12.11
17 7.81
18 3.91
19 1.56
20 0.39

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Alamar
Alamar

Tavern Dweller
posted February 07, 2009 12:28 AM

Ok. So we know how damage is calculated if attack=defense. But can somebody tell me what is corellation between damage and attack and then defense of course? How is it calculated? For example 2 Archangels (AS 30, dam 50) attacks 500 Peasants (DS 1). How many Peasants will perish? And, first of all, how do we know that?
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Warmonger
Warmonger


Promising
Legendary Hero
fallen artist
posted February 07, 2009 09:20 AM

For very point of attack over defense, the damage is increased by 5%, capped at 300%. Thus (30-1)*5 = 145% additional damage, which results in 245% * 2 * 50 = 245 damage.
For every point of defense over attack, the damage is decresed by 2%, but minimally stack does 40% damage.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Rainalcar
Rainalcar


Promising
Famous Hero
Heroji su zakon
posted February 07, 2009 11:25 AM

http://heroescommunity.com/viewthread.php3?TID=27539
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Ecoris
Ecoris


Promising
Supreme Hero
posted February 08, 2009 02:21 PM

Quote:
For every point of defense over attack, the damage is decresed by 2%, but minimally stack does 40% damage.
Wrong. It is 2.5% per point up to a maximum reduction of 70%.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
pdesbois
pdesbois


Adventuring Hero
posted February 10, 2009 06:46 PM

Since we're at calc, here's something I've always wondered:

A hero's spec has him get +5% / level to Offense (Crag Hack I guess). Expert Offense means +30% to melee. So, this means a level 20 Crag Hack get 20 x 5% on top of the 30% , yesn't? Meaning 60% + to melee damage??? (obviously, ohter things held constant).
____________
" Karate ni sente nashi . "

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
sub_zero
sub_zero


Adventuring Hero
posted February 10, 2009 06:52 PM

correct

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
pdesbois
pdesbois


Adventuring Hero
posted February 10, 2009 06:54 PM

Quote:
correct



thx - i was about to say 'nevermind', coz i found the answer by pure chaotic chance.
____________
" Karate ni sente nashi . "

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0565 seconds