nflverse / nflseedR

Functions to Efficiently Simulate and Evaluate NFL Seasons
https://nflseedr.com
Other
21 stars 3 forks source link

`break_division_ties` for common record not correct #4

Closed mrcaseb closed 3 years ago

mrcaseb commented 3 years ago

When trying to run draft order for the 2011 season this happens

library(dplyr, warn.conflicts = FALSE)

games <- nflseedR::load_sharpe_games() %>% 
  dplyr::filter(season == 2011) %>% 
  dplyr::rename(sim = season) 

games %>% 
  nflseedR::compute_division_ranks() %>%
  nflseedR::compute_conference_seeds(h2h = .$h2h, playoff_seeds = 6) %>% 
  nflseedR::compute_draft_order(games = games, h2h = .$h2h)
#> * 2021-02-08 15:29:17: Calculating team data
#> * 2021-02-08 15:29:17: Calculating head to head
#> * 2021-02-08 15:29:17: Calculating division rank #1
#> * 2021-02-08 15:29:18: Calculating division rank #2
#> * 2021-02-08 15:29:18: Calculating division rank #3
#> * 2021-02-08 15:29:18: Calculating division rank #4
#> * 2021-02-08 15:29:18: Calculating seed #1
#> * 2021-02-08 15:29:18: Calculating seed #2
#> * 2021-02-08 15:29:18: Calculating seed #3
#> * 2021-02-08 15:29:18: Calculating seed #4
#> * 2021-02-08 15:29:18: Calculating seed #5
#> * 2021-02-08 15:29:18: Calculating seed #6
#> * 2021-02-08 15:29:18: Processing Playoffs Week 18
#> * 2021-02-08 15:29:18: Processing Playoffs Week 19
#> * 2021-02-08 15:29:19: Processing Playoffs Week 20
#> * 2021-02-08 15:29:19: Processing Playoffs Week 21
#> Error in nflseedR::compute_draft_order(., games = games, h2h = .$h2h): Something went wrong and the function has entered an infinite loop. Does the number of postseason games match the number of playoff seeds?

Created on 2021-02-08 by the reprex package (v1.0.0)

The draft_order function correctly catches an infinite loop because the games of 2011 don't include a team that the div_ranks functions says is a playoff team, the SD Chargers.

It looks like the chargers win the 3-way tie breaker with "conference record" but in real life the Broncos won the 3-way tie with the "record in common games" so they never looked at "conference record".

library(dplyr, warn.conflicts = FALSE)

games <- nflseedR::load_sharpe_games() %>% 
  dplyr::filter(season == 2011) %>% 
  dplyr::rename(sim = season) 

games %>% 
  nflseedR::compute_division_ranks(.debug = TRUE) %>% 
  purrr::pluck("standings") %>% 
  dplyr::filter(division == "AFC West")
#> * 2021-02-08 15:33:19: Calculating team data
#> * 2021-02-08 15:33:19: Calculating head to head
#> * 2021-02-08 15:33:19: Calculating division rank #1
#> * 2021-02-08 15:33:19: DIV (3): Head-to-head
#> * 2021-02-08 15:33:19: DIV (3): Division Record
#> * 2021-02-08 15:33:20: DIV (3): Common Record
#> * 2021-02-08 15:33:20: DIV (3): Conference Record
#> * 2021-02-08 15:33:20: DIV (2): Head-to-head
#> * 2021-02-08 15:33:20: Calculating division rank #2
#> * 2021-02-08 15:33:20: DIV (2): Head-to-head
#> * 2021-02-08 15:33:20: DIV (2): Division Record
#> * 2021-02-08 15:33:20: DIV (2): Common Record
#> * 2021-02-08 15:33:20: DIV (2): Conference Record
#> * 2021-02-08 15:33:20: DIV (2): Strength of Victory
#> * 2021-02-08 15:33:20: Calculating division rank #3
#> * 2021-02-08 15:33:20: DIV (2): Head-to-head
#> * 2021-02-08 15:33:20: Calculating division rank #4

grafik