Skip to content

Allocate best-placed teams to avoid same-group knockout rematches - #53

Merged
ylynfatt merged 1 commit into
mainfrom
best-placed-allocation
Jul 20, 2026
Merged

ylynfatt merged 1 commit into
mainfrom
best-placed-allocation

Conversation

@ylynfatt

Copy link
Copy Markdown
Owner

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.
  • SeedStageFromGroups now 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 gains origin_group and rematch.
  • Seeding review card shows each pooled third's true origin group (e.g. Ecuador · Group E) and an amber warning if any rematch is unavoidable.

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 draw pairing mode (qualifiers known, pairings drawn by hand).

Testing

  • 6 new BestPlacedAllocator unit tests: no-own-group guarantee, rank-order preference when unconstrained, full 4-team combination, null-opponent handling, unavoidable-rematch flag, determinism
  • Updated 3 Phase ③ seeding tests to the improved rematch-free output (with comments explaining the change)
  • Full suite: 444 passed

🤖 Generated with Claude Code

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>
@ylynfatt
ylynfatt merged commit f5e2506 into main Jul 20, 2026
1 check passed
@ylynfatt
ylynfatt deleted the best-placed-allocation branch July 20, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant