-
Notifications
You must be signed in to change notification settings - Fork 146
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
Better schedule generation for non-standard leagues #120
Comments
@kgilbert-cmu I was thinking, this sounds like something that might interest you. If so, let me know. If not, I'll do it myself some time. |
Side-bar: I can't believe you actually used the name "crappy" in the function name. Though I suppose it does help differentiate it. Anyway, I'm wondering if this can be cleaned up if we allow the compromise that in League Settings, the user can specify how many games they want, but if it's an odd number or one that wouldn't be balanced, we "round" up or down to the nearest whole factor. It looks like this function grabs the g.numGames and just runs with it, rather than reconsidering the number with respect to how many teams it has to work with. Option 2: what about enumerating all of the possible games into the |
You still have much to learn...
There probably is some math that proves scenarios where it's possible to have balanced schedules, in which case we could use that, but I think it actually doesn't really matter. Maybe we could show it as a warning, but if users want to do weird shit, they should be able to. Most of the time, if it's only slightly unbalanced, that's fine. The problem is, now it can be way unbalanced because it's totally random.
Yeah, that's basically what I was thinking this morning. Something like:
Also, this is probably all just a solved problem, but I haven't researched it.
I would probably just ignore that and keep the special function for NBA-like leagues... but if you wanted to not ignore it... the holy grail would be an algorithm that, when given (82 games, 2 conferences, 6 divisions, 30 teams) would produce exactly the NBA scheduling constraints, and when the conditions deviate from that it would still produce something reasonable and NBA-like. That might not be a solved problem. |
Hey guys, Saw this project on r/nba today - awesome stuff! I think I may be able to contribute and help with your scheduling problem. Sorry in advance if this is super long - it's quite a complicated problem, I tried my best to keep my answer as simple as possible. The solution I'm visualizing uses a sort of "building blocks" method of constructing a schedule. Imagine you have and unlimited amount of building blocks that come in three different sizes - division blocks, conference blocks, and league blocks. Each "block" involves every team in each group playing every other team in their group exactly once. Thus, the "division" block in a normal NBA league structure contains 4 games for every team, each "conference" block has 14, and each "league" block 29. If we have non-neat number of games in a season, we can cut the final block into a smaller piece to make it fit. To get really close to a real NBA schedule with 30 teams/2 conf/6 div/82 games, we use the following set of blocks: This ensures each team plays each team in their conference (but not in division) 3-4 times, each team in their division 4-5 times (not exact to NBA, but close), and each non-conference team 2 times. More generically, we can generalize the order we add blocks to be:
This formula allows us to deviate from the NBA structure while keeping "NBA like" scheduling. Basic example: If we get crazy with the structure, we see the schedule is good but definitely gets weird: I have ideas on how to handle home/away games and schedule randomization, but I've already written a novel here so I'll save it for later. If you guys didn't die from confusion while reading and like the idea, I can take a stab at coding it (I'm a professional Python dev, so writing algos in JS might take me a hot minute) Cheers |
You are welcome to try. It would be really cool to have an algorithm that produces an NBA schedule when given an NBA-like league but generalizes well to other scenarios. But if the end result is something ridiculously complicated, I might not be inclined to merge - I'm not trying to be negative, just want to be up front about it.
I feel you, look far enough back in the commit history and you'll find this used to be a Python project, and it was my first serious work in JS :) It'd also be fine if you do the algo in Python and want to leave the JS porting to me. Just assign each team an ID number from |
Currently an NBA-like schedule is generated if you have a league with 82 games, 30 teams, 2 conferences, and 3 divisions. Otherwise,
season.newScheduleCrappy()
is used. And as you can see, it's basically just totally random, which kind of sucks because it will result in unbalanced schedules.It would be nice to do better. Even ignoring conferences and divisions, having all teams play each other an equal number of times (or as close to that as possible) would be a big improvement.
The text was updated successfully, but these errors were encountered: