Ricochet is the best place on the internet to discuss the issues of the day, either through commenting on posts or writing your own for our active and dynamic community in a fully moderated environment. In addition, the Ricochet Audio Network offers over 50 original podcasts with new episodes released every day.

#
Boots, Hammers, and Classic Math

Being a man subject to his vices, I’ve started up again on World of Warcraft. Not the new stuff, the “Classic” servers. “Is that what’s taking up your time?” I hear you all saying, “I had wondered why it was slightly less nerdy and pedantic around here.” Well, worry no more! For the joy and edification of the Ricochet audience, here I reproduce the work I did with the damage formulas. Because a simple post about Warcraft wouldn’t be nearly nerdy enough.

It all stemmed from a simple question; which is better, strength or agility? Strength adds damage, but agility adds some damage as well, and some critical hit chance too. So how do you compare them? You can’t categorically say that one is always better than the other. Well, you can, and people often do. But you can’t and still be right. In a broader sense, how do you decide between two items? Here, let’s go shoe shopping. Which pair of boots do you think goes better with my yellow damage?

**Don’t Let the Shoes Fool You; It Gets Mathy in Here**

While I should have been doing useful things in college like homework, I was instead deriving an item selection algorithm for my druid. And for all of you nerds (let’s face it, the only people still reading now have a good shot at the title in the Dork Contest), here’s how it works:

You start by taking a swing at someone. (In game, @SamRhody. I haven’t been your brother this long without learning to duck.) You pull out your ax, wave it at a chump, what happens? Well, there are a couple of different possibilities. He could dodge. You could hit him. You could get a critical hit. You could miss entirely. Bottom line, though, your swing results in one of several options.

We’re talking about things we can change here. We can change misses into hits, and hits into critical hits. The other possibilities don’t change much. Our gear selection affects those outcomes, though. We’re going to ignore the other options and go with the following simplified equation:

(1) h + m + c = 1

That is, you chance to hit plus your chance to miss plus your chance to crit add up to 100%. It adds up to 100% because when you take your swing, something’s gotta happen. We’re dividing the universe up into those three possibilities.

That adding up to one makes it a stochastic system, by the way. “Stochastic.” There’s your vocabulary word for the day. “My you’re looking stochastic this evening, and your earrings are particularly monotonic.”

Now, we’re trying to maximize damage here, which means we’ve got to figure out how those numbers affect damage. Let’s assign capital letter damage to each probabilistic outcome. You can expect a critical hit to deal “C” damage. We’re weighting the probabilities with the damage we’re expecting from those outcomes. Over time that ought to work out to your average damage “D.”

(2) hH + mM + cC = D

When you swing, h percent of the time you’ll do one hit’s damage, which we represent as H, the other capital letters corresponding similarly. In fact, we can simplify this immediately, when we realized that “M” must necessarily be zero. If you’re doing more than zero damage you must have actually hit him, right?

(3) hH + cC = D

Okay, that’s easy enough. What else can we simplify? A critical hit is always going to do double damage. If we know that C = 2H, then we can substitute that in.

(4) hH + 2cH = D

(5) (h + 2c)H = D

Okay, one less letter. Anything else we can do for this? Well, look back at equation 1. Rearrange it like so:

(6) h = 1 – c – m

Oooh, there’s that pesky “m” sneaking back in. Substituting all that back into equation 5, we get

(7) (1 – c – m + 2c)H = D

Which boils down to

(8) (1 – m + c)H = D

**It Gets Worse**

Alright? One more complication before things really go off the rails. Divide all that by time to get damage per second. The game already does that math for you, so we might as well stick with that number. Unfortunately, that change forces us to be a bit more specific about our topic. Up until now, everything’s been consistent with white and yellow damage. Here though, we’re restricting it to white damage only. That’s okay; white damage matters. Just note that dividing things by time gets more complicated quickly when you’re talking about voluntary character actions.

(9) (1 – m + c)H/t = dps

“Wait. What was that you said a moment ago about this going off the rails?” Well, up until now, this has been an exercise in probability and algebra. While I’m sure all y’all were just begging for one of those, it doesn’t tell us all that much that’s useful. Want to increase your dps? Up your crit chance, and add more weapon damage. We want to maximize the function; to choose items to optimally increase our damage. And math helpfully supplies us with a way to do that. We’re going to take the gradient!

The what now? Gradient. We’re jumping right past ordinary calculus into vector calculus. (Hey, even Weird Al does vector calculus just for fun.) The gradient takes a perfectly innocent function like the one we just derived, and it gives you a vector pointing in the direction of maximum increase. Okay, let me try and explain that.

Picture yourself in a field on the side of a gentle hill. Now, you’ve got three hundred and sixty degrees of options, choose an angle at random. Walking that way will either put you up higher on the slope or lower on the slope, or at the same height. One angle is going to point directly upslope, which is the one we’re interested in. If you had a function that described how the hill was arranged, you could take the gradient of that function and it’d give you that direction. Or the direction going directly downslope.* Fair enough?

To take a gradient, you take the partial derivative of your function with each variable in sequence and array them as a vector. It … it’s easier done than said, actually. Here, let’s just roll with it. An introduction to vector calc is beyond the scope of this post.

(10) grad(dps)(H,c,m,t) = < (1-m+c)/t , H/t , -H/t , -(1-m+c)/t^2 >

Those individual equations give you your damage vector. If you could increase your character stats in exactly that direction you’d be maximizing your damage.** We’ll be getting to what that means in a moment.

Which brings us way back ’round to our original question, maximizing your character’s damage. Recall the shoe shopping example from up above. Which pair of boots is better? Well, since we have that handy gradient vector, we just need to know which item aligns best with that gradient. How do we know which aligns best? We take the dot product with the item’s vector. That boils all our formulas down to one number per item. Biggest number wins.

“Slow down. What’s an item vector?” Boy am I glad you asked. If you hadn’t this post would have kind of tapered off awkwardly there. To get an item vector, you take the stats from an item and arrange them in a vector in the same order as your gradient. < 25 attack power , 0.24% crit chance , 0% hit chance, 0 change in attack speed*** > for example.

(Can you treat items as vectors? Is this all a load of hooey? That is an excellent question. I spent some time thinking about it, and it turns out that yes, you can. See my post on the zombie apocalypse for why.)

Okay, if you’re not going to click the link, you’ll have to take that statement on faith. Serves you right. “But you never explained what’s a dot product!” Fine. A dot product tells you how closely two vectors are aligned, in length and direction. (How? Go back to your vectors textbook. Again, explaining all that is beyond the scope of this post.) To take a dot product, you multiply each term of the vector with that term in the other vector, then add all those things together. Another thing that’s easier done than said.

**Here’s Where We Get to the “Practical” Example**

This is Lemuel. Lemuel is a level 60 druid. Lemuel need to decide between two big hammers for his cat form stats. Either the Impervious Giant or the Fist of Omokk. Before I go any further, these calculations are duplicated in a Google (yes, I know they’re evil) spreadsheet here.

On with the show! We need to convert the raw stats on those items into item vectors. Easy enough:

(11) Impervious Giant: < 0 attack power change , 2% crit chance, 1% hit chance, no attack speed change >

(12) Fist of Omokk: < 29 strength, 0 crit chance change, 0 hit chance change, no attack speed change>

Reposting equation (10) from up above. We’re going to have to figure out what all those symbols actually are.

(13) grad(dps)(H,c,m,t) = < (1-m+c)/t , H/t , -H/t , -(1-m+c)/t^2 >

Okay, we’ve got a whole buncha symbols on the right we’ve got to define. “t” we can deal with right away; t = 1. It’s always 1 in cat form. “m” is another one; this isn’t listed anywhere on your character sheet. But I can tell you you’ve got a 5% chance to miss against a same-level monster, so we’ll go with m = 5% as a base. But Lemuel has +3% hit chance from other items he’s wearing, so m = 0.02.

That leaves us “H”, which is the damage you can expect on a single hit, and “c”, which is your critical hit chance. A look at the spellbook tells me my crit chance without any weapon equipped is 20.40%. A quick glance at the character sheet gives us a standard dps rate of 125.5. Wait. I know that strength translates into dps, but specifically what’s 29 strength mean in terms of dps?

Two quick identities, which are known World of Warcraft formulae, and verifiable on your character sheet.

(14) 14 attack power = 1 dps

(15) 1 point of str = 2 attack power for a cat druid; 2.4 after talents.

29*2.4/14 = 4.97 and change dps. Now we’re gettin’ someplace!

Let’s rewrite that gradient, only replacing the symbols with the appropriate numbers.

(16) grad(dps)(H,c,m,t) = < (1-0.02+0.2040)/1 , 125.5/1 , -125.5/1 , -(1-0.02+0.2040)/1^2 >

(17) grad(dps)(H,c,m,t) = < 1.178 , 125.5 , -125.5 , -1.178 >

Alright, then let’s rewrite the item vectors in terms of those same numbers;

(18) Impervious Giant: < 0 , 0.02 , -0.01 , 0 >

(19) Fist of Omokk: < 4.97, 0, 0, 0 >

Note that I changed +hit chance to -miss chance in equation 18; we want to make sure those negative symbols cancel out so we aren’t penalized for adding hit chance. Now, we need to take the dot product with each item:

(20) grad(dps)(H,c,m,t) (dot) Impervious Giant = 1.178 * 0 + 0.02 * 122.7 + (-0.01 * – 122.7) + -1.178*0

(21) grad(dps)(H,c,m,t) (dot) Fist of Omokk = 4.97 * 1.178 + a bunch of things times zero.

And all that is now is an exercise in arithmetic. Again, if you want to jump straight to the spreadsheet, I saved the calculation here. The dot product for the Giant works out to be 3.7 something. The dot product for the Fist works out to be 5.9 or so. Since the Fist of Omokk ended up with a bigger number, that tells me that Lemuel will deal more damage with that particular mace.

That’s the way it works. Of course, white damage isn’t the whole story. Which means the whole story is more complicated. You can work out yellow damage over time based on the skill rotation and

**Problems:** (Solutions to the even numbered problems will be provided in the back of the book)

- Suppose Lemuel has that shoe-shopping decision mentioned up above. Without changing his gradient vector work out which pair of boots will help him deal more damage.
- According to this derivation is hit chance or crit chance more important?
- The commonly accepted wisdom is that maxing out your hit chance is better. What assumptions am I hiding that may explain that phenomena?
- Okay, admit it. You’re not going to solve any of these other problems, are you?
- Turn the idea around. Let’s say you’re looking to compare tanking equipment, and that you need to mitigate as much damage as you can. Write out a stochastic equation for the scenario where he’s swinging his axe at you, and derive an incoming damage formula that corresponds with equation (9).
- If Lemuel is dealing out cat damage in a raid, he’s mostly going to be using the skill Shred. (48 energy, 225% normal damage + 160 to the target.) Assuming a steady state scenario where energy is only regenerating at the normal rate of 20 energy every two seconds, does adding shred into the damage equations change any conclusions?
- Doyt is a warrior. Doyt would like to know if an iron counterweight or a +7 damage enchant would be better for his brainhacker. You may assume Doyt’s basic damage and crit chance are the same as Lemuel’s for the sake of argument.
- After five shreds, generating one combo point each, Lemuel finishes off the combo with a Ferocious Bite, dealing 685 – 735 damage to the target. Does that change anything?
- Lemuel has taken the talent Blood Frenzy, which grants him an additional combo point whenever he critically hits with shred. Given a crit chance of “c”, how many shreds can he expect to need to get to five combo points for a Ferocious Bite? Bear in mind that any combo points past #5 are wasted.
- Write a new equation for damage that includes the yellow damage combo and the Blood Frenzy combo points. Take the gradient of that equation and write out a new character vector for Lemuel. Recalculate the Fist of Omokk versus Impervious Giant decision. Does the Fist still win?

*Since the gradient technically looks for maximum change, we could have a vector pointing in the exact opposite direction. In theory, that’s a concern. In practice, we won’t have to worry about that since we’ll be dealing exclusively with positive numbers. If your new hat gave you -1% crit chance, you wouldn’t expect it to increase you damage.

**There’s another complication here. “What about local minima? Or maxima? Or saddle points?” I hear all you Calc II grads asking. Yeah, right you are. I’m sure you did a lot of studying to get you through the hangover from the frat parties. But I might as well answer the objection.

Instead of a farmer out standing in his field, imagine a mountain climber. If he always goes upslope he’ll get to the mountain peak. Is that the highest he can get? What about that other mountain over there? Since he’s always going up he can’t go downslope to climb that mountain and check if it’s higher. So how do we know our item gradient doesn’t leave us stranded on a mediocre peak?

Here, the relative simplicity of the equation comes to the rescue. Excepting the time coordinate all the terms in the gradient are first order. You don’t get local maxima on a straight line.

*** As long as you’re working with straight dps you can take the dps number from weapons and generally ignore the time coordinate. It’s included solely to deal with questions like “would I rather have an Iron Counterweight or +7 damage enchantment on my weapon?”

Published in Science & Technology
Oh my goodness.

There are entire worlds out there that I know nothing about.

But have you done a sensitivity analysis for not hitting your rotation perfectly?

I was expecting some real math. Where’s the good stuff?

Not hardly. On the other hand, the math as stated here applies to white damage, which oughtn’t be subject to as much random variation.

The math in the problems might need it, I’ll grant you.

If you feel up for it, I recall that footnote (2) follows from Laplace’s Equation, but it’s been long enough since I was actually studying those things that I settled for the handwaving argument in the post. I guess what I’m trying to say is that the proof is left as an exercise for the student.

I think I have to ask whether or not the Swiftwalker Boots are lime green.

Also, there’s no Kent in World of Warcraft.

They are fancy, but not lime green.

The answer to problem 1, by the way, is that the Swiftwalker Boots are better. 3.64 to 3.38. I should also note that agility comes with 0.04% dodge chance and 2 armor per point. Not relevant to a strict damage calculation, but still useful.

I read this post while my Minstrel in LOTRO was grinding some XP in the Deeping Coombe at Helm’s Deep. And I actually understood most of it. One of the reasons that RPGs are popular with nerds is because they let you quantify and systematize things like that.

This is SO funny – I don’t understand a word of except BOYS. Our son has starting playing a version with his son and the back and forth with all those boy words like Damage (he loves Damage) is something else. I’ll take your word for it about the maths involved. Both of our boys seem to take that for granted. Yes – we are partial to boys.

The solution provided says, “

No,” so I guess not.So, Hank, what’s WoW Classic like? Original start areas and content?

For the most part they’ve been remarkably faithful to the original experience. All the way down to massive queues on launch day. The points where they’ve changed things tend to be obvious, no downside things. E.G. you can trade Bind-on-pickup epics for up to two hours after you get them.

What they can’t reset is the playerbase. At least 70% of the people on the server are jerks like me; people who were pro at the game back in the day and have come back to relive their glory days. On the upside that means your usual pick-up group is almost always competent. On the minus side world PvP (They’ve implemented the honor system but not battlegrounds yet) is, as the kids say, ‘cancer’.

This is why these games are un-fun for anyone who wasn’t there on the first day. I remember when D&D first started back when I was in high school. But only nerds were playing that. So now, 40+ years later, if I were to play a game, everyone else playing would be 120th level wizard with a 100 million gold pieces and every weapon that ever appeared in the game. Meanwhile, after I roll to establish my characteristics, I end up as a one-legged dwarf with a stutter, no armor, and my only weapon is a sword made from a Christmas wrapping tube.

You know role-playing means you’re supposed to play something that you’re not.

Re, the other nerds, if you start a campaign you’ll probably start out on an even footing, but yeah, you’ll be at a severe knowledge disadvantage to the obsessives.

So, just like real life?

According to the derivation, they’re of exactly equal worth.

There are several, although to be perfectly honest I haven’t seen a really solid explanation for why everyone obsesses over hit chance these days.

I thought retailers were supposed to sell to people, not kill them? Although, on Black Friday…

This would have been very useful to know, if I hadn’t dropped my WoW subscription and removed all of the Blizzard software from my computers after their ham-handed actions in relation to China.

Fair reaction. I’ve limited mine to making bitter, sarcastic remarks about it in game.

But what are your will saves like?

Principles.

After reading this post carefully, I’ve decided that only games I’m going to play will be on the complexity level of Candyland.

Hank clearly does a lot of PvP or raiding, where such calculations are important. I usually just played the game, and dps wasn’t quite as important. I mean, you want to be respectable, but it’s not necessary to get every drop of dps out of your gear.

I have to admit that I left my account intact, though, in case they have an outbreak of sanity and divest themselves of their China investments.

It’s a faint hope at best.

The original Diablo is on GOG.com for under $12.00 including the Hellfire expansion pack. This is the game which pretty much started the entire RPG game type…

If you have a spare hour and would like to sink it into hearing about developing a game in the mid -90s:

I think it was Bill Whittle, who noted all these socialist kids run around these games pretending to be republicans – gather gold and buy weapons…

https://www.gog.com/game/diablo

Do you get negative honor for killing NPC’s?

The 90’s? We had computerized RPGs in at least the 80’s. Am I missing something in your statement?

Yeah, but the computers they could stuff into a small rocket weren’t very sophisticated.