Skip to content

Instantly share code, notes, and snippets.

@fabio-t
Created March 19, 2016 12:44
Show Gist options
  • Save fabio-t/ea93766e98a03e3eb425 to your computer and use it in GitHub Desktop.
Save fabio-t/ea93766e98a03e3eb425 to your computer and use it in GitHub Desktop.
Diminishing returns formula
public static double diminishing_returns(double val, double scale) {
if(val < 0)
return -diminishing_returns(-val, scale);
double mult = val / scale;
double trinum = (Math.sqrt(8.0 * mult + 1.0) - 1.0) / 2.0;
return trinum * scale;
}
@fabio-t
Copy link
Author

fabio-t commented Mar 19, 2016

Taken from here. Can be greatly useful.

For example, suppose you define a Skill, Climbing, that makes you decently good very fast but it takes a huge amount of effort to really master. Suppose each skill has levels from 0 to 500, and to go up one level it requires a certain "effort" (experience, money, whatever). Now, if "decently good" means skill level 100 and "mastering" means skill level 500, we could use a scale of 20 to get the following progression:

Effort Level
20 30.622
50 61.803
100 100
200 156.155
300 200
500 270.156

So, before skill level 100, small efforts yield big level increases. So we get to "decently good" quite fast.

After skill level 100, increasingly more effort is required to go up one level. To get to a level less than 3 times higher than "decently good", we need 5 time the effort it took us to get there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment