Showing posts with label plotting. Show all posts
Showing posts with label plotting. Show all posts

15 August 2018

Natural Diminishing Returns on Critical Hit Chance

Hold up! I can't believe it took so long to notice. This post is actually a misconception about probability I ran into. This is not an actual diminishing return but a perceived one.

A few days ago I explained that linear functions have a diminishing returns if we look at the damage increase we get at higher values. I also explained that it's even worse if you look at how difficult it is to get stats generally in games. Next up I want to talk about the natural diminishing returns on the critical hit chance.

Natural Diminishing Returns

Before I start, a quick reminder of what natural diminishing returns are. Diminishing returns can be broken down into the words diminishing which means a decrease of something and returns stands for the output or the amount we get from something. An example in video games let's say there's an attribute called strength. Each point of strength gives you about 1 damage. Now we put in 50 points into strength and our damage increases by about 47. If we put in 100 points we get 86 damage. Notice that the value you get out keeps decreasing.

The difference between diminishing returns and natural diminishing returns is that normal diminishing returns are programmed into formulas and such. Natural diminishing returns, however, appear due to the way the math works and is often not visible on it yourself. The example we used last time was that you increase your strength by 50 and you get 50 damage. If you double your strength you add 50 more strength onto it and you get double the damage, so plus 50 here too, the damage is increased by 200% or 100% of the damage is added upon it. If you add another 50 strength on the 100 you get 150 strength and 150 damage. The damage increase is only 150% or 50% of the damage is added upon it.

Mathematically: 100 / 50 =  2.0; 150 / 100 = 1.5
For more details on this check out the older post.

Critical Hit Chance is Linear

Just like the older post, critical hit chance is linear as well. For each 1% of critical hit chance, you get a 1% critical hit chance. Using Guild Wars 2 as an example getting 21 precision increases your critical hit chance by 1%. It doesn't matter how much precision you have, this is always the case. To illustrate the linearity here's a graph showing the conversion. The formula used in Guild Wars 2 for critical hit chance is 
criticalHitChance = (precision - 895) / 21;
{precision | precision ∈ R and precision >= 1000}
This means the function of our graph is:
f(x): y = (x - 895) / 21; {x | x ∈ R and x >= 1000}
Keep in mind that: {y | y ∈ R and 0% <= y <= 100%}
I don't know about you, but this definitely looks linear to me.

How Critical Hit Chance Behaves

Critical hit chance is a percentage that tells us how likely it is for an attack to be a critical hit. This that when the amount of your attacks goes against infinity we get an average of how many attacks critically hit. For example, if we say we have 0% critical hit chance, without much explanation this means you'll never critically hit. If we have a 100% critical hit chance, every attack will hit critically (1 / 1).
If we have a 50% critical hit chance this means that if you do infinite attacks against an enemy you will critically hit it 50% of the time. This is about every second hit (1 / 2).

Now you might notice something.
  • 0% means no critical hits
  • 50% means about every second hit
  • 100% means every hit
If you didn't notice it yet, no problem let's just continue then. As the next example value, we're gonna take 25%. When we attack the enemy infinite amount of times you will see, simply, 25% of our attacks will hit. On average that's every 4th attack (1 / 4).

Now about the 0% thing... let's assume we don't have 0% but nearly 0% critical hit chance. That means we could potentially hit critically but it's as impossible as it can be. To remind you of it I'm gonna write 0.0000...%. This is important that it's not 0%.

What we have now is 0.0000...% which means nearly 1 out of infinite attacks hit critically.
  • 0% means nearly one out of infinite attacks hits critically (lim x->∞ (1 / x) = 0.0000...%)
  • 10% means every 10th attack hits critically (1 / 10)
  • 20% means every 5th attack hits critically (1 / 5)
  • 25% means every 4th attack hits critically (1 / 4)
  • 50% means every 2nd attack hits critically (1 / 2)
  • 100% means every attack hits critically (1 / 1)
I only wrote down the rounded numbers. Such a great idea, this illustrates it even better. Just look at how the numbers behave. From 0.0000...% to 50% we went from one out of infinite to every second. Surprisingly from 50% to 100%, we went from every second attack to every attack.

This is definitely a diminishing returns. Let's plot it so everyone sees in black on white. Actually, I use the standard blue line.. so it's blue on white... though the axis is black.
Not so linear anymore. Here you can see it the more critical hit chance you have the less effective it becomes. Using analysis we can determine the exact point where critical hit chance stops to be as effective as it has been up until then. 

11 August 2018

Natural Diminishing Returns on Linear Functions

So, I actually went into a discussion with a fellow guild member on natural diminishing returns. He claimed there are no diminishing returns if the function that relates to the main stat that increases damage and the damage increase is linear. Well, he's right. There are no diminishing returns as we might know it, however, there are a natural diminishing returns. Let's break it down.

Diminishing Returns

First of all, let's clarify what diminishing returns means - in case you don't know, you can skip this paragraph if you do. Diminishing means a decrease and returns means something you get back. Both words together mean you get back a decreased value. In an example, we say we learn a language for one hour and we manage to keep 24 words from this session. Now we learn another hour with no pause in between and we manage to keep 22 additional words from the lengthened session. We keep pushing learning for longer and longer, but at three hours or so we would have only kept maybe 60 words in mind when we expected to have 24 words for each hour for three hours, so 24 * 3 = 72. As you can see there's a trend down, the diminishing returns.

Common Occurrence in Games

From my experience with a handful of people, I've seen that diminishing returns is known by people who are less active or interested in theorycrafting as a mechanic that affects loot drops. The longer you farm the same content the less loot or drops you get. This - of course - is diminishing returns as well. However, in the theorycrafting community, it's more about the damage increase or stat gain.

Damage as a Linear Function

For the purpose of the explanation I'm gonna use the damage calculation from Guild Wars 2:
damage = (weaponStrength * power * skillMod * positiveMods) / (armor * negativeMods)
Now, the fun part is - if you didn't sleep during your physics classes - we know that we're going to keep a few variables the same. If we compare our damage to another example and only change one value the rest becomes constant.

For our purpose, we only change power. Let's say we have the following values:
damage = (1150 * 1000 * 0.35 * 1) / (2597 * 1) = 154.98652291105122
Now, we change the value of power and leave every other value constant:
damage = (1150 * 2000 * 0.35 * 1) / (2597 * 1) = 309.97304582210245
As you can see, we doubled the power and our damage value doubles as well. Do not believe me?
Here you go:
309.97304582210245 / 154.98652291105122 = 2.0
This means, as long as all the other values do not change we can directly modify the value by the factor we change it. To simplify our calculation we can replace any constant values with a 1:
damage = (1 * 1000 * 1 * 1) / (1 * 1) or damage = 1000

Next up let's look at how our damage behaves if we increase our power by one steadily. For this, I'm gonna plot the function. Though we already claimed that our simplified function is damage = power.
Additionally, we started with 1000 and I claimed to steadily increase it by one. It shouldn't be hard to realize that the function we get is linear starting at 1000 and increasing by x:
 f(x): y = 1000 + x
 Nice and big for everyone to read.

Natural Diminishing Returns Behind Linear Functions

Thus far, we haven't seen any diminishing returns. Now let's do the following:

We start off with 1000 power which directly translates to 1000 damage or 1000 * otherFactors damage to be specific. If we add 1000 power to our base of 1000 we get 2000 power or twice the damage. This means if we double our modifier we double our damage. Funny enough we can look at the damage increase for each point of power we get. To calculate this increase there are multiple ways to do it but my favorite way is to calculate:
damageChange = (newStat / oldStat - 1) * 100
damageChange = ((oldStat + change) / oldStat - 1) * 100
We could calculate this 500 times.. or we simply leave that to the computer. Time is too precious to waste anyways.
damageChange = ((oldStat + x) / (oldStat + x - 1) - 1) * 100
Now let's run it for oldStat = 1000.
As you can see the line decreases. This means for each point of power each additional point of power loses in value or worth. Well, yeah, there you have it, diminishing returns in linear functions.

Worse With Min-Maxing

(min-maxing describes the act of more or less pushing and pulling out the last few improvements. It's the difference between 95% of what's possible and ~99% of what's possible. Might write a blog post about that as well... *shrug*)
However, in many games "one does not simply double their main stat". The stat gain in many games behaves like a log function at higher values. This means the more stats you get the harder it will be to get even more of it.

If you do not know what this looks like here you go:

As you can see, it's easy to get power at the start but at some point, if you have your main stat everywhere you can have it, it's just a few sources here and there where you can still get some making it hard to keep ongoing.
***NOTE: This is not a graph that represents the exact way this behaves in any games or in Guild Wars 2.

19 July 2018

Guild Wars 2: Danger Level at Desmina's Platform - Part 2

Okay, I had a change of heart. I'm going to release the Desmina research results now because I still can't find the time to continue and secondly because I want to keep any following data for different research.

Procedure

What I did was the following. I looked at the two wall spawns, three wall spawns and four wall spawns differently and tracks them separately. Then I added them all together but also looked at them added together keeping the duration of their phases in mind, created a weighted result basically.
I also calculated the percentage of coverage using the number of walls appearing at one point and dividing it by the amount of total wall spawns.

The Result

Size of Data

I have accumulated a total amount of 266 two sized waves which means 532 wave parts in the first phase. I've tracked 1201 three sized waves which consist of 3603 wave parts and I have tracked 444 four sized waves which are 1776 wall pieces. In total it accumulates to 1911 waves and 5911 wave parts. The first phase is weighted at 0.1, the second phase takes 57% of the fight assuming constant damage and the third phase is 33%. The weighted count results in 857.69 waves.

Two Wall Spawn

108113110122111
101106103105104
92979410695
104109106118107
9710299111100
40.60%42.48%41.35%45.86%41.73%
37.97%39.85%38.72%39.47%39.10%
34.59%36.47%35.34%39.85%35.71%
39.10%40.98%39.85%44.36%40.23%
36.47%38.35%37.22%41.73%37.59%

266 or 532 may not be a big data set, yet it does not seem to try to reach an equal amount in every field. This has been confusing me. If we assume that it is completely random shouldn't each field have the same amount in the long run? That's not the case here though. There are what seems like random oddities all over it. Of course, I might have made some mistake here and there but none that should affect the result by that amount. Apparently, there are a few safer places as shown by the darker green in the percentage view.

Three Wall Spawn

732729715711706
723720699693699
726715694686693
692692669672676
752759738729735
60.95%60.70%59.53%59.20%58.78%
60.20%59.95%58.20%57.70%58.20%
60.45%59.53%57.79%57.12%57.70%
57.62%57.62%55.70%55.95%56.29%
62.61%63.20%61.45%60.70%61.20%

Looking at this result... okay, seriously. Is this generated using Perlin noise? If you assume this to be a height map, it could be some area straight out of Minecraft. That's soo weird. Nevertheless, it shows the safer places during the longest phase turn out to be in the lower right part of the platform. Now, this might have been the result of how we pulled her,  however, I've checked fifteen different days for between half an hour to three hours and our tanks start off with a pattern but switch to going wherever the walls and exploding deads lead us to. Usually, when something is random there is still a pattern behind it. For example, when throwing a dice randomly each side should appear an equal amount of times at some point.

Four Wall Spawn

444376366372444
368298290296368
361291283289361
377308299305377
444376367372444
100.00%84.68%82.43%83.78%100.00%
82.88%67.12%65.32%66.67%82.88%
81.31%65.54%63.74%65.09%81.31%
84.91%69.37%67.34%68.69%84.91%
100.00%84.68%82.66%83.78%100.00%

Here, we can see that 2 pieces are always forced to spawn in the corners resulting in the corners being covered by each wall that spawns at some point. This also - due to the nature of how the walls or waves move - results in very dangerous corners. This doesn't matter too much since the outer ring should be nearly impossible to touch without dying as the platform has been decreased to more or less a 3x3 area. Obviously, the middle is safer now. Besides from this fixed field, it seems like the corners and edges are yet a tiny bit safer than the middle. Whether or not this matter depends on how much you believe in numbers. I don't think this is the case though. We have three safe fields and two walls will always occupy two of those three safe fields at some point. That means 33% of a lane is going to be safe while the rest - the 66% - are covered by a wave. If this is completely random each area in the middle should end up with a coverage of 66%.

Total Coverage

12841218119112051261
11921124109210941171
11791103107110811149
11731109107410951160
12931237120412121279
67.19%63.74%62.32%63.06%65.99%
62.38%58.82%57.14%57.25%61.28%
61.70%57.72%56.04%56.57%60.13%
61.38%58.03%56.20%57.30%60.70%
67.66%64.73%63.00%63.42%66.93%
If we sum up all the walls and touched areas we get this total coverage. So, if you're interested in an overall that does not care about the length of each phase this is the result. The safest area in the middle, still. Obviously, since the last phase strictly prohibits us from moving into the outer ring. Is this the reason people came up with the idea that big walls spawn when you go outside? To scare people from staying in the middle without explaining it mathematically? Hmm...

Weighted Coverage

623.04576.69563.67567.17612.16
567.55519.86505.17506.81557.53
563.25512.12497.43499.21549.36
560.55514.82498.6505.11553.97
630.54588.49573.13573.81623.53
72.64%67.24%65.72%66.13%71.37%
66.17%60.61%58.90%59.09%65.00%
65.67%59.71%58.00%58.20%64.05%
65.36%60.02%58.13%58.89%64.59%
73.52%68.61%66.82%66.90%72.70%
For the weighted coverage, we consider the length of each phase as well. This means the first phase plays hardly to no role and the last phase only a bit. We still get a result similar to the total coverage, however. There are some slight changes in percentages here and there, overall nothing new.

So, There We Have It!

An analysis of which area of the platform is the safest and whether or not there is a pattern to the coverage. The end results show that there's more at play than just randomness. At least that's what it seems like to me. Except for the fourth phase, the total coverage and weighted coverage, it pretty much seems like some kind of noise function.

Fun

I've created this height map from the three-wave data using Python and Matplotlib. It's always fun to do these things. Seriously, Python is awesome.


About Me

My photo
I'm a M.Sc. Games Engineer and I created this blog to share my ideas, theorycrafting, thoughts and whatever I'm working on or doing.