Windows Tournament Bracket Generator



Hey everybody! Right now I'm trying to build a tournament bracket generator similar to "challonge." I can't figure out how to make a system though the bracket. I currently have an input system for players to enter their name so it gets saved to an array which i capped to 256 cause I don't think I'd need more space for a tournament.
I did read about lists though and saw that you don't need to set a cap cause they can be added to on the fly so would you recommend i switch to a list instead of using an array?
Back to the bracket though, I have no clue how to build upon it to support any amount of player and to change according to that. I could figure it out for standard numbers like 8,16,32 but those brackets would have to be presets. If there is a odd number like 13 then the bracket changes according to that but I'm not sure how? Challonge has examples if you look up any bracket that isn't something like 8,16,32 etc.
I'll ignore seeding for right now because I think I could figure that out.
So the main goal is for the bracket to create its self based on how many players are entered lol.
Thanks for the help you guys!


I started writing up a long thing, but then as I was going along writing it, some stuff occurred to me.

Okay, how flexible do you want this thing to be? Brackets can be beastly in size and nature.

A simple tournament bracket can have 1v1 pairings where Tier 1 is twice as big as Tier 2 which is twice as big as Tier 3 and so on until the winner is decided.
A tournament can have 1v1 pairings where a wild card rotates throughout each tier, so that Tier 1 is twice as big as Tier 2 but the wild card in Tier 1 is a competitor in Tier 2 and a winner in Tier 1 is the wild card in Tier 2, and so forth.
A tournament could have 1v2 match-ups with no wild cards, or it could have 1v1v1 match-ups with 1 wild card, or it could have 1v1v1 match-ups with 2 wild cards.
A tournament could have 1v3 match-ups, or even 1v7 match-ups (like Starcraft).
Consider that 1v7 match-up. You could have 1 wild card, no problem. But what if you had more than 1 wild card? Would the wild cards all wait until the next tier, or would they participate in a smaller match-up? Or even smaller match-ups (emphasis on the plurality)?
A tournament could be 2v2 or 3v3 or 4v4 with "teams" rotating between tiers (so the players in Team 1 of Tier 1 might have to compete against each other in Tier 2 or later).

But as for the basics, enter all the initial participants into a list and shuffle it. Use a list for the first tier. Copy all the entries in the entries list to the tier 1 list straight across (remember, you already shuffled the entries list). You can then easily draw the tier list. When the user updates the win/loss roster, delete all the losers from the entries list (not the tier list). Then copy the entries list over to the next tier's list.

The reason I say to use lists is because you can then easily use ds_list_write() to save all the lists to a file and ds_list_read() to retrieve said lists later. You only need to save the tiers' lists I would expect, since each tier would essentially have all the applicants anyway.

But again, that's assuming it's just a simple bracket. The more complex brackets may be a little trickier.


Ya, i started reading an realizing that lists sounded way better than an array for this. Im looking to just create a 1v1 double elimination bracket for games like street fighter and super smash(doubles work as teams so its still just 1v1). So i guess ya, it the simple 1v1. The rounds progress and get halved until their is a winner, but when there are numbers that aren't standard like having 13 players then i have no clue how to adjust the bracket to those parameters. I want the bracket to adjust according automatically to any number but i have no idea on how i would do that.


The 13th player would be a wild card. You treat a wild card as a default win. As for when to rotate the wild card, that's up to you. You can swap out the wild card with a specific position, with the highest score, with the lowest score, or randomly.

At the creation of the first tier, decide if you have wild cards or not.

WILDCARD = ds_list_size(ENTRIES) & 1; //use mod n if you have more than 2 entries, which you wouldn't in this particular case

When the winnings are reported, remove the losers. Until the last tier, you will still have a wild card, so just keep running that check. You'd just then swap the wild card with another entry.

var size = ds_list_size(ENTRIES);
var WILDCARD = size & 1;
size &= ~WILDCARD;
var i = 0;
var next;
while i < size
    next = ds_list_find_value(ENTRIES, i++);
    ds_list_add(TIER[current_tier], next );
    var extra = ds_list_find_value(ENTRIES, i);
    ds_list_replace(ENTRIES, i, next);
    ds_list_replace(ENTRIES, i-1, extra);
    ds_list_replace(TIER[current_tier], i-1, extra);
    ds_list_add(TIER[current_tier], next);
In this case, the last entry would be the wild card, who would get rotated into the bottom of the bracket.