1

Math has never been my strong suit. But with my head in the books and me paying attention at every step while problem solving I did... pretty good. But my calculus was 20+ years ago. I'm close to zero retention. I did some searching and came up with some results showing the A*log(Bx)+C or something along those lines.

It was a help but not getting me exactly where I want to be.

The purpose is to provide an exponential decay for a game mechanic. For anyone who plays Elite Dangerous this will sound familiar and is actually an improvement I want to propose. But I wanted to do it first with a math formula to provide a generic behavior for a range of values.

The mechanic is as follows. A player can "jump" to enter a faster than light travel within any star system. This is called "supercruise" (SC). If you have a small ship in normal flight and a large ship comes over to beat you up and you want to get away and enter SC their mass will extend the period of time needed to do this by a "Mass Lock Factor." (MLF)

But this seems to be a boolean type of state. If I am within $x$ kilometers (lets say 4.5) with two specific types of ships and I have a MLF of 24 applied to me. If I'm >4.5 km the MLF is 0.

The proposal would be the sum of the new MLF of all ships within 5km. This is why the y-axis is clamped to 1. As the MLF would approximately be something like: $mass_{enemy}/mass_{player} \cdot f\left(x\right)$ where f(x) = 0..1 I didn't want the decay to ramp up really until the ship under the effect was close to the distance limit of 5km.

So I want to the log function to always be $f\left(0\right)=1$ and I chose 5km as the cutoff so $f\left(5\right)=0$.

What I came up with was: $$ \frac{\log \left(-s\left(x-d\right)\right)}{???+ \log \left(s\right)}+\frac{d}{s} $$

d = threshold distance. If a ship is > d kilometers away there is no affect.

s = scale factor to get the function to hug 1 longer.

$ \frac{d}{s} $ This was added as I noted for small values of s the function would stray from d. That seemed to greatly fix that issue. Although for small s it still strays but barely. My problem is with the divisor which is incomplete. (Well maybe I'm completely wrong in my approach and it needs a total rehaul IDK.)

I noted that as I changed s I seemed to add the log of s to the number I had put there. But this number changes for changes in s and d. Where s = 100 and d = 5 it's ~ 0.84

Removing $\frac{d}{s}$ and with some tinkering seeing how the graph moved with ${\log \left(s\right)+ \left(0.1d\right)}$ as the divisor I came up with: $$ \frac{\log \left(-s\left(x-d\right)\right)}{\log \left(s\right)+\log \left(d\right)} $$

I think this is much better as the graph isn't translated up and over one for high values of d and IDK why it works but the divisor always clamps to 1 at x=0. But for s < ~100 it starts to stray from d. How do I fix that?

(Or is there a better function?)

If I put back the d/s term both are approximate but not exact...

  • Tip: long questions get fewer answers. It sounds like you want a function $f$ such that $f(0)=1$, $f(5)=0$, and a gradual downslope between $x=0$ and $x=5$. It might be easiest if you just sketch the curve shape that you want. – bubba Jan 25 '16 at 12:52
  • You could use a cubic Bézier. With the Wikipedia's notation you'll have $P_0=(0,1)$ and $P_3=(5,0)$ and you can use $P_1$ and $P_2$ to adjust the curve. The problem is that it will be harder to find $y$ as a function of $x$ as for the Bézier curves both the coordinates are function of a parameter ($t$) going from $0$ to $1$. – N74 Jan 25 '16 at 15:19
  • I would definitely need to benchmark that. But from the reading it seemed expensive computationally before I saw that the article mentioned that itself. $s$ and $d$ would be tinkered with to determine what to use but in-game are fixed. So the divisor and $\frac{d}{s}$ would be precomputed – Nolan Robidoux Jan 28 '16 at 13:53

0 Answers0