Can someone suggest a function to achieve this graph?

123 Views Asked by At

I need a function that achieves a curved, logarithmic (I think) graph.

The graph plots the level progression of a player of a simple game over time. Some players might progress faster, others slower, but this graph is the timeline my ideal player would take.

So the game has 100 levels, and I'd like the player to stay engaged for about 112 hours (3 x 30min sessions per week for 75 weeks). Level progression should happen much more frequently at the start, and then get slower as the level increases.

Can anybody suggest the best way to organise my thoughts around this problem?

Update

The player starts at level 1, having played for 0 hours. Within the first 0.5 hours of playing, the player should advance to level 2. By 112.5 hours, the player should have reached level 100. I'm not particularly married about the exact values in the middle, only that the progression should gradually slow from 1-2, 2-3, 3-4 etc.

2

There are 2 best solutions below

0
On

If you're not fixated on a logarithmic graph, a simple power function would do the trick.

Take $L = at^b + c$, where $L$ is the level, $t$ is the time (in half-hour play sessions) and $a,b,c$ are constants to be found.

You want $L$ at $t=0$ to be 1 so $c=1$

You also want $L$ at $t=1$ to be 2 so $a + 1 = 2 \implies a = 1$

Finally, you want $L$ at $t = 112.5 \times 2 = 225$ to be $100$.

So $225^b + 1 = 100 \implies b\log225 = \log99 \implies b \approx 0.85$

Hence the relationship is $L = t^{0.85} + 1$.

If you want to make the level purely integer, then just take $L = \lfloor t^{0.85} + 1\rfloor$ where the square brackets denote the floor function, meaning the largest integer not greater than the result of that power expression.

A graph would go like this: http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiJmbG9vcih4XjAuODUrMSkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyItNTIiLCI1MiIsIi0zMiIsIjMyIl19XQ--

You can zoom in and out to see the trend and where it ends up at the desired endpoint. The graph is "stepped" because of the floor function, which keeps the levels integral.

Would that be adequate?

2
On

I prepared different approaches. They all should range between $1$ and $100$ for the values on the $y$-Axis and between $0$ and $112$ on the $x$-Axis (Please excuse the fact, that my plots are ugly as hell, nice plots in matlab and me are mortal enemies).

  • logarithmic: We use the logarithm and fit it to your requirements. Thus getting \begin{align} L_1(t) = 1+99\cdot \log(t)/\log(112) \end{align} which looks like this enter image description here

  • square root: Simply use the $\sqrt{}$ function. Maybe this fits the worst, because the curvature is quite little. \begin{align} L_2(t) = \sqrt{t}\cdot 100/\sqrt{112} \end{align} enter image description here

  • logistic growth: maybe my favourite. Take a look at the Wiki page. I used \begin{align} L_3(t) = 99\cdot \Bigl(2\cdot\frac{1+\exp(-112/c)}{1+\exp(-t/c)}-1 \Bigr)+1 \end{align} where you can adjust the curvature via $c$. The first plot has $c=20$ enter image description here and the second has $c=30$ enter image description here