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'm trying to do a score that is based on the time taken and number of manipulators used. The faster you do it, with the fewest manipulators, the higher the score. I've managed to get it working with you get the lowest score but not the highest and i can't think how to do it. Any help would be appreciated.

I have a play time (GameTime.TotalGameTime.TotalSeconds - startTime.TotalSeconds) and a count of the manipulators used (grid.NumberOfManipulatorsInGrid(TextureList.GameplayTextures)) to work with

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I think this is a place where a power function may be ideal. If the best score S is achieved with N manipulators, you can have N+1 manipulators yield a score of S * 0.9 (ie. 90% of the best score), then N+2 manipulators yield S * 0.81 (ie. 90% of 90% of the best score), and so on.

This is generalised by the following formula:

score(num_manip) = S * pow(0.9, num_manip - N);

The advantage of this method is that you don't need any clamping: progressively bad performance will tend towards a score of zero.

The general score formulas can be:

TimeScore = TimeScoreBase * pow(A, BestPlayTime - PlayTime);
ManipulatorScore = ManipulatorScoreBase * pow(B, BestManipulatorCount - UsedManipulators);

You then need to choose TimeScoreBase and ManipulatorScoreBase (these are probably global to the game), tune A and B by how much you want the score to decrease for each additional second spent or each additional manipulator used (again, global to the game) and choose BestPlayTime and BestManipulatorCount (these, however, should be specific to the level being played).

Note that if by chance the player managed to finish the level in less time than BestPlayTime, it wouldn't be a serious problem, the score would simply be higher than TimeScoreBase. You may accept this, thus rewarding outstanding players, or clamp the total play time to avoid cheating.

Then you need to choose how to combine the scores:

Score = TimeScore + ManipulatorScore;
Score = sqrt(TimeScore * ManipulatorScore);

Each formula will have a different asymptotic behaviour, but the general idea is that the worse the play, the lower the score. The first one will give points for using few manipulators even in case of a bad time. The second one will give a bad final score if any of the two scores is bad.

share|improve this answer
    
Note: an edit was suggested that reversed the sign of the exponent in the pow calls. It is incorrect because, as illustrated in the first example, A and B are smaller than 1. –  Sam Hocevar Jun 12 '13 at 16:43
add comment

You could possibly invert it, a lower score could be what players could try to achieve: as another example your score isn't the number of live you have, but rather the number you lost - I think Touhou works like this. Therefore your score calculation would be:

score =
  (GameTime.TotalGameTime.TotalSeconds - startTime.TotalSeconds) * TimeScalingFactor +
  (grid.NumberOfManipulatorsInGrid(TextureList.GameplayTextures)) * ManipulatorScalingFactor;

However, if you really want a bigger score to be better you will need to have a time and manipulation limit; you could either end the game if the limits run out or go into negative values. This would imply:

score =
  (TimeLimit - (GameTime.TotalGameTime.TotalSeconds - startTime.TotalSeconds)) * TimeScalingFactor +
  (ManipulatorLimit - grid.NumberOfManipulatorsInGrid(TextureList.GameplayTextures)) * ManipulatorScalingFactor;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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