-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NFL Schedule Fix (Draft) #415
base: master
Are you sure you want to change the base?
NFL Schedule Fix (Draft) #415
Conversation
NFL Schedule POCThis commit finished the prototype for generating an schedule containing 18 weeks for 32 teams to play 17 games each with 1 bye in a manner which mimics the NFL's method.
|
Typescript Port...This commit translates the rough POC python scripts into Typescript and places them in the season directory with some rudimentary tests for both the sorting function, as well as the matchup generation function.
|
Revert..., implement bit walkerThis commit reverts the n-sized array generic method commit and adds a decent solution for providing the binary matches. N-sized arraySo I had a sort of shower thought and figured that I could just use a really easy solution for generating the conference offsets (the n-sized array problem). Turns out, I was wrong. The pattern we're using to generate those is a special type of 'Latin square' which allows contains a special symmetry that makes it easy to allocate our divisional matches per year. The drawback of using this square is that we need different an entirely different formula for any number of divisions that doesn't satisfy 2^n divisions. So that leaves that pattern as really only relevant in conferences with 2, 4 or 8 divisions each. On the other hand, it's not like an odd number of divisions can resolve into an even number of divisional matches, so this is probably not the end of the world, and would have to be addressed anyway to create schedules as a league expands or if it has a custom structure. Bit walkerStack Overflow spit out a pretty good answer for how to generate the patterns we need for generating even home/away splits, so this method was incorporated, and allows for any number of home/away game patterns to be generated. I'm thinking there should be an upper limit on the size of bit arrays generated. If we need to allocate something like 13 games between 2 teams, generate the combinations of 8 games, then the combinations of 5 games and join those two arrays. |
Latin square function...This commit adds a function to build a Latin square as described above, for values that are powers of 2. Details of the implementation are provided in the comments. Added more type annotations and made those that existed more consistent. |
Speculative schedule partially implementedThis commit attempts to implement the speculative NFL schedule maker and the schedule sort algorithm. While we can start a league and have the first season's schedule generated no problem, the generation of a schedule that's actually balanced around the previous years ranks is not yet functional. ChangesTo utilize the algorithms, I tried to be as unobtrusive as possible, though there is some minor modifications to Next Steps
|
Draft
This PR deals with issue #333, and has the potential to improve scheduling across a number of league structures.
The initial commit contains two Python files, one which lightly explores the bye week issue, and another which generates 17 match-ups per team for a 32 team league using the NFL's Formula. These were written in Python just to ease the amount of overhead, and I can adapt them to typescript once all the kinks have been worked out (and I get a little more familiar with the code base.)
Schedule.py
This part of the code received the majority of my attention so far, but I think it was worth it as the
schedule.py
script generates varied schedules based on the NFL's Formula with the home/away logic cycling every 6 years. There's copious comments on the functionality, but it boils down to using the binary nature of home and away games to set the schedule before assigning matches.This function would require that we receive the year the schedule is for, as well as a list of teamIDs in a specific order, as laid out in this table:
At the moment, I'd say the math is a little dogeared, as I wanted to create the NFL schedule, and then work back to adapt this schedule schema to leagues of varying size. At the moment, we're hard coding some values that should be derived, and to be honest, some of the math could be simplified by preparing the
teams
list into a more complex structure. There's also some very Python specific hacks that hopefully I won't have to resort to in the final typescript version.This can eventually be adapted into a singular script for NFL matches, or possibly into some sort of modular scheduling system, though at this point I'd really be spitballing, but it does feel like formulas for assigning games based on each of the NFL's rules could be swapped out to create balanced schedules of varying length for leagues with varying amounts of teams.
Basic.py
This file contains some logic for an extremely simple method to collapse bye weeks for unsorted round robin type tournaments. It's not very flexible, rather shaggy, and it only appears to work on 2n teams playing 2n/2 games. But I thought I might as well include it as a starting point.
Extra Commentary
I do want to stress that these attached scripts are a very rough jumping off point. Beyond the need for adapting to typescript, some of my approach can be simplified or made less wasteful (the O2 approach to NFL scheduling could stand to be further refined). Also, there's some blindingly, embarrassingly obvious math I know I'm missing, so please feel free to point out where I can shape that up.
I'm going to turn my attention to the schedule condensing logic, and then once that's finished, port these scripts into typescript and place them in the appropriate areas.