Dear PHPers,
I'm currently developing a cupsystem for a new gaming ladder called "ClanFight". Now, I hit a snag.
I am trying to determine how many brackets should be played before the end is 'near', so to speak. For example:
PHP Code:
$totalPlayers = 64;
$totalBrackets = $totalPlayers * 2 - 1; /* 128 minus 1, 127th is the winner */
Now, of course I know that we have to play:
64 players, remainder 32, remainder 16, remainder 8, remainder 4, remainder 2, winner 1. A total of 127 brackets (64 + 32 + 16 + 8 + 4 + 2 + 1 = 127).
Now, this means, that there will be played 7 ROUNDS.
Round 1 :: 64 (32 matches, 32 dropouts)
Round 2 :: 32 (16 matches, 16 dropouts)
Round 3 :: 16 (8 matches, 8 dropouts)
Round 4 :: 8 (4 matches, 2 dropouts)
Round 5 :: 4 (2 matches, 2 dropouts
Round 6 :: 2 (1 match, 1 winner)
Round 7 :: 1
(cookie?)
Anyhow, this all looks rather simple because we can calculate the yet unknown variable. We know by seeing the nummers 64 to 1, that 7 rounds are played, with the 7th round being the winner. So most fairly, you could say 6 rounds with the result 1 winner. Either way. I rather have it displayed in 6 rounds though, because the 6th round, 1 on1 will spit out the winner anyway.
Now, how am I supposed to calculate it? 8 players requires 3 rounds. (8 - 4 - 2 (- 1)) So how am I supposed to draw from 8, 3 and from 64, 6.
64 / 8 = 8 - 2 = 6... But that doesn't work on the 8 players.
8 / 8 = 0 - 2 = -2...
I am still ignorant to this variable or calculationmethod. Perhaps you guys could take a crack at it.
The total players will increase to 512 players total, 1023 brackets with A LOT of ROUNDS. :)
Help? :)