I need to figure out this log function

3absh3absh Member Posts: 601
edited July 2015 in Working with GS (Mac)

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

  • 3absh3absh Member Posts: 601

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    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).

  • ArmellineArmelline Member, PRO Posts: 5,368
    edited July 2015

    Perhaps use the ln(x) function.

    8-(ln(day count)/3)
    

    will give you (at least tens of) thousands of days before it hits 4.

  • SocksSocks London, UK.Member Posts: 12,822

    Example plot of a value being divided by a a ratio of its current value . . .

  • ArmellineArmelline Member, PRO Posts: 5,368
    edited July 2015

    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.

  • SocksSocks London, UK.Member Posts: 12,822

    @Armelline said:
    . . . . after 40,000 days it's down to 4.47.

    Shape looks good.

  • ArmellineArmelline Member, PRO Posts: 5,368

    Day 80,000 now and down to 4.24.

    This is like the most boring but compelling game I've ever made.

  • SocksSocks London, UK.Member Posts: 12,822

    @Armelline said:
    Day 80,000 now and down to 4.24.

    This is like the most boring but compelling game I've ever made.

    The Curve™

    Watch as the curve inexorably drops towards ground zero in this excruciating tedious arcade classic.

  • tintrantintran Member Posts: 453
    edited July 2015

    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).




  • mhedgesmhedges Raised on VCS Member Posts: 634
    edited July 2015

    Y = 1/x + 4 gives you an asymptote curve. Easy as heck. Enter in excel, graph it for reference.

  • tintrantintran Member Posts: 453
    edited July 2015

    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 :D)
    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 :D

    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

  • 3absh3absh Member Posts: 601

    Wow, I'm overwhelmed, thanks a lot guys. I thought I was the nerdiest guy here, I was wrong

  • ArmellineArmelline Member, PRO Posts: 5,368

    You have to tell us which one you end up going for!

  • tintrantintran Member Posts: 453

    @Armelline said:
    You have to tell us which one you end up going for!

    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.

  • 3absh3absh Member Posts: 601

    @Armelline said:
    You have to tell us which one you end up going for!

    I ended up going for the log, my second post :p
    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.

  • 3absh3absh Member Posts: 601

    @tintran said:
    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 think all RPGs require some functions. The function i wanted is merely a very basic and quite primitive levelling function

  • tintrantintran Member Posts: 453
    edited July 2015

    @abuabed84 said:
    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.

    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.

Sign In or Register to comment.