2

I am creating a mobile game where I would like to award prizes (ie. gold) to the players based on how well they did in the game. First place wins the most gold, last place will get a small amount of gold (more than zero).

However, I want the prizes to be awarded in an exponential fashion. By that I mean, if I set the maximum gold that can be won to 100, if there were 10 players in the game, I would award the guy in 1st 100 gold, the guy in 2nd 75 gold, 3rd gets 60, 4th gets 50, 5th gets 43... etc. Note that they do not add up to 100, but each player gets a percentage of the max gold based on their place in the game.

So, I'm really hoping someone can help me figure out a formula I can use in the following function :

function calculatePrize(place, totalPlayers) {
  // do some calculation to based on their place to find out what percentage of the max prize the should get (value will be between 0 and 1)
}

// call the function and multiple by max prize theirPrize = calculatePrize(6, 10) * maxPrize;

(the above code will call the calculatePrize function, telling it there are 10 players and thie particular player got 6th. The function would return a decimal between 0 and 1 (ie .55).

So, if the max prize in this example was 100, that player would get 55 gold.

Any idea how to do this? I've been googling and trying formulas on my own and getting no where :(

Thanks!!!

  • 1
    Use the formula $A = 100(1-r)^n$ to generate winnings, where $r$ is the percent decay (as a decimal). – Sean Roberson Jul 31 '22 at 21:27
  • @SeanRoberson Your formula looked very promising when I tried it for 10 players. I then tried it for 100 players and unfortunately all players after about rank 13 all players get almost nothing. I didn't make it clear, but there is no prize pool.... there is just a maximum prize. So the more players the more winnings will be awarded. – Ryan Ritten Jul 31 '22 at 22:11
  • You can easily adjust this for any prize pool. – Sean Roberson Jul 31 '22 at 22:16
  • Ok, ya, I see that now. I am assuming I just need to adjust the r value based on the number of players – Ryan Ritten Jul 31 '22 at 22:17
  • The numbers 100, 75, 60, 50, 43 are not decaying perfectly exponentially. I tried to guess at a pattern: take away 1/4 of 100 to get 75, take away 1/5 of 75 to get 60, take away 1/6 of 60 to get 50, but take away 1/7 of 50 gives 46.5, not 43. Not sure what exactly you want. – anon Jul 31 '22 at 22:22
  • If you want to avoid losing players recieving nothing, I might suggest adding a minimum prize, eg. 10. Adapting Sean's formula, you get $A=10+(100-10)(1-r)^{n-1}, n=1, 2,...$ – Angelica Jul 31 '22 at 23:01

3 Answers3

3

If you like the values you've listed, I would reccomend dividing the gold according to a harmonic series. If you let $G_0$ be the maximum reward, try giving players gold according to the formula

$$G=\left\lceil G_0\frac{3}{n+2}\right\rceil \text{ for } n=1,2,\cdots$$


Edit:

This formula can be tuned by varying the value of $x$ in the following formula:

$$G=\left\lceil G_0\frac{x}{(n-1)+x}\right\rceil$$


Setting $G_0=100, x=3$, we get the following values for the first hundred players

$$\begin{matrix} n & G\\ 1&100\\ 2&75\\ 3&60\\ 4&50\\ 5&43\\ 6&38\\ 7&34\\ 8&30\\ 9&28\\ 10&25\\ 11&24\\ 12&22\\ 13&20\\ 14&19\\ 15&18\\ 16&17\\ 17&16\\ 18-19&15\\ 20-21&14\\ 22&13\\ 23-25&12\\ 26-27&11\\ 28-31&10\\ 32-35&9\\ 36-40&8\\ 41-47&7\\ 48-57&6\\ 58-72&5\\ 73-97&4\\ 97-100&3\\ \end{matrix}$$

Angelica
  • 1,963
  • I apologize, I just listed numbers off the top of my head that seemed semi-exponential.... it was just an example. I was looking for an actual formula to generate real exponential numbers – Ryan Ritten Jul 31 '22 at 23:34
  • 1
    @RyanRitten The harmonic series and geometric (exponential) series have many of the same properties, including finite start, tending to zero, and monotone decreasing. You noted in the comments above that the geometric series formula was reaching zero much too fast; the harmonic series decays to zero much more slowly. As such, it might serve your purposes better. – Angelica Jul 31 '22 at 23:52
1

Fix a parameter $T$. You can experiment to choose a value you like. The larger $T$ the faster the rewards drop off.

Let $S(j) = T^j$ be the share for the player at rank $j$, numbered so that the best of the $n$ players has rank $n$ and the worst has rank $1$.

Let $S$ be the sum of the shares. (You can find $S$ in closed form since it's the sum of a geometric progression. No need to loop.)

Give player $j$ the fraction $S(j)/S$ of the gold to be awarded.

You can set the total in advance to be divided up, using either a fixed amount or a fixed amount for the best player.

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199
0

An easy solution is as follows: Let $M$ be the size of the prize pool, $r$ a rate of decay, and $n$ the number of players. Then player $n$ will receive $M(1-r)^n$ gold.