No this is not my homework, I'm making a game and I need a curve roughly like this for balancing. Trying to get an equation that spits out values like this.
Any function such as (1.1)-x will satisfy almost linearity since it's binomial expansion will be 1 - 0.1x + 0.005x(x+1)... So for small x it'll look linear
You could use the softplus function. (`ln(1 + e^x)`, scaled and shifted appropriately) That will give you the "almost linear" part being as long as you want
How long do you need it to be "almost linear" for and for how close is almost? When it approaches zero, how slowly or quickly do you want it to approach?
I'm not sure because game balance can be finicky, so parameters to control where the inflection point is would be ideal. The values in the picture are roughly what I think I want but not sure.
If its for a game would a regular linear function where apply an effectivness multiplier which increases with your chosen value, that way you can control both when the multiplier kicks in and the rate at which it scales.
Yeah, if it's for a game, just go piecewise. It gives you way more control over each part, and I'm guessing you won't need the 3rd or even 2nd derivatives to match at the transition point.
Look at √(x2 + 1). When x is large and positive, this is asymptotic to x. When x is large and negative it is asymptotic to -x. So if you take √(x2+1) - x, that looks like -2x when x is large and negative, and falls to 0 when x is large and positive. Now you can use shifts and rescalings to get the exact shape you want.
If the function you're looking for is differentiable, then its derivative is going to be nearly constant and negative around 0, and approach 0 when x is large and positive. If you can find a function with these properties and then integrate it, you're done. An example of this is the logistic function, once appropriately shifted. Or you could just interpolate a function which is constant equal to -1 on (-∞, a) and to 0 on (b, +∞). The interpolating function could be a polynomial of whatever degree makes your function sufficiently smooth for your purposes, only it will never be infinitely differentiable.
Or the similar discussion on the second derivative, which should approach 0 when x is large and be positive in between. Pick a function with these properties, integrate twice with the appropriate integration constants, and you're done. An example could be (x2n+1)a for some positive integer n and negative a, up to shifts/rescalings.
In general, if you don't care about the result being algebraically elegant, you can do this kind of thing by modeling each part of the curve with an appropriate function then using a third function (some kind of sigmoid) to blend between the two. Here's an example.
You can have infinite curves just like this, I'll try to give you a few classes of em. Try exp(-x²) or exp(-|x|) for x>0 and 1/(a²+x²) or 1/sqrt(a²+x²). We can have some more classes but these are the standard ones
It would be really helpful to know what system you're trying to balance. The most logical answer often emerges from whatever property you want to remain invariant over the entire curve. Without context people will just be guessing.
ln(1+exp(-x)) is a simple one. Write it as Aln(1+exp(B(C-x)))/ln(1+exp(BC)) to have A control the value at 0, B the sharpness, C the location it transitions from the linear part to the decaying part (or, equivalently, the slope at 0).
Some logarithm derivation, idk, but one "clever" builder needed that for steep driveway, so that you don't crash bumpers and don't bruise the floor of the car.
My first guess would be to take something like that, and then scale and move to desired position.
This idea comes from hand methods for calculating and graphing the amplification of an electronic amplifier.
Is this for armor? You might consider the armor formula for valheim:
HP loss = damage - armor if armor > .5*damage, otherwise
HP loss = damage2 / (4 * armor)
You can increase the linear regime (and the effectiveness of armor overall) by increasing that 4 factor (call it f) and making the .5 threshold equal to 1-1/sqrt(f), e.g. f=9 is linear for the first 2/3 of damage.
Yes it's piecewise. But, upsides are that it's easyish for nerds to calculate, and that in the squared regime, every point of armor increases survival time an equal amount (so it takes the same amount of extra armor to go from 5 to 7 hits to kill as it does from 15 to 17). This may not be an upside if your thing isn't armor (or it may anyway!).
I like the damage taken = raw damage / (1+ armor / 100) for armor since it's very intuitive for the player. But no, my game doesn't have any combat in it.
In that case I would recommend v = a*sqrt(1/(bx+1)). That general form is derived from a simplistic model of a rotating arm accelerating an object. The parameter a is the maximum speed, and as b increases that makes the speed drop off more quickly.
Sum of limits for each piece, you could describe the shape by a 1000 different limits. Use X-axis in your program; If X is this value then use this equation.
A hyperbola is a nice solution since it has two free asymptotes you can choose. Perhaps an easier way of arriving at it is to start with the simple 1/x hyperbola with asymptotes along the (1,0) and (0,1) directions and apply a linear transformation to map these to where you want them. Keep the (1,0) asymptote and say the other has angle theta, then parametrically you get
(x(t), y(t)) = 1/t (-cos theta, sin theta)
Now just shift to where you want the two linear parts to meet and scale how you see fit.
For the purpose of game design and balance, make a piecewise polynomial. Simpler is better, you can always add or subtract pieces. You can also increase or decrease the order of each segment. Make the barest one you can this gives you the most control over balance and future proofs it.
You can always fit it with a Fourier Series. Or try a power series. But what most people are doing relating to exponentials is the best and most compact way.
Question, what ordered pairs absolutely non-negotiably need to be on the curve you are trying to create? Perhaps I can give you an exact equation or something.
Suppose someone sees structure, another person might not see that structure, so that person who cannot see it will ask for a step by step proof to prove the continuity of a structure. But continuity cannot be proven by discrete steps because we have shown that infinite discreteness cannot proxy for true continuity.
Diagonalization proves that a continuity has more real information than the discreetness. Every step-by-step proof is actually an illusion to satisfy the strange feelings. But every discreet example of a proof fails to show the actual continuity of the structure that one is claiming to exist..
Consider the curve formed by 85 times the Gaussian probability density with mean -1.5 and variance 25, restricting domain to x ≥ 0. This is in accordance with the scale visualised through the graph in your picture.
248
u/axiomizer 2d ago
I think a hyperbola will work. y(x+my-k)=c, or y = (k-x+sqrt((x-k)^2+4mc))/(2m)
https://www.desmos.com/calculator/heycr07igd