111 lines
5.0 KiB
Markdown
111 lines
5.0 KiB
Markdown
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):
|
|
|
|
```csharp
|
|
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:
|
|
|
|
```csharp
|
|
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](https://www.worldtaekwondo.org/rules-wt/rules.html)
|
|
[2](http://www.worldtaekwondo.org/wp-content/uploads/2019/08/WT-Competition-Rules-Interpretation-Manchester-May-15-2019.pdf)
|
|
[3](https://www.worldtaekwondo.org/att_file/documents/WT-Standing-Procedures-for-Taekwondo-Competition-at-Olympic-Games%20(May%2012,%202024).pdf)
|
|
[4](https://nyopentkd.org/rules-regulations/)
|
|
[5](https://worldtkd.simplycompete.com/files/eventDocuments/7802f6c7-cde2-4ce8-8962-da1183e2c31c.pdf)
|
|
[6](https://www.isfsports.org/sites/default/files/documents/2024-07/TAEKWONDO%20-%20ISF%20Technical%20Rules%20and%20Regulations%202024.pdf)
|
|
[7](http://www.worldtaekwondo.org/notice/ec_view.html?nid=102452)
|
|
[8](https://europetaekwondo.org/wp-content/uploads/2023/04/11.-WT-Para-Taekwondo-Competition-Rules-as-of-May-14-2019.pdf)
|
|
[9](https://image.aausports.org/dnn/tw/2025/2025AAUTKDHandbook-9.1.24.pdf)
|
|
[10](https://www.worldtaekwondo.org/viewer_pdf/external/pdfjs-2.1.266-dist/web/viewer.html?file=https%3A%2F%2Fwww.worldtaekwondo.org%2Fatt_file%2Fdocuments%2FWT+Competition+Rules+and+Interpretation+%28September+30%2C+2024%29.pdf) |