third place fix
This commit is contained in:
@@ -207,17 +207,31 @@ export function thirdSlotIsSecure(
|
||||
else contested.add(g);
|
||||
}
|
||||
|
||||
// 3. Wenn weniger als 8 lockedIn sind, aber alle contested stabil → früh raus
|
||||
if (lockedIn.size >= 8) {
|
||||
// Mehr als 8 Gruppen garantiert qualifiziert → Annex C kann nicht eindeutig sein
|
||||
// (es gibt mehr als eine Auswahl von 8 aus den lockedIn)
|
||||
// Prüfe: sind ALLE 8er-Teilmengen aus lockedIn identisch bezüglich dieses Slots?
|
||||
// Das ist komplex; im Zweifel konservativ: false
|
||||
// 3. lockedIn >= 8: wenn genau 8 → Zuordnung EINDEUTIG (nur eine Kombination).
|
||||
// Wenn > 8 → mehrdeutig (versch. 8er-Teilmengen möglich) → konservativ false.
|
||||
if (lockedIn.size > 8) {
|
||||
console.log("[3RD-SECURE] false: >8 lockedIn | wg:", winnerGroup, "| lockedIn:", [...lockedIn].join(","));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Genau 8 lockedIn → nur eine mögliche Kombination → Annex C ist determiniert.
|
||||
// Direkt prüfen, da Enumeration entfällt.
|
||||
if (lockedIn.size === 8) {
|
||||
const qGroups = [...lockedIn];
|
||||
const assignment = resolveAnnexC(qGroups);
|
||||
if (!assignment) { console.log("[3RD-SECURE] false: no annex with 8 locked | wg:", winnerGroup); return false; }
|
||||
const assignedGroup = assignment[winnerGroup];
|
||||
if (!assignedGroup) { console.log("[3RD-SECURE] false: no assignedGroup (8 locked) | wg:", winnerGroup); return false; }
|
||||
const stableState = states.get(assignedGroup);
|
||||
if (!stableState) return false;
|
||||
const result = stableState.finished && stableState.third != null && stableState.possibleTeamIds.size === 1;
|
||||
console.log("[3RD-SECURE] final (8 locked):", result, "| wg:", winnerGroup, "| stableGroup:", assignedGroup, "| finished:", stableState.finished, "| hasThird:", !!stableState.third, "| uniqueTeam:", stableState.possibleTeamIds.size);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (lockedIn.size + contested.size < 8) {
|
||||
// Nicht genug Gruppen, um 8 Dritte zu füllen → Annex C nicht auflösbar
|
||||
console.log("[3RD-SECURE] false: <8 possible | wg:", winnerGroup, "| lockedIn:", lockedIn.size, "| contested:", contested.size);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -229,7 +243,7 @@ export function thirdSlotIsSecure(
|
||||
|
||||
// Begrenzung der Kombinationszahl
|
||||
const combos = combinations(contestedArr.length, need);
|
||||
if (combos > 200) return false; // zu viele Kombinationen → nichts stabil
|
||||
if (combos > 200) { console.log("[3RD-SECURE] false: >200 combos | wg:", winnerGroup); return false; }
|
||||
|
||||
let stableGroup: GroupId | null = null;
|
||||
|
||||
@@ -249,20 +263,23 @@ export function thirdSlotIsSecure(
|
||||
if (!assignment) continue;
|
||||
|
||||
const assignedGroup = assignment[winnerGroup];
|
||||
if (!assignedGroup) return false;
|
||||
if (!assignedGroup) { console.log("[3RD-SECURE] false: no assignedGroup | wg:", winnerGroup); return false; }
|
||||
|
||||
if (stableGroup === null) {
|
||||
stableGroup = assignedGroup;
|
||||
} else if (stableGroup !== assignedGroup) {
|
||||
return false; // Slot fällt in verschiedenen Kombinationen auf verschiedene Gruppen
|
||||
console.log("[3RD-SECURE] false: unstable slot | wg:", winnerGroup, "| groups:", stableGroup, "vs", assignedGroup);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Slot ist stabil → prüfe, ob die Quellgruppe selbst bereits feststeht
|
||||
if (stableGroup === null) return false;
|
||||
if (stableGroup === null) { console.log("[3RD-SECURE] false: stableGroup=null | wg:", winnerGroup); return false; }
|
||||
const stableState = states.get(stableGroup);
|
||||
if (!stableState) return false;
|
||||
return stableState.finished && stableState.third != null && stableState.possibleTeamIds.size === 1;
|
||||
const result = stableState.finished && stableState.third != null && stableState.possibleTeamIds.size === 1;
|
||||
console.log("[3RD-SECURE] final:", result, "| wg:", winnerGroup, "| stableGroup:", stableGroup, "| finished:", stableState.finished, "| hasThird:", !!stableState.third, "| uniqueTeam:", stableState.possibleTeamIds.size);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Berechnet C(n, k) — die Anzahl der Kombinationen.
|
||||
|
||||
Reference in New Issue
Block a user