Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

So I'm making a game and want to create an equation for calculating the effect of a stat called armor. The effect is in percent and determines how much damage reduction one has against attacks. The parameters are, 1, Player level and, 2, Armor points. Here's my initial approach:

I created a matrix $A$ that looks like this: $$\left[\array{ 1 & 5 & 0.05\\ 30 & 170 & 0.5 }\right]$$ I want the effect to be 5% when the player is level 1 and has 5 armor points. And when the player is level 30 and has 170 armor points, the effect should be 50%.

This all works fine, except for two problems:

  1. The solution to that Matrix result in something unsuitable: When a player increases his armor points (without gaining in level) the effect decreases. If you have ever played a rpg, it should increase.

  2. The changes to the effect are happening too fast. If $B$ is the effect when the player is level 25 and has 150 armor points and $C$ is the effect when the player is level 25 and has 151 armor points, $|B-C|$ is too big.

Any suggestions on how to get by problem 1 and 2?

To clarify:

I rowreduce matrix A. That gives me

$$\left[\array{ 1 & 0 & 0.3\\ 0 & 1 & -0.05 }\right]$$

So the equation I use is $$\text{effect} = 0.3\text{ level}-0.05\text{ armor}\;.$$

Here's what I would like to happen: 1. I would like the effect to increase as armor increases(and level standing still). 2. I would like the effect to decrease as level increases(and armor standing still).

share|improve this question
If the matrix is based on two data points, and solving it yields the undesired effects you describe, then the right correlation is not linear. In that case, you need to give more information about what result you desire: there's not enough info in the question to indicate the right equation. –  msh210 Dec 4 '11 at 22:02
How are you currently using $A$ to calculate the effect when a player is at level $L$ with $P$ armor points? Are you solving $\left[\array{1 & 5\\30 & 170}\right]\left[\array{x\\y}\right]=\left[\array{0.05\\0.50}\right]$ and then taking $xL+yP\;$? –  Brian M. Scott Dec 4 '11 at 22:04
Brian M. Scott: Yes that's what I do. –  Emiam Dec 4 '11 at 22:15
If you’re going to go with a linear expression $xL+yP$, where $L$ is level and $P$ is armor points, you need to make $x$ negative and $y$ positive in order to get the effect to increase with increasing $P$ and decrease with increasing $L$. You’ll not be able to combine this with the data in your original matrix $A$, however: they’re simply not consistent with both a linear formula and the effects that you want. –  Brian M. Scott Dec 4 '11 at 22:57

2 Answers 2

up vote 2 down vote accepted

Try the following formula:

$$\mathrm{effect} = 1 - 5099/(\mathrm{level} \times \mathrm{armor} + 5098)$$

This assumes that both player level and armor points have a minimum of one. If not, add $1$ to each.

It has the correct result of a person at level 30 with 170 armor points giving an effect of $0.5$. However, it underestimates the result for a person at level 1 with 5 armor points. It has several advantages, though. If both the level and armor points have the minimum value of 1, then it will produce a $0$. Also, no matter how high either value is, there will never be a result greater than $1$ (results greater than one would imply that attacks would actually boost a player's health).

share|improve this answer

First, is level 1 the lowest player level, or is level 0? If it's level 1, then you need to reduce some of the numbers in your matrix by $1$ so that the lowest level player with no armor gets zero effect.

Second, a linear map does not seem appropriate unless your game has a cap for player level and armor points. Does it? Otherwise, with a high enough value for either, then the effect would surpass 100%.

If you do have a cap for each of these parameters, here is what would make sense to me. Decide what effect you want for

  • maximum level, zero armor (A situation that would occasionally actually happen.)
  • maximum level, maximum armor (A situation that would occasionally actually happen.)

These two values $e_1, e_2$ will uniquely define a linear map with positive change in effect whenever either of the parameters increase. You would replace your augmented matrix by $$\begin{bmatrix}M & 0 & e_1\\M & m & e_2\end{bmatrix}$$ where $M$ is the maximal level, $m$ is the maximal armor points, and naturally you would have chosen $e_2>e_1$.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.