I've been trying to figure out a way to calculate the score in my game.... but nothing seems to work properly...

The score is to be calculated according to:

  • playtime
  • coins collected.

The playtime should be as low as possible and number of coins should be as high as possible.

For example: Let's say an idle play for a level X has:

  • playtime = 15 seconds
  • coins = 20.

The score is 100.

Then what will be the score when the:

  • playtime = 20 seconds
  • coins = 14.

P.S.: Pardon me if the example is wrong but I can't figure out how to explain my problem... Thanks in advance.


1 Answer 1


Maybe you want this one:

$$ (c_0 + c) \cdot {t_0 \over t_0 + t} $$

\$ c_0 + c \$ is the part for coins.
\$c\$ is how many coins a player has. \$c_0\$ is a constant which ensures positive score even if a player has no coins.

\$ t_0 \over t_0 + t \$ is the part for playtime.
A player finishes the level in time \$t\$. \$t_0\$ is a time constant.

How you should pick \$c_0\$ and \$t_0\$? Let's assume they are 30 coins and 30 seconds, and the level has 30 coins.

If \$t = 0s\$ then time multiplier will be \$1\$.
If \$t = 15s\$ then it will be \$2 \over 3\$.
If \$t = 30s\$ then time multiplier will be \$0.5\$.
If \$t = 60s\$ then time multiplier will be \$1 \over 3\$.
If \$t = 120s\$ then time multiplier will be \$0.2\$.

So, if a player just speedruns a level in 30 seconds without collecting any coins. His score will be \$30 \cdot 0.5 = 15\$.
Another player spends time collecting every single coin, \$t = 120s\$, his score will be \$60 \cdot 0.2 = 12\$.
But what if we decide to collect some easy coins while trying to finish level quickly? Let \$t = 60s\$, \$c = 15\$. Our score is... no, \$15\$ again.

You can encourage players to collect coins by lowering \$c_0\$, and to hurry up by increasing it. If you want to punish both those who don't collect coins and those who spend much time to collect them all, try lowering \$t_0\$. If we set \$c_0 = 10, t_0 = 10s\$, those players will score \$2.5\$, \$3.08\$ and \$3.57\$ points respectively.

If that's not enough, square the time multiplier. Or put some coins into places that are hard to get into.

Or course you can multiply the result by some constant, \$1000\$ for example, to prevent players from saying "why is my score always so low??"


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .