Clash-of-clans – way to calculate the Gems requires to fill storage

clash-of-clans

Obviously there is a set amount of Gem needed to fill 10% and 50% of your storages but I am wondering, with the 3rd storage fill options which fills them to 100% but the number fluctuates because of your current levels, is there a way to calculate how many gems it'll approximately cost without having to look in the shop? (ie. predicting how much it'll cost before storage upgrades are complete)

Best Answer

In Clash Of Clans there are "plateaus" in the game files that are used to calculate how many gems it costs to buy resources.

Plateaus

1st - 100 - 1 gem

2nd - 1,000 - 5 gems

3rd - 10,000 - 25 gems

4th - 100,000 - 125 gems

5th - 1,000,000 - 600 gems

6th - 10,000,000 - 3000 gems

This is the formula to calculate gems (modified version of Dahimi's).

Gems = (x - a) / ( (b - a) / (c - d) ) + d

Where:

x = Resources needed (gold or elixir)

a = resource amount of plateau below resources needed.

b = resource amount of plateau above resources needed.

c = gem amount of plateau above resources needed.

d = gem amount of plateau below resources needed.

Example:

If we wanted to find how many gems it costed to buy 50,000 resources.

We know that 50,000 is in between the 3rd (10,000) and 4th (100,000) plateau.

We already know the value of x is 50,000. But we still need to find the value of a, b, c and d so that we can put them in the formula.

a is equal to the resource amount of the plateau under x, we know that the 3rd plateau is under x making a = 10,000. The same thing is done for b, but with the plateau above x, which is the 4th, the 4th plateau is equal to 100,000, so b = 100,000.

For finding c and d it is exactly the same as a and b, except instead of the resource amount you are grabbing the gem amount. If you scroll back up to the list of plateaus you will see that the gem amount for the 3rd and 4th plateau is 25 and 125, respectively. This makes c = 25 and d = 125.

This means:

x = 50,000

a = 10,000

b = 100,000

c = 125

d = 25

Then we put the values into the formula.

Gems = (x - a) / ( (b - a) / (c - d) ) + d

Gems = (50000 - 10000) / ( (100000 - 10000) / (125 - 25) ) + 25

Gems = (40000) / (90000/100) + 25

Gems = 40000 / 900 + 25

Gems ~ 69

We can see that we need around 69 gems needed to buy 50,000 resources.

Please note that I rounded up to 69 because the amount of gems must be an integer.