Online game programming issues.

Click For Summary
SUMMARY

This discussion focuses on calculating the cost of purchasing multiple buildings in an incremental game, specifically using a formula that accounts for increasing prices based on the number of buildings owned. The formula provided is ((BaseCost * (1.07^b - 1.07^a)) / 0.07), where a is the number of buildings already owned and b is the total number of buildings after purchase. The user successfully applies this formula to determine that with $20,000 and a base cost of $200, they can purchase 53 additional buildings. The conversation also addresses the need for a direct formula to calculate the total cost of buying multiple buildings at once, leading to further refinements in the cost calculation process.

PREREQUISITES
  • Understanding of exponential growth in pricing models
  • Familiarity with logarithmic functions and their applications
  • Basic knowledge of programming concepts for game development
  • Experience with incremental game mechanics and economics
NEXT STEPS
  • Research advanced pricing algorithms in game development
  • Learn about exponential growth functions in economics
  • Explore optimization techniques for in-game currency management
  • Investigate user interface design for displaying dynamic pricing
USEFUL FOR

Game developers, particularly those focused on incremental game design, programmers looking to implement dynamic pricing models, and anyone interested in optimizing in-game economic systems.

danielmchugh
Messages
3
Reaction score
0
Okay so i am building an incremental game and have a formula to work out how much it will cost to buy a set amount of buildings.

This is required as each time you buy a building the price for that building goes up.This formula is as follows:

((BaseCost * (1.07^b - 1.07^a)) / 0.07)BaseCost = Starting cost of buildings.

a = number of buildings i already own.

b = number of buildings i will own after buyingThis formula will give me a cost if i give it a set amount i want to buy.

But i need to work out how many i can buy with a finite amount of money, say 20000 if the base cost is 200 each and i already own 50.
 
Mathematics news on Phys.org
danielmchugh said:
Okay so i am building an incremental game and have a formula to work out how much it will cost to buy a set amount of buildings.

This is required as each time you buy a building the price for that building goes up.This formula is as follows:

((BaseCost * (1.07^b - 1.07^a)) / 0.07)BaseCost = Starting cost of buildings.

a = number of buildings i already own.

b = number of buildings i will own after buyingThis formula will give me a cost if i give it a set amount i want to buy.

But i need to work out how many i can buy with a finite amount of money, say 20000 if the base cost is 200 each and i already own 50.

Hi danielmchugh! Welcome to MHB! ;)

Filling in your numbers, we get:
\begin{aligned}\frac{200\times (1.07^b - 1.07^{50})}{0.07} &= 20000 \\
1.07^b - 1.07^{50} &= \frac{20000 \times 0.07}{200}\\
1.07^b &= \frac{20000 \times 0.07}{200} + 1.07^{50} \\
\ln\left(1.07^b\right) &= \ln \left(\frac{20000 \times 0.07}{200} + 1.07^{50}\right) \\
b \ln 1.07 &= \ln \left(\frac{20000 \times 0.07}{200} + 1.07^{50}\right) \\
b &= \frac{\ln \left(\frac{20000 \times 0.07}{200} + 1.07^{50}\right)}{\ln 1.07}
\end{aligned}
 
More generally, the formula is:
$$NrToOwn = \left\lfloor\frac{\ln \left(\frac{AvailableMoney \times 0.07}{BaseCost}+ 1.07^{NrOwned}\right)}{\ln 1.07}\right\rfloor$$

In your specific example, it's:
$$NrToOwn = \left\lfloor\frac{\ln \left(\frac{20000 \times 0.07}{200}+ 1.07^{50}\right)}{\ln 1.07}\right\rfloor
= \left\lfloor\frac{\ln 36.457}{\ln 1.07}\right\rfloor
= \left\lfloor 53.15\right\rfloor
= 53
$$
 
Thank you so much this is exactly what i needed! :)
 
danielmchugh said:
Thank you for replying again to the post it is exactly what i needed, after putting it in everything worked well but it has highlighted that my original formula is not working properly.

If each time you buy a building the price increases by baseCost * 1.07^N, what formula should i be using to find out the cost if i were to buy for instance 20 buildings in one go.

What do you mean exactly by "the price increases by baseCost * 1.07^N"?

Suppose you already own $N$ buildings and you've paid $Cost_N$ for the last building, what will you pay for the next building $N+1$?
And what will you pay for the one after if you buy both of them at the same time?
 
Sorry I ment to say:

Cost of building = BaseCost * 1.07 ^ Number already owned.

So if the base cost was 200 and i already owned 50 buildings.

Cost of one more building: $$$200 * 1.07 ^50 = $5891.4$$

So rather then running this multiple times over to find out how much it would cost to buy say 20 buildings at once, is there a formula i can use to get that answer directly?
 
Last edited:
danielmchugh said:
Sorry I ment to say:

Cost of building = BaseCost * 1.07 ^ Number already owned.

So if the base cost was 200 and i already owned 50 buildings.

Cost of one more building: $$$200 * 1.07 ^50 = $5891.4$$

So rather then running this multiple times over to find out how much it would cost to buy say 20 buildings at once, is there a formula i can use to get that answer directly?

Okay, so 3 more buildings would cost:
$$\$200 \cdot 1.07^{50} + \$200 \cdot 1.07^{51} + \$200 \cdot 1.07^{52}
= \$5,891.4 + \$6,303.8 + \$6,745.1 = \$18,940.3
$$
which is exactly what you can buy for $\$20,000$.
It brings you up to the $53$ buildings that the formula I gave earlier predicted.

The formula you gave yourself in the opening post tells us how much 20 more buildings will cost by substituting $a=50$ and $b=50+20=70$.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 26 ·
Replies
26
Views
3K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
2
Views
3K
Replies
1
Views
2K