thinking out loud, feel free to speculate/comment/ignore

Away from my code(and pretty color coded editor) for a few days, trying to plan out this daunting task of creating a double elimination ‘tournament bracket’ that seems to not exist in terms of online support/guides/open source.

Feel free to ignore this post as I’m really just thinking out loud or make suggestions if you see a way to do something better, easier. :slight_smile:

The only thing I’ve found on this online is: http://www.phpfreaks.com/forums/index.php?topic=277764.0 which is useless and only attests that the process is extremely difficult. which makes the simplicity of what I’m seeing in my mind offputting…

//upper
array = round-array = matches
establish unique match id for every match
print matches per round

//lower
create lower round
ensure establish unique match id for every match with a tie to propper upper match
count # of losers from equiv round of upper bracket
establish any round byes and #of losers from this round
count # of losers from next round of upper bracket
if incoming losers < losers of previous lower round
print next round for lower playout
else print next round for new incoming losers

Sabmin??? Are you talking about a sports gaming tree? Not sure what you are looking for…

But, I have had a NFL pool going for awhile online and it is basically a tournament elimination, but it is a 16 team game elimination based on multiple games… And, you can basically view it as a tree with ALL of the starting teams on the bottom rungs. As they win , the rungs are less and the winners move up. Not sure why that is hard to do? Well, more info might help on what you are trying to do in this project!

Anyway, what are you talking about??? CURIOUS! LOL…

Yes sports gaming tree:
http://www.printyourbrackets.com/double-elimination-tournament-brackets.html

From what Id read, setting up the first bracket is extremely simple, but when facing double elimination the 2nd or losers/lower bracket is extremely difficult… Which I got a glimpse of last night as I was able to get an unexpected 30 minutes at it where the best I could do was:

attempt to pull the number of matches it should look something like: http://www.printyourbrackets.com/32teamdoubleelimination.html
Winners(upper) Bracket: (simple loop cutting elements in half until 1 remains)
Array ( [1] => 16 [2] => 8 [3] => 4 [4] => 2 [5] => 1 )

Losers(lower) Bracket:
Array ( [1] => 8 [2] => 8 [3] => 4 [4] => 2 [5] => 2 [6] => 1 [7] => 1 [8] => 0.5 )

The lower bracket works… but doesn’t… for some reason, that confused the hell out of me, round 4 was mismatched. I’ve yet to look at it today as I just havn’t had the time, hoping I just made a drunk mistake somewhere. :slight_smile:

[php]$i = 1;
$key_count = 1;
foreach ($winners_b as $k => $v) {
$l_count = count($losers_b);// check if first round of losers
if ($l_count == 0) {
$losers_b[$key_count] = ($v / 2);// if first round # matches = incomming losers
} else {
// compare losers from previous losers round with incoming losers from winners bracket
$incomming = ($v); // incomming is always $v as number of matches is number of losers coming down.
$old_k = ($k - 1); // prepare for last array key
$curr = $losers_b[$old_k]; // get last rounds losers
if ($incomming < $curr) { // continue losers to meet incomming
$new_count = ($losers_b[$old_k] / 2); // previous rounds winners
$losers_b[$key_count] = $new_count;//set matches element
$key_count++;//set lower key count to prevent overriding elements
$losers_b[$key_count] = ($new_count / 2);//create next rounds element
} else {
$losers_b[$key_count] = $v;//add in new incomming losers
}
}
$key_count++;//set lower key count to prevent overriding elements
}[/php]

^^^The code to create the lower array, I’ve never commented so much in my life, but I found that trying to code this while heavily drinking gets extremely confusing extremely fast!

Interesting… And, that site to print forms was interesting, too…

Did you solve it?

Not yet, really strapped for time this week, and I have 'til June 4 to have the site ready for use, so I’m not too stressed… yet. :slight_smile: Getting ready to start my next project after the inspiration from this other thread I think its time I finally started building a game… So tired of this trend of games that have gotten so popular that you login once a day or few days hit a button and can’t do anything until this timer runs out… that’t not a game, someone needs to remind people what a fun time killer is. :slight_smile: Wish I could remember the name of an old open source game I played over a decade ago that was responsible for me getting into php, always wanted to design something code something myself maybe with another person or two with a similar concept. I’m looking at something that appeals to the casual player who can login and play for 5 minutes a day but not be restricted to… sometime similar to a time earned-turn based game, where you’ll have multiple alotments of available turns, so you can save them for a big assault on another player, while using unrelated turns for production or exploring or manufacturing… I envision something like eve-online on a browser :slight_smile:

Sounds interesting… I am sure you will fill us in here when you get it started!

absolutely… will probably try to recruit some help trying to break it :slight_smile:

as far as this stupid bracket goes I’m really starting to confuse myself… might even be caused by the excessive comments :slight_smile: The thought of what I’m doing leads me to think I should have way to many array elements… but it actually looks good… except I’m missing 2 elements and not sure why…------scratch that edit now down to only 1 missing :slight_smile:

[php]$i = 1;
$key_count = 1;
foreach ($winners_b as $k => $v) {
$l_count = count($losers_b);// check if first round of losers
if ($l_count == 0) {
$losers_b[$key_count] = ($v / 2);// if first round # matches = incomming losers
} else {
// compare losers from previous losers round with incoming losers from winners bracket
$incomming = ($v); // incomming is always $v as number of matches is number of losers coming down.
if ($key_count == $k) {
$old_k = ($k - 1); // prepare for last array key
} else {
$old_k = ($key_count - 1); // prepare for last array key
}
$curr = $losers_b[$old_k]; // get last rounds losers
//check if incoming = 1 and signify last round
if ($incomming <= 1) { // only 1 player comming down from winners bracket
if (($losers_b[$old_k] / 2) == 1) {// if previous rounds winner is only 1 player
$losers_b[$key_count] = 1;//there must only be 1 match left
$key_count++;
}
} else {
if ($incomming < $curr) { // continue losers to meet incomming
$new_count = ($losers_b[$old_k] / 2); // previous rounds winners
$losers_b[$key_count] = $new_count;//set matches element
$key_count++;//set lower key count to prevent overriding elements
$losers_b[$key_count] = ($new_count);//create next rounds element
} else {
$losers_b[$key_count] = $v;//add in new incomming losers
}
}
}
$key_count++;//set lower key count to prevent overriding elements
}[/php]

gives me:
Upper Bracker:
Array ( [1] => 16 [2] => 8 [3] => 4 [4] => 2 [5] => 1 )

Lower Bracker:
Array ( [1] => 8 [2] => 8 [3] => 4 [4] => 4 [5] => 2 [6] => 2 [7] => 1 )
should be:
Array ( [1] => 8 [2] => 8 [3] => 4 [4] => 4 [5] => 2 [6] => 2 [7] => 1 [8] => 1)

It seems as though the last item of the loop isn’t running…

I feel so stupid, I’m doing this 100% absolutely positively wrong…

[PHP]$i = 1;
$key_count = 1;
foreach ($winners_b as $k => $v) {
if ($v > 1) {
$losers_b[$key_count] = ($v / 2);
$key_count++;
$losers_b[$key_count] = ($v / 2);
$key_count++;
}
}[/PHP]
draws the proper bracket, I just need to make sure when I’m actually drawing them each has a unique id, and when handling movement that each sector is connected properly. There is absolutely nothing about this that will be difficult…

The site that does the print forms just had me overcomplicating things as if you look at the form for only 5 teams/players it hides the “byes” which I don’t need a complicated formula for, I can do that with css.

Sponsor our Newsletter | Privacy Policy | Terms of Service