Math help...
Posted: Fri Oct 05, 2012 12:43 am
I am working on a shop plugin for minecraft servers.
One problem I ran into is that the prices to buy an item are always the same, no matter how many are in shop. To fix this, I am working on making the value of an item decrease as more of the item is in the shop.
I am doing this with a half-life sort of equation.
Here are variables that the server admin will configure:
halfLife
itemPrice
itemsInStock
The way i have this work is every time the stock equals the half life, the item price is halved.
If the half life is 10 and the item price is $20, you get this:
0 in stock = $20
10 in stock = $10
20 in stock = $5
30 in stock = $2.50
etc...
This is the equation i have to find out the price of an item:
newPrice = price / 2^(itemsInStock / halfLife)
The problem I have now is trying to calculate the price if a user purchases multiple items at once. How can I make an equation that calculates the price for multiple items? I have this equation that uses summation, but i would rather not use loops.
![Image]()
qty = items purchased
x = half life
y = raw price
z = items in stock
Thanks if you can help. If you don't understand anything, feel free to ask me to explain better :P
One problem I ran into is that the prices to buy an item are always the same, no matter how many are in shop. To fix this, I am working on making the value of an item decrease as more of the item is in the shop.
I am doing this with a half-life sort of equation.
Here are variables that the server admin will configure:
halfLife
itemPrice
itemsInStock
The way i have this work is every time the stock equals the half life, the item price is halved.
If the half life is 10 and the item price is $20, you get this:
0 in stock = $20
10 in stock = $10
20 in stock = $5
30 in stock = $2.50
etc...
This is the equation i have to find out the price of an item:
newPrice = price / 2^(itemsInStock / halfLife)
The problem I have now is trying to calculate the price if a user purchases multiple items at once. How can I make an equation that calculates the price for multiple items? I have this equation that uses summation, but i would rather not use loops.

qty = items purchased
x = half life
y = raw price
z = items in stock
Thanks if you can help. If you don't understand anything, feel free to ask me to explain better :P