Compound Decay

ChaosWarlock

New member
Joined
Dec 27, 2021
Messages
4
Hi Everyone. I'm looking for some help in solving a unique issue.

I'm making a spreadsheet to help calculate profits on an economy based game I'm playing. In this game when I craft an item it requires x number of resources but once that item is crafted not only do I receive the item but I also receive a percentage of the resources used to craft the item. I'll call this the resource return rate. I'm trying to create a formula where I can plug in the number of items I want to craft and it will give me the number of resources I need to craft them based on the compounding resource return rate.

For example. If I have 100 resources, it costs 10 resources to craft 1 item, and my resource return rate is 50%. I would craft 10 items and be returned 50 resources. I could then craft 5 items and be returned 25 resources. Then I craft 2 items with 5 resources left over returning 10 resources. Then craft 1 item with 5 resources left over returning 5 resources. And finally craft 1 item with 5 resources returned. At which point I would have 19 items and 5 resources. So in this example if I had indicated that I wanted to make 19 items it would have told me that I would need 100 resources.

I've tried to use a compounding depreciation formula that I found online but I'm not exactly where all of the pieces fit. I'll start off by saying that I'm not sure if this is even the right formula for what I'm trying to do.

p = principal number of resources required to craft the desired number of items
r = resource return rate
t = the number of times you craft or number of items desired?
c = the number of resources where you can't craft any more items

p(r)^t=c
  1. I know the value of r (0.5 from the example above).
  2. My thought was that if I set c to 1 less than the number of resources required to craft 1 item then that would be the stopping point. So from my example above c would be 9).
  3. I'm not sure if t should be the total number of items I want to craft (19 in the example above) or the number of times I craft items and return resources (5 in the example above). If t is not the total number of items I want to craft then I'm not sure where I would enter that into the formula.
  4. I'm trying to solve for P and I'm not sure how to do that. I haven't had a math class in 20 years so I'm not sure if I can just divide both sides by (r)^t to isolate p.
Thank you in advance for any assistance. I really appreciate anything you can teach me here.
 
First, in your example, you only needed 95 resources to craft 19 items, not 100 because you had five resources extra. Second, I think you're overthinking.
[math]P=c*t*(1-r)[/math]where c= resources needed to craft 1 item, t= # of items desired, r=return rate, p= # of resources needed.
# of Items Desired (t)​
# of resource needed (P)​
15
210
525
1050
1995
 
Last edited:
Thank you for the reply BigBeachBananas!

There are a couple of issues with the formula you provided but I think you've put me on the right path.

Your formula does get the 95 in the example above but if the resource return rate is say 25% instead of 50% it produces a much lower number for P when it should produce a higher number. I believe I need to reverse the resources return rate. So instead of r I would have 1-r.
P = c * t * (1 - r)

The next problem is that I do need the 100 resources from the example not 95. This is due to the fact that the last item crafted will always return resources. If I had started with 95 resources I'd have only been able to craft 9 items in my first round of crafting. Which would return less resources and reduce further the number of items I could craft. So to solve that I think I have to add the resource return of the last item to P.
P = c * t * (1 - r) + c * r

I've tested this with a few different examples and it seems to work pretty well. It doesn't take into account that I will not get fractions of a resource returned to me. Which could throw the numbers off one way or another. But I think this will work for my purposes. I can just round down my resource return rate to ensure P ends up slightly higher than necessary rather than slightly lower.
 
I had my reply up all morning and when I finally got around to hitting submit I see that you have edited your post to accommodate the resource return rate issue I just mentioned. I believe my other addition of + c * r is also still valid though.
 
If I had started with 95 resources I'd have only been able to craft 9 items in my first round of crafting.
You don't need 100 resources to craft ten items. You'll only need 50 resources to prepare ten items because you're getting a return of 50.
Maybe you need to distinguish between the cost to make an item vs what is required to make an item.
For instance, to craft ten items will cost you 10*10=100 resources, but you actually need is 50 resources because of the refund.
 
Last edited:
You don't need 100 resources to craft ten items. You'll only need 50 resources to prepare ten items because you're getting a return of 50.
Maybe you need to distinguish between the cost to make an item vs what is required to make an item.
For instance, to craft ten items will cost you 10*10=100 resources, but you actually need is 50 resources because of the refund.
The aim was 19 items off of 100 resources. I only picked those number to make the math easy and I was only able to work the problem backwards without the formula.

With the formula though I can now calculate how much resources I need to craft any number of items I desire. So thank you for getting me going in the right direction. I appreciate your help.
 
The aim was 19 items off of 100 resources. I only picked those number to make the math easy and I was only able to work the problem backwards without the formula.

With the formula though I can now calculate how much resources I need to craft any number of items I desire. So thank you for getting me going in the right direction. I appreciate your help.
No problem, anytime. If you wish to discuss why the equation works, let me know :)
 
Last edited:
Top