Solved

# Poker Tournament Payout Equation

Posted on 2006-05-17
681 Views
I would like to have an equation or an algorithm to calculate the % of tournament winnings paid to players.

For instance if there are only 3 players paid out of X players in a tournament:

1st: 50%
2nd: 35%
3rd: 15%

But I don't want to have to store all of these values in an array or database and would like the payouts to be able to go as high as 100 places. It would be nice to be able to call a function like "getPayouts (50)" and it returns an array of all the payout % for 1st through 50th place.

I have somethign like this but as you will see it can get lengthy:

\$payouts = array (
0  => array (),
1  => array (100),
2  => array (70, 30),
3  => array (50, 30, 20),
4  => array (45, 28, 17, 10),
5  => array (40, 25, 15, 11, 9),
6  => array (34, 23, 15, 11, 9, 8),
7  => array (31, 21, 15, 11, 9, 7, 6),
8  => array (30, 20, 14, 10, 8, 7, 6, 5),
9  => array (29, 18, 13, 10, 8, 7, 6, 5, 4),
10 => array (28, 17, 12, 10, 8, 7, 6, 5, 4, 3)
);

where the index is the number of places to payout and the values the %

any suggestions?
0
Question by:guitarclap

LVL 5

Expert Comment

Uh, you'll have to provide the algorithim if you're hoping for a function, unless you want us to derive it from what you've given, which, incidentally, contradicts itself:

> For instance if there are only 3 players paid out of X players in a tournament:
>
> 1st: 50%
> 2nd: 35%
> 3rd: 15%
>
> 3  => array (50, 30, 20),
0

LVL 1

Author Comment

Typo. Sorry.

If I knew the algorithm then obviously I wouldn't be here. There are a few ways to attack this and I am looking for some input from other people to get those creative juices flowin`
0

LVL 40

Accepted Solution

You have to decide how the distribution works.

An idea...

<?php
for (\$i_number_of_winners = 1 ; \$i_number_of_winners <= 10 ; \$i_number_of_winners++)
{
\$a_winners = array();
\$i_parts = 0;
\$i_split = 0;

for ( \$i_winner = 1 ; \$i_winner <= \$i_number_of_winners ; \$i_winner++)
{
\$i_parts += \$i_winner;
}

for ( \$i_winner = 1 ; \$i_winner <= \$i_number_of_winners ; \$i_winner++)
{
\$a_winners[\$i_winner] = 100 * ((\$i_number_of_winners + 1) - \$i_winner) / \$i_parts;
\$i_split += \$a_winners[\$i_winner];
}
print_r(\$a_winners);
echo "There are \$i_parts part(s) to share amongst \$i_number_of_winners winners.\nTotal distribution \$i_split.\n\n";
}
?>

Results in ...

Array
(
[1] => 100
)
There are 1 part(s) to share amongst 1 winners.
Total distribution 100.

Array
(
[1] => 66.666666666667
[2] => 33.333333333333
)
There are 3 part(s) to share amongst 2 winners.
Total distribution 100.

Array
(
[1] => 50
[2] => 33.333333333333
[3] => 16.666666666667
)
There are 6 part(s) to share amongst 3 winners.
Total distribution 100.

Array
(
[1] => 40
[2] => 30
[3] => 20
[4] => 10
)
There are 10 part(s) to share amongst 4 winners.
Total distribution 100.

Array
(
[1] => 33.333333333333
[2] => 26.666666666667
[3] => 20
[4] => 13.333333333333
[5] => 6.6666666666667
)
There are 15 part(s) to share amongst 5 winners.
Total distribution 100.

Array
(
[1] => 28.571428571429
[2] => 23.809523809524
[3] => 19.047619047619
[4] => 14.285714285714
[5] => 9.5238095238095
[6] => 4.7619047619048
)
There are 21 part(s) to share amongst 6 winners.
Total distribution 100.

Array
(
[1] => 25
[2] => 21.428571428571
[3] => 17.857142857143
[4] => 14.285714285714
[5] => 10.714285714286
[6] => 7.1428571428571
[7] => 3.5714285714286
)
There are 28 part(s) to share amongst 7 winners.
Total distribution 100.

Array
(
[1] => 22.222222222222
[2] => 19.444444444444
[3] => 16.666666666667
[4] => 13.888888888889
[5] => 11.111111111111
[6] => 8.3333333333333
[7] => 5.5555555555556
[8] => 2.7777777777778
)
There are 36 part(s) to share amongst 8 winners.
Total distribution 100.

Array
(
[1] => 20
[2] => 17.777777777778
[3] => 15.555555555556
[4] => 13.333333333333
[5] => 11.111111111111
[6] => 8.8888888888889
[7] => 6.6666666666667
[8] => 4.4444444444444
[9] => 2.2222222222222
)
There are 45 part(s) to share amongst 9 winners.
Total distribution 100.

Array
(
[1] => 18.181818181818
[2] => 16.363636363636
[3] => 14.545454545455
[4] => 12.727272727273
[5] => 10.909090909091
[6] => 9.0909090909091
[7] => 7.2727272727273
[8] => 5.4545454545455
[9] => 3.6363636363636
[10] => 1.8181818181818
)
There are 55 part(s) to share amongst 10 winners.
Total distribution 100.

The algorithm is to work out how many parts exist IF each winner gets 1 more part than the next.

The last winner ALWAYS gets 1 part of the winnings.

So, 1 winner = 1 part.
2 winners = 3 parts.
3 winners = 6 parts.
4 winners = 10 parts.

0

LVL 1

Author Comment

RQ...
Bravo!

You have answered a few of my questions in the past (i think, or have commented on them -- recognize your name!!) and you seem to come through yet again.  This is EXACTLY what I was looking for -- a step in the right direction. I will tinker with it some more but you have given me a great start!
0

LVL 1

Author Comment

I am goign to leave the question open incase I have any questions or if someone else would like to put their 2 cents in :)
0

LVL 40

Expert Comment

The winnings are NOT weighted to any one person.

You could add weightings so that more of the winnings go to the winner. It is all about determining the number of shares you have to distribute and the number of shares each winner gets.

0

## Featured Post

This is a general how to create your own custom plugin system for your PHP application that you designed (or wish to extend a third party program to have plugin functionality that doesn't have it yet).  This is not how to make plugins for existing s…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.