cross mix knockout seeds
This commit is contained in:
@@ -34,7 +34,10 @@ export function calculateGroupConfigurations(teamCount: number): GroupConfigOpti
|
||||
if (remainder > numGroups) continue;
|
||||
|
||||
const groupsWithExtra = remainder;
|
||||
const matchesGuaranteed = teamsPerGroup - 1;
|
||||
|
||||
const groupsAtBaseSize = numGroups - groupsWithExtra;
|
||||
const minGroupSize = groupsAtBaseSize > 0 ? teamsPerGroup : teamsPerGroup + 1;
|
||||
const matchesGuaranteed = minGroupSize - 1;
|
||||
|
||||
for (let advancePerGroup = 1; advancePerGroup <= Math.min(3, teamsPerGroup - 1); advancePerGroup++) {
|
||||
const teamsAdvancing = numGroups * advancePerGroup;
|
||||
@@ -77,7 +80,24 @@ export function calculateGroupConfigurations(teamCount: number): GroupConfigOpti
|
||||
}
|
||||
}
|
||||
|
||||
return configs.sort((a, b) => {
|
||||
const uniqueConfigs = new Map<string, GroupConfigOption>();
|
||||
|
||||
for (const config of configs) {
|
||||
const groupSizes: number[] = [];
|
||||
for (let i = 0; i < config.num_groups; i++) {
|
||||
const size = config.teams_per_group + (i < config.groups_with_extra ? 1 : 0);
|
||||
groupSizes.push(size);
|
||||
}
|
||||
groupSizes.sort((a, b) => b - a);
|
||||
|
||||
const key = `${groupSizes.join(',')}_advance${config.advance_per_group}`;
|
||||
|
||||
if (!uniqueConfigs.has(key)) {
|
||||
uniqueConfigs.set(key, config);
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(uniqueConfigs.values()).sort((a, b) => {
|
||||
if (a.matches_guaranteed !== b.matches_guaranteed) {
|
||||
return b.matches_guaranteed - a.matches_guaranteed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user