5.0 KiB

To build competition brackets based on the grouped participants from your filtering function and perform the draw according to World Taekwondo (WT) competition rules, here is a practical approach in .NET:

Core WT Bracket Rules to Consider

  • Single-elimination tournament structure with repechage for bronze medal (mostly WT elite events).
  • Seed top athletes by WT/world ranking; remaining are drawn randomly.
  • No reseeding after draw; no redraws on disqualification.
  • Bracket must handle power-of-two numbers by providing byes to top seeds if participants are fewer.

Step-by-step implementation outline

  1. Accept grouped participants by category/gender/weight class (output of GroupPlayersForPredraw).
  2. For each group, generate a bracket with single-elimination structure:
    • Determine nearest power-of-two number >= group count.
    • Assign byes to top seeds or randomly if no seeding.
    • Randomize unseeded fighters for fairness.
  3. Provide pairing list for each round.
  4. Optionally incorporate repechage logic (advanced).

Example .NET code snippet for bracket creation and draw (single elimination):

using System;
using System.Collections.Generic;
using System.Linq;

public class Matchup
{
    public PlayerDto Fighter1 { get; set; }
    public PlayerDto Fighter2 { get; set; } // null means bye for Fighter1
    public int Round { get; set; }
}

public static class BracketBuilder
{
    // Create bracket matchups for a single group (gender/age/weight)
    public static List<Matchup> CreateBracket(List<PlayerDto> fighters)
    {
        int n = fighters.Count;
        int bracketSize = 1;
        while (bracketSize < n) bracketSize <<= 1; // next power of two

        // Byes assigned for slots beyond the number of fighters
        int byes = bracketSize - n;

        // Shuffle fighters for random draw (or apply seeding logic here)
        var rnd = new Random();
        var shuffled = fighters.OrderBy(x => rnd.Next()).ToList();

        // Create first-round matchups, pairing fighters; byes as null opponent
        var matchups = new List<Matchup>();
        int fighterIndex = 0;

        for (int i = 0; i < bracketSize / 2; i++)
        {
            PlayerDto f1 = fighterIndex < n ? shuffled[fighterIndex++] : null;
            PlayerDto f2 = fighterIndex < n ? shuffled[fighterIndex++] : null;

            if (f1 != null && f2 == null)
            {
                // Handle bye: f1 automatically advances (no opponent)
                matchups.Add(new Matchup { Fighter1 = f1, Fighter2 = null, Round = 1 });
            }
            else
            {
                matchups.Add(new Matchup { Fighter1 = f1, Fighter2 = f2, Round = 1 });
            }
        }
        return matchups;
    }
}

How to integrate with your grouping output:

var groups = TaekwondoPredrawHelper.GroupPlayersForPredraw(participants);

foreach(var group in groups)
{
    Console.WriteLine($"Bracket for Gender: {group.Gender}, Age: {group.AgeCategory}, Weight: {group.WeightClass}");
    var bracket = BracketBuilder.CreateBracket(group.Players);

    foreach(var match in bracket)
    {
        string f1 = match.Fighter1?.Name ?? "TBD";
        string f2 = match.Fighter2?.Name ?? "BYE";
        Console.WriteLine($"Round {match.Round}: {f1} vs {f2}");
    }
    Console.WriteLine();
}

Explanation

  • This creates a fair draw bracket per WT rules albeit simplified (random draw if no ranking).
  • Byes are properly handled for non-power-of-two group sizes.
  • Further complexity like official seeding based on WT rankings, repechage rounds, or draw ceremonies can be added as needed.

This method provides a solid, rule-aligned foundation for building competition brackets and performing the draw for World Taekwondo events, suitable for most tournament management software and workflows.[1][2][3][7]

If you want, I can help extend this to incorporate WT seeding, repechage system, or export bracket data for UI display.

1 2 3 4 5 6 7 8 9 10