Search code examples
algorithmgame-theory

Parametric Scoring Function or Algorithm


I'm trying to come up with a way to arrive at a "score" based on an integer number of "points" that is adjustable using a small number (3-5?) of parameters. Preferably it would be simple enough to reasonably enter as a function/calculation in a spreadsheet for tuning the parameters by the "designer" (not a programmer or mathematician). The first point has the most value and eventually additional points have a fixed or nearly fixed value. The transition from the initial slope of point value to final slope would be smooth. See example shapes below.

  • Points values are always positive integers (0 pts = 0 score)
  • At some point, curve is linear (or nearly), all additional points have fixed value
  • Preferably, parameters are understandable to a lay person, e.g.: "smoothness of the curve", "value of first point", "place where the additional value of points is fixed", etc

For parameters, an example of something ideal would be:

  • Value of first point: 10
  • Value of point #: 3 is: 5
  • Minimum value of additional points: 0.75

Exact shape of curve not too important as long as the corner can be more smooth or more sharp.

This is not for a game but more of a rating system with multiple components (several of which might use this kind of scale) will be combined.

This seems like a non-traditional kind of question for SO/SE. I've done mostly financial software in my career, I'm hoping there some domain wisdom for this kind of thing I can tap into.

enter image description here

Implementation of Prune's Solution:

enter image description here

Google Sheet


Solution

  • Parameters:

    • Initial value (a)
    • Second value (b)
    • Minimum value (z)

    Your decay ratio is b/a. It's simple from here: iterate through your values, applying the decay at each step, until you "peg" at the minimum:

    x[n] = max( z, a * (b/a)^n )
    // Take the larger of the computed "decayed" value, 
    //   and the specified minimum.
    

    The sequence x is your values list.

    You can also truncate intermediate results if you want integers up to a certain point. Just apply the floor function to each computed value, but still allow z to override that if it gets too small.

    Is that good enough? I know there's a discontinuity in the derivative function, which will be noticeable if the minimum and decay aren't pleasantly aligned. You can adjust this with a relative decay, translating the exponential decay curve from y = 0 to z.

    base = z
    diff = a-z
    ratio = (b-z) / diff
    
    x[n] = z + diff * ratio^n
    

    In this case, you don't need the max function, since the decay has a natural asymptote of 0.