Friday, April 20, 2012

Health, Armor, and Magic Resistance

This post contains a lot of mathematics. Specifically, it uses the method of Lagrange Multipliers from multivariable calculus. Maybe you wish I was your calculus instructor right now. If you want to skip all that, feel free to use the calculator here.


You are buying a defensive item, and you need to know whether you should build Health or Resistances. Calculus tells us the answer and this calculator displays it.

Enter the ratio of Physical : Magic damage you will take in a teamfight, and your health, armor, and MR.

Phys:Mag Dmg:
Current Health:
Current Armor:
Current MR:

Ideal Health/(100+Armor):
Ideal Health/(100+MR):
Your Health/(100+Armor):
Your Health/(100+MR):

Equal Physical and Magic Damage

Single-variable optimization problems are standard in a first-semester calculus class. You end up with one of these if you assume that you take an equal amount of physical and magic damage.

Under this assumption, you look at health and resistances, and ask how much they cost. It turns out that health costs about 2.6 gold each, while armor and magic resist cost about 15 gold each.

When we take 1 physical and 1 magic damage, we will actually take less damage than that because of resistances, and we want to maximize the number of times we can get hit before we die. The resulting equation is

Here H = Health, X = 100 + Armor and Y = 100 + Magic Resist.

We would like to maximize this number of hits before death. The trick is that we know our armor and magic resist should be equal, so we can actually substitute X = Y. This means we try to maximize


Now we are trying to maximize a quantity that has 2 variables, so we use our calculus 1 expertise and say, "we should eliminate one of these variables so that we can take the derivative." Eliminating a variable is possible, since Health and Armor+MR cost money, and we only have some finite amount of gold k to spend. Remember that now X stands for one point of both armor and magic resist, so that a point of X costs us 30 gold. We'll use the equation

to eliminate H from our Number of Hits equation above. The result is


Take the derivative and set it equal to zero. You can then solve for H and X:

Which is really cool, because it means that if you are buying H and X from scratch, you want to spend the same amount of money on H as you do on X. This means that you should end up spending half your money on Health and the other half on Armor and MR:

Warning: This model assumes that you start with 0 health and 0 resistances, which is of course false. In practice, you first need to make up for the fact that your armor, health, and MR start out wonky. So the easiest way to interpret it is to look at the optimal ratio of health to resistances:

Conclusion: If you are taking equal physical and magic damage, your health should be 11.5 times the value of your 100+Armor, with your MR being the same as your armor.

Unequal Physical and Magic Damage

When you don't take equal physical and magic damage, we can't use the trick where we set X = Y, so we need multivariable calculus. Specifically we will need Lagrange multipliers to find the optimal solution.

Again we'll use the assumption that armor costs 15 gold, magic resist costs 15 gold, and health costs 2.6 gold. But now we will assume that you take R physical damage for each 1 magic damage you take, so that the damage you take from each "hit" is

Again X = 100 + Armor, Y = 100 + MR.

The number of those units of damage you can take before dying is your health divided by the damage. This is what we want to optimize:


Simplifying a bit we can remove an annoying factor of 100 and work to maximize the function


There isn't any easy argument for claiming that X should be some proportion of Y here (or at least, not one that I see immediately). So we use Lagrange Multipliers to maximize this function subject to the constraint that we only have a finite amount of gold, k, to spend.


Lagrange Multipliers force you to make up a new variable called Lambda, and work with a function of four variables:

Then we set all four partial derivatives of f equal to zero and see what we get.

Note that as always with these things, the last equation just tells us that we better satisfy our initial constraint!

Anyway, we can subtract the first two equations from each other and find that

Since H is nonzero, we get our first interesting result, which is:

This tells you the correct ratio of armor to magic resist given the ratio of damage you are taking. If you take 4 times as much physical as magic damage, you want twice as much X as Y, so you want your 100 + Armor to be twice your (100 + MR).

When we plug (*) back into the first equation we can find


When we plug (*) into the third equation, we find


Now we could use the last equation to find exact values, but what we really care about is the ratio of H to Y and the ratio of H to X, which we can find.


To check our work, we can use R=1 to re-find the fact that H/X and H/Y are both 11.5 if you are taking equal damage from physical and magical sources.

With R=4, H/X is between 8 and 9. So in this situation your health should be about 8 or 9 times your (Armor+100). H/Y is between 17 and 18. So your health should be about 17 or 18 times your (MR+100).

This doesn't take into account last whisper or void staff, and assumes that all health has a constant cost (which is not exactly correct). But it still gives a very good approximation to the optimal defensive build plan. Aren't you glad you learned multivariable calculus?

Sunday, April 8, 2012

Team Composition

I used my Team Composition spreadsheet while watching the IPL4 finals today. Here's what I got.

Game 1

CLG, at left, has a team that has very very strong Initiation and CC but also Counter-Initiate. TSM, at right, can't get away or initiate. This means CLG always gets to choose when the fights happen. There are lots of holes in TSM's team composition; picking Kog'Maw when you can't protect him is sad times.

Game 2

No CC for CLG, at left. But a huge amount of offensive siege and push pressure means that they can split push 3/1/1 all day. TSM, with no push pressure, can't do anything about it. That's basically the story of this game.

The Spreadsheet

The first page explains the 12 Team Composition traits I used, and how to compensate for a lack in one of them.

The second page is the meat of this spreadsheet; the individual champion ratings.

The next page allows you to sort the champions; here I've sorted by "Protection for Carries."

The next page shows the list of 5-star Champions.

The final pages use that data to form the actual Team Composition pages that you saw at the beginning.

Hint: Use "Blank" as a champion to fill in 2 for everything, so you can see what you are missing while the team falls into place.

Would you like to use it?

When opening the XLS in OpenOffice, one of the sheets just plain didn't work. Maybe Google Docs is the only place all the sheets will work? PM me on Reddit (HippityLongEars) if you want a link to the google doc so you can copy it that way.

If you want to complain about my ratings for specific champions, just download the thing and fix it yourself. ;)


The idea for such a thing comes from This Guide at