Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to devise an score algo for my game. I want to award high scores to players who achieve the goal in minimum time and least number of moves.

I did this but its not going correctly:

var score = ((finishSeconds / moveCount).toFixed(2) * 100).toFixed(0);
share|improve this question

closed as not constructive by Byte56, Jonathan Hobbs, Laurent Couvidou, Josh Petrie, Ali.S Dec 9 '12 at 7:02

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Returning over 9000 when the game is finished in minimum time and minimum moves, and returning zero otherwise, is a scoring system that meets your specifications. I can only assume that's not what you had in mind, but you leave us guessing quite a bit here. –  Marcks Thomas Nov 19 '12 at 12:04
have a look at this fiddle based on the formula suggested by @Byte56, I think there is some problem with the formula. Either it gives u score as high as Infinity or 0. The two ends are very large. How can we further limit this so that it doesn;t go to infinity –  JeyKeu Nov 20 '12 at 8:57
That score does approach infinity for fast completions, but can only exceed highestScorePossible if the variables minimumMoves and minimumTime are set incorrectly. –  Marcks Thomas Nov 20 '12 at 14:26
add comment

1 Answer 1

Smaller numbers of either is better right? So how do we make sure that larger numbers make the score smaller? We divide 1 by that number. The larger the number, the smaller the parts 1 is broken into. We can change that slightly to allow for other minimums. See the example for a perfect score being calculated when the seconds elapsed is 1 and the moves taken are 1. Using this allows you to set these numbers higher and allow people to get better than perfect if they finish in fewer moves or less time than you anticipated the best to be.

var minimumMoves = 1;
var minimumTime = 1;
var score = ((minimumTime/finishedSeconds)*(minimumMoves/moveCount))*highestScorePossible)

By example, where a minimum time is 20 seconds and minimum moves is 5. The player finished in 38 seconds and 6 moves, where the highscore is 100:

(20/38 * 5/6) * 100 = 43.85

Where another player did it in 24 seconds with 5 moves:

(20/24 * 5/5) * 100 = 83.33
share|improve this answer
I've plugged the formula, doing some tests. Thanks –  JeyKeu Nov 18 '12 at 16:51
I'm getting strange setting using ur values for minimumTime and minimumMoves: moveCount:11 - finishSeconds:16 - score:1705 moveCount:11 - finishSeconds:14 - score:130 moveCount:11 - finishSeconds:16 - score:57 moveCount:10 - finishSeconds:13 - score:77 –  JeyKeu Nov 18 '12 at 17:49
Looks like you're calculating it wrong. It's not a very complicated formula. When the player time and moves equal the minimum values, the score is equal to 1. When they're greater than the minimum values, the score is less than 1. Check your code calculations against a manually calculated value. The example I provided is just an example of how to make larger time and move values into a smaller score. I suggest you tweak it to be more inline with your game goals. –  Byte56 Nov 18 '12 at 18:15
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.