Math Equation
I am trying to figure out how I can calculate something based on a few variables.
We have: 1. Max points = 20 points. 2. Minimum points = 1 point. 3. Jumps required to complete challenge and achieve max points = 4 jumps. Now lets say the player completes the challenge with just 2 jumps. He gets 20 points because that's the maximum he can get. Now lets say he completes the challenge in 8 jumps. He gets 10 points because he completed the challenge with double the required jumps so he gets half the max points. If he completes the challenge in a million jumps, he gets 1 point, that's the minimum he can get. Here's my question, what if the player completes the challenge in 5 or 6 or ..etc jumps? Is there a math term or equation for what I'm trying to achieve? It might sound basic to some of you but I've never been the brightest when it comes to maths. |
Re: Math Equation
earnedpoints = maxjumps / jumpsmade * maxpoints
if (earnedpoints > maxpoints) earnedpoints = maxpoints if (earnedpoints < 1) earnedpoints = 1 |
Re: Math Equation
Thank you.
|
Re: Math Equation
Quote:
I made an attempt and I think it gives what you want: PHP Code:
Code:
PHP Code:
Code:
1 Jumps = 20 points |
Re: Math Equation
I think Jimaway's formula is correct, however, his code is not.
If 8 jumps give you 1/2 max points (10) then 16 jumps should give you 1/4 max points (5). PHP Code:
Code:
1 Jumps = 20 Points |
Re: Math Equation
It works, but you have to turn them into floats like you did in your method. But hey the more methods the better.
Quote:
|
Re: Math Equation
Good stuff. Ok so now you have two methods to choose from. One consistently reduces points after MaxJumps (my method), while the other spreads out the reduced points in a long range (fysiks). I don't know what the output from jimaways looks like.
|
Re: Math Equation
Quote:
no i didn't test my code before posting, but like PartialCloning mentioned you had to use floats |
| All times are GMT -4. The time now is 18:08. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.