Repository navigation
Allocate best-placed teams to avoid same-group knockout rematches - #53
Merged
Merged
Conversation
Phase 4 of World Cup style advancement. Best-placed (third-placed) slots were resolved purely by rank, which could — and on the 2026 bracket did — draw a third-placed team against a winner from its own group. FIFA/UEFA solve this with a per-combination allocation table; this finds an equivalent rematch-free assignment directly. - BestPlacedAllocator: backtracking bipartite match assigning the top-N thirds to the N best-placed slots so none faces its own group, tried in rank order over bracket order for a deterministic result. Flags an unavoidable rematch rather than failing. - SeedStageFromGroups resolves best-placed slots as a pool through the allocator (opponent group taken from each slot's round-1 partner); group slots unchanged. Slot payload gains origin_group + rematch. - Seeding review card shows each pooled third's origin group and warns on any unavoidable rematch. Deferred (documented follow-up): manual per-slot swap on the review screen, and draw-mode pairing for UCL-style competitions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase ④ (final phase) of World Cup–style advancement. Best-placed (third-placed) knockout slots were resolved purely by rank, which could draw a third against a winner from its own group — a rematch. On the real 2026 dev bracket it produced exactly that. FIFA/UEFA avoid it with a published allocation table per group combination; this finds an equivalent rematch-free assignment directly instead of hardcoding those tables.
BestPlacedAllocator— a backtracking bipartite match assigning the top-N qualifying thirds to the N best-placed slots so none faces its own group. Teams tried in ranking order over bracket order → deterministic, keeps stronger thirds earlier. Any combination that admits a rematch-free layout resolves (covers the classic 6-group/4-third table, the 2026 12-group/8-third shape, and everything between). An unavoidable rematch is flagged, not fatal.SeedStageFromGroupsnow resolves best-placed slots as a pool through the allocator (each slot's opponent group taken from its round-1 partner descriptor); group slots resolve exactly as before. Slot payload gainsorigin_groupandrematch.Verified read-only on the real World Cup R32: 0 rematches, all 8 thirds allocated away from their own groups (the allocator reshuffled the seeded-template thirds to achieve it). The updated Phase ③ scaffold previously produced an Alpha One v Alpha Two same-group rematch — now Alpha One v Beta Two.
Completes the plan. Deferred as a documented follow-up: manual per-slot swap on the review screen, and UCL-style
drawpairing mode (qualifiers known, pairings drawn by hand).Testing
BestPlacedAllocatorunit tests: no-own-group guarantee, rank-order preference when unconstrained, full 4-team combination, null-opponent handling, unavoidable-rematch flag, determinism🤖 Generated with Claude Code