Use this thread for various math that occurs in a game. Instead of 50 different threads, I figure one thread is better.
Question: in a game where you purchase items and the value of the item increments by a certain value every time you purchase it, what is the explicit formula for determining this?
For example:
Items starts at $10.
You want to buy 10 of them.
It increments by $5 every time you purchase one.
What is the total amount of money that you will need to purchase 10 at once?
$10*5 + ((10 * $5) * 5) + 5 *5 = $325
Is that the right formula?
Let's check:
10+15+20+25+30+35+40+45+50+55 = 325
It might be.
Sum up the formula:
(Iv * t/2) + (t * i) * i) + (t/2 * i) = Fv
Iv = initial value
t = times the item purchased (we wanted 10, in the xample)
i = the amount the item increments with each purchase
Fv = final value after the purchase is complete
I know this is a lot of math but this keeps on bothering me and a recursive formula is far too easy to make but difficult to just randomly employ. I need an explicit one so I don't have to keep track of previous values. I don't think the above is correct.
((n(n-1))/2) + Iv calculates the final value of the 10th item (in the first example).
n = number of items
(9*10)/2+10 = 55
We know it will cost $55 for the final item.
So I believe I'm onto something there.
Surely there's a much quicker way to go about calculating this.
Seriously, please help me figure this out as it's frustrating me.
Edit - Gauss did a calculation similar to the thing I'm looking for when he was in elementry school. 100+1, 99+2, etc. 101*50 = 5050 which is all the number 1-100 added up.
Maybe I could approach it from that angle. I'll try it.
Edit 2 - That works but it requires I figure out the final item's purchase value before I can make the calculation using Gauss's method. There's got to be an explicit formula for the whole thing.
__________________
Last edited by dadudemon on Jun 30th, 2011 at 12:31 AM
No. tbh I only made it halway through your post though. Could you summarize it?
__________________
"The Daemon lied with every breath. It could not help itself but to deceive and dismay, to riddle and ruin. The more we conversed, the closer I drew to one singularly ineluctable fact: I would gain no wisdom here."
Last edited by Tzeentch on Jun 30th, 2011 at 12:21 AM
I can't. You can read the first portion and read the conclusions but the stuff in between is an example of what I'm talking about which makes it kind of important to understand the rest.
Many games have incremental purchase prices for their items. It prevents people from buying too much of one item as they get more money in the game.
Sometimes, the increment is a factor, not an exact value. (Iv * 1.2 versus Iv + n*x, for example.)
But, I figured it out using Gauss's method. It's still not complete as you have to figure out one set before you can use it in the second set. That's clunky and not elegant. I want a complete, single, formula for figuring this out. I could also re-work it to use factors and not an exact value. You know what I mean?
To add up all the numbers from 1 to 100 one can use the equation (n(n+1))/2. Thus we can use this however, since the first number equals 0 we actually want ((n-1)(n-1+1))/2 or (n(n-1))/2.
Here is what I came up with (Iv *t) + (t(t-1))/2*i = FV
Hmmm this is incorrect. You appear to be adding 15 everytime rather than 10.
They keep incrementing the value of items so you don't stack up too much on one particularly good item or don't become too powerful early on.
And example of incrementing purchases: the Gemcraft series. It increments quite a bit by factors creating almost a "soft cap" for many of the upgrades.
It can be. This is all about game math, questions about it, or ideas. The first portion is just one of many things we can talk about.
I'll test this in just a second.
You're right. I incremented by 15, 15 times. In that example, you can just change the "i" to a 15 rather than changing the whole set.
Edit - YUP! It works. That's what I was looking for. Exactly what I was looking for. Ares...you are now my new favorite poster.
(Iv *t) + (t(t-1))/2*i = Fv
This can be altered to use a factor instead of an increment. I'll rework this to do increments, in a while. Feel free to take these equations and put them into your own RPG game code.
__________________
Last edited by dadudemon on Jun 30th, 2011 at 03:16 AM
Cool. I do a fair amount of WoW theorycrafting, it's a good time. It's kind of leaked into my other gaming habits, and I think in terms of optimization. Most of it is paper napkin math, but I've worked out a few formulas and do a lot of in-game testing.
It's sometimes hard to model an ideal attack strategy (whether it's a sequence of attacks/spells/whatever, a specific combination of forces, formations, etc.), regardless of the game (shooter, strategy, RPG), and the best games leave too many variables to nail down a "best" because a lot of the strategy is context specific. But it's usually easy to identify a clear winner between two possibilities. Such binary comparisons, if done on a near-constant basis, can over time hone your approach into a few really, really good options. That's generally how I approach games, since I enjoy taking them seriously and getting a lot out of my characters, units, armies, etc. The actual formulas behind the mechanics are rarely transparent though, so it's an inexact art most times.
Those players that can stop and think about the math involed in the game will always have an advantage over their competitors.
I used to be part of a large alliance of players in an RTS game. Whenever they would release the new unit stats for each patch they released, I'd calculate all of the numbers that maximized upkeep costs to defense and attack ratios. This maximized our forces per unit gold spent and we were literally the number one alliance on the server due in part to our unit efficiency.
Some people get pissed and say you shouldn't bring "schoolwork" to play. I love those types because they provide some hilarious victories. Spending an hour to workout the best possible strategy with some math is really cool when it gives you an advantage. Then they get mad and say you're cheating.
"The Daemon lied with every breath. It could not help itself but to deceive and dismay, to riddle and ruin. The more we conversed, the closer I drew to one singularly ineluctable fact: I would gain no wisdom here."
Yes. Yes we are. I just wrote a trinket comparison for the newly-dropped 4.2 patch for WoW, that got posted to a popular class-specific website as a guide.
Heh. Well, it IS geeky, so there's only so much I can take pride in it. But I enjoy it. I have a semi-regular spot on a heavily-trafficked hunter website. The guy who runs it updates every weekday (so 5 articles/posts a week). I pop in occasionally with articles, and also take over for brief stretches of time when he goes on vacation and such.
Off-topic...but how do you have time for WoW gaming, WoW geeking, teaching (I assume you're still a teacher?), working out, KMC posting and modding, AND a dating life? Do you not sleep much? [Back on topic...]The math just doesn't add up.
Heh. My degree is in teaching, I actually work as the director of communications for an organization. Writing, editing, marketing, pr, etc. Not unrelated to my English background, but not teaching. Just as busy day-to-day, but I don't take much work home, which is nice.
I don't work out. I'm naturally sexy .
I make it a rule never to allow WoW to override my social life or work though. I keep my priorities aligned. It's surprising what you can do with not much play-time though. I just don't do anything frivolous. I don't grind useless things like achievements or mounts, anything I do has a tangible benefit to my play (which is primarily raiding, I don't PvP...though I do other things like extreme soloing and hunter-tanking, which are basically the same skills as raiding). As long as you've done your homework, and play with a specific focus, you don't need to sink epic amount of time in. So I raid 2 nights a week for 3 hours each night (weekdays, so usually nothing else going on). Then I'll put in time on weekends when I have spare time, so my overall playtime varies.
But I don't f--- around with alts (literally 2 toons ever with more than an hour of gameplay, and the other is mostly there to support the main with professions), and I enjoy the game when I'm getting the most out of my class and my performance, and that shows when I play.
But as a result, it takes me a long time to work through other games, or books I'm reading, stuff like that.
I'm also deceptive with KMC. I pop into my forums that I mod or frequent, post maybe 5 posts a day, check the reports, ban a sock or two, and am out in 10-15 minutes. I never spend long on here. If I'm ever "online" for longer than that, which is often, I probably just left my browser up and went to wank do something else.
Ok, I have a calculation here but the formula is under scrutiny. I am calculating force used in someone flipping 300 tons, roughply 4 meters in 1 second;
Is there a flaw in this calculations formula? regardless of the actual numbers used, is the formula sound? What can improve it or a counter formula that can fix errors?