I need to figure out this log function
3absh
Member Posts: 601
I'm making an RPG
The aim here to to make the time between "re-occurrences" (the element shows up) shrink with every passing day until it gets infinitely close to 4 but..
it never reaches it. I know this function has something to do with log but I just can't figure out the formula for this curve
(BTW the value during day 1 is 8)
please help me.
Comments
You can just take 4 (of the 8) and divide it by a ratio of its current value and then add the result to 4.
So for example if N starts life as 4 . . . .
Constrain N to N/1.005
Or every X seconds change N to N*0.99
Also, I expect the idea of nearing 4 but never reaching it will be defeated by rounding errors, you might have to artificially keep it above 4 (for example wrap everything in a 'ceil' function).
Perhaps use the ln(x) function.
will give you (at least tens of) thousands of days before it hits 4.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Example plot of a value being divided by a a ratio of its current value . . .
Adapting @Sock's demo a little, here's the curve of
8-(ln(day count)/3)
(I artificially raised it a bit on the Y axis, so it's not entirely representative, but the shape of the curve itself is.)
I've had it running in the background since my last post, and after 40,000 days it's down to 4.47.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Shape looks good.
Day 80,000 now and down to 4.24.
This is like the most boring but compelling game I've ever made.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
The Curve™
Watch as the curve inexorably drops towards ground zero in this excruciating tedious arcade classic.
Looks like a Nibiru flyby mission
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
y = (4/x) + 4 gives a close curve to what you're sketching.
recurring = (4/day_count) + 4
How I got this was that i knew 1/x gives a graph that approaches zero curve so i can just add 4 to shift the graph so that it approaches 4
But i know that you want value to be 8 when x=1 i want the y = 8 after the graph is shifted so before shifting it 4 units, i want value of y = 4 when x = 1
looking at the default curve, i have x=1 y=1
so to get 4 i'll just multiply the graph by 4 so i get 4/x instead of 1/x now if i shift it everything is as you specified. An inverse curve where y = 8 when x = 1
Here are other variations of equations that will give you a dropping/approaching to 4 that crosses point (1,8). I think from these you'll have a really good idea of what you want depending on if you want y to quickly/slowly drop towards 4. You'll see that the pattern is any number over a quarter of it with x being 1 will produce your wanted conditions crossing point (1,8).
Y = 1/x + 4 gives you an asymptote curve. Easy as heck. Enter in excel, graph it for reference.
My Blog / App Store / Google Play
I was thinking out of curiousity what if you wanted this curve to fit 2 specified days/points. For example day 1 and day 2
Let's say for example you want
the value to be 8 for day 1 (point (1,8)),
the value to be 6 for day 2 (point (2,6)).
There are probably other ways but i found this method to work visually for me.
I know the form of the curve has to be a/(x+b) + 4
so since i know x for day 1 and 2 (it's just 1 and 2), I'll graph it and see where it fits solving for a and b, but since we're graphing we'll name them x,y respectively to get values where they satisfy these equations
for day 1, x = 1, y = 8
so we'll graph
x/(1 + y) + 4 = 8
for day 2, x = 2, y = 6
so we'll graph
x/(2+y) + 4 = 6
and see where these two graphs intersect
where they intersect is our answer for x and y, in which we'll replace a and b
They intersect at (4,0)
so we know in order to have this curve to fit our 2 points/days specs, we'll need to use the equation
a/(x+b) + 4
so our answer is 4/(x+0) + 4 ---> 4/x + 4
which will fit the curve to cross point(1,8) and point(2,6)
Let's try another example, just for fun (because i love graphing too much )
We want
day 1 to be point (1,8)
day 2 to be point (2,7)
enter equations
x/(1+y)+4 = 8
x/(2+y)+4 = 7
we see intersection at (12,2)
answer for curve that goes through point(1,8) and point(2,7) : 12/(x+2) + 4
Graphing is fun
or you can enter equations for using a,b like here: https://www.wolframalpha.com/input/?i=a/(1+b)+++4+=+8,+a/(2+b)+++4+=+7
Wow, I'm overwhelmed, thanks a lot guys. I thought I was the nerdiest guy here, I was wrong
You have to tell us which one you end up going for!
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I agree...I am also curious as to what the game is like I wish i had ideas of games that involved such fun functions.
I ended up going for the log, my second post
Reason is I don't want the decrease in recurrences to be very dramatic during the first few days. I want it to be a bit subtle.
I think all RPGs require some functions. The function i wanted is merely a very basic and quite primitive levelling function
Did you see my last post with graphs, you can specify the rate at which you want it to go down by by setting day 1 and day 2, then let the function take over.... so you could specify a really slow rate by choosing something like 8 for day 1 and 7.5 for day 2 or maybe even slower, like 7.9 for day 2
I tried log functions too but they don't seem to approach any number, they keep going up/down non-stop because of power rules.