
NHL Stanley Cup Playoffs: Best-of-7 Bracket
Source:vignettes/nhl-stanley-cup.Rmd
nhl-stanley-cup.RmdThis vignette models the NHL Stanley Cup Playoffs as a 16-team single-elimination bracket where every series is best-of-7.
It demonstrates:
-
single_elim("playoffs", best_of = 7, seed = TRUE)for a seeded bracket with series play, -
result(trn, stage, match, score = c(x, y))for series score entry, - inspecting bracket state with
matches()andstandings(), -
winner()for the final champion.
Note on the conference format. The real Stanley Cup format runs the Eastern and Western conference brackets in parallel and merges their winners into the Final. Merging from multiple upstream stages into one downstream stage is a planned feature not yet available in this version. This vignette models a simplified bracket where all 16 teams compete in one seeded tree.
1) Playoff field
teams <- c(
# East seeds 1–8
"NY Rangers", "Panthers", "Bruins", "Maple Leafs",
"Hurricanes", "Lightning", "Islanders", "Capitals",
# West seeds 9–16 (seeded across both conferences in bracket order)
"Stars", "Avalanche", "Canucks", "Oilers",
"Jets", "Golden Knights", "Kings", "Predators"
)
length(teams)2) Define the tournament
trn <- tournament(teams) |>
single_elim("playoffs", best_of = 7, seed = TRUE)best_of = 7 means each match is a series: the first team
to 4 wins advances. seed = TRUE applies standard bracket
seeding (1 vs 16, 2 vs 15, etc.).
3) Inspect the first-round schedule
stage_status(trn)
r1 <- matches(trn, "playoffs", status = "pending")
nrow(r1) # 8 first-round series
r1[, c("id", "participant1", "participant2")]4) Enter first-round series results
Each result is the final series score (wins–wins).
trn <- trn |> result("playoffs", match = 1, score = c(4, 2)) # Rangers over Capitals
trn <- trn |> result("playoffs", match = 2, score = c(4, 1)) # Panthers over Islanders
trn <- trn |> result("playoffs", match = 3, score = c(3, 4)) # Lightning over Bruins
trn <- trn |> result("playoffs", match = 4, score = c(2, 4)) # Hurricanes over Leafs
trn <- trn |> result("playoffs", match = 5, score = c(4, 1)) # Stars over Predators
trn <- trn |> result("playoffs", match = 6, score = c(4, 3)) # Avalanche over Kings
trn <- trn |> result("playoffs", match = 7, score = c(2, 4)) # Oilers over Canucks
trn <- trn |> result("playoffs", match = 8, score = c(4, 2)) # Jets over Golden Knights5) Second round
As results advance teams through the bracket, new matches become available.
r2 <- matches(trn, "playoffs")
r2[, c("id", "participant1", "participant2")]
trn <- trn |> result("playoffs", match = 9, score = c(4, 2)) # Rangers over Hurricanes
trn <- trn |> result("playoffs", match = 10, score = c(4, 3)) # Panthers over Lightning
trn <- trn |> result("playoffs", match = 11, score = c(4, 3)) # Stars over Jets
trn <- trn |> result("playoffs", match = 12, score = c(3, 4)) # Oilers over Avalanche6) Conference finals and the Cup
trn <- trn |> result("playoffs", match = 13, score = c(3, 4)) # Panthers win East
trn <- trn |> result("playoffs", match = 14, score = c(2, 4)) # Oilers win West8) Batch result entry
For simulation or bulk data entry, results() accepts a
data frame.
series_results <- data.frame(
match = c(1, 2, 3, 4, 5, 6, 7, 8),
score1 = c(4, 4, 3, 2, 4, 4, 2, 4),
score2 = c(2, 1, 4, 4, 1, 3, 4, 2)
)
# Reset and replay round 1 from a fresh build:
trn2 <- tournament(teams) |>
single_elim("playoffs", best_of = 7, seed = TRUE)
trn2 <- trn2 |> results("playoffs", series_results)