A bit of math problem

I have a, should be simple, math problem that I just have hit a mental block on.

I want to use a slider to answer a question, so let’s say.

“During which decade did Napoleon die?”

The answer would be 1920.

My problem is that I want to give more points per decade you are close. So if you are 10 years (one decade) from, you get 90 points, if you are 20 years from, you get 80 points. And so on down to 0.

Anyone got any idea how I could run a good calculation for this? Simply +/- the decade with the answer will only make it so you get less points the closer to the answer you are, which is the opposite of what I want.

Please do see attached image for the crappiest paint job to ever exist.

You’re looking for something like:

int points = Mathf.Max(0, 100 - Mathf.Abs(targetYear - guessedYear));
1 Like

Absolute value of (Actual Year - User Answer) * points per year