Tuesday, March 21, 2023

8 teams, 84 games - Part 7

With a gap of over 3 years in this series, I have forgotten what all I intended to include in this series.  So extending the "ta-da" jump to the end of the grid work in the previous part, I am jumping to the end of the process here.  Basically I will just hand-wave on how I get from completed grid from the previous entry to the file that can be used by the game.

Where I last left off I had the grid all worked out in the webpage.  That webpage was when I did a bit of Javascript learning - just enough to get the page to do the main things I wanted.  For "export" of the grid content, all I did was make that "Console" button that will dump the data into the browser developer console.  So I have to hit F12 to bring up the Developer Tools, choose the Console tab, and copy the info dumped there.  I can then paste than into basically a text file from which I can do subsequent work.  That is my "adjusted" grid file.

The webpage showed a variety of stats used to show the details for the characteristics I want to set.  But I have a separate stats processing script that computes those same things and more.  I run that over the adjusted data to make sure everything looks good.

Another script takes the input of that grid and produces the LSDL file for the game.  I have the details that go into the header section of the LSDL file in a configuration file, so that info gets pulled in from there and plugged in the file as it is built.  Comments to describe the schedule can also be pulled in to include them in the file.

There is one detail not yet addressed at all in the prepartion - gametimes.  Rather than tuck in discussion of that here, I will save it for its own post and simply say that some decision is made for each each game.  Most simply that could be using the same default value like 7pm, but through configuration there can be other options made available.

8 teams, 84 games - Part 6

Where last left off we had just moved one pair of series, switching the positions of a couple series involving teams 3 & 4 in halfweeks 22 & 26 to try to improvement their homestands/roadtrips.

That left us with "dh" instances for those teams - they each now have two 4-game series in one week (halfweeks 21 & 22).  We are aiming to not have any actual doubleheaders, so we will want to adjust to move one game for each of those teams in that week.  The simplest thing would be to move the 4-game series now in halfweek 22 (that was originally in halfweek 26).  We could simply switch that with the 3-game series that are also 4@3 in halfweeks 9 & 16.  That would be fine.  But we could introduce more variation in offdays by removing the extra games for teams 3 & 4 from their halfweek 21 series.  We would do that by switching out those 4-game series from there with 3-game series between the same pairs of teams from other places in the schedule grid.

Very often the case is like that - one improvement does what it intended toward achieving some target (like decreasing the number of single-series homestands/roadtrips, but lead to another thing to address (like creating instances of too many games in a week).  There can often be quite a chain - doing change A creates a need or benefit to doing change B, which compels change C, which ...  Sometimes things end up getting worse such that the preferred action becomes erasing all those changes, then doing something different instead of that original change A.

I am just going to skip all the way to the end rather than show individually at lot more of the changes made.  Here is a side-by-side of the grid (with teams 3 & 4 highlighted) before any changes at all, then after all the changes done to get the grid into a good overall condition with all the stats at satisfactory levels.

Here is a gif version that shows going back and forth between before and after.  From that it may be easier to see the changes made to flip-flop series in different places, juggle the 3-game & 4-game series, and tweak the day-move checkboxes.

That stats at the bottom of the grid are all "OK" in the after picture.  Some things are very precise, like getting the counts of home & away games.  The thresholds for others are rather arbitrary, like for single_series.  There hsa to be some decision of "good enough" to decide to quit tinkering.

In the after picture team 4 has the green indicator on its series for halfweek 25.  That indicates the series there is at home and could be bumped to start a day later to have the offday before the series after a road series rather than in the middle of the homestand as it sits now.  I like to do that as a matter of personal preference.  But there is something blocking that change.

Moving that 2@4 series to start a day later (from Mon-Wed to Tue-Thu) would clash for team 2 with its 4-game series in halfweek 26 covering Thu-Sun.  That 4-game series of 2@1 could be switched with one of the 3-game series for 2@1 in halfweek 9 or 13.  But maybe I prefer the way the 4-game series (and thus offdays) are and leaving in that mid-homestand offday.

So it is important to have targets and an endpoint in mind.  After all stats warnings are cleared, maybe I glance around for more improvements, but it is good enough.

Tuesday, December 31, 2019

8 teams, 84 games - Part 5

We saw the grid and statistics for the initial layout in the previous part.  For a first step in making revisions it would be better to see exactly what we want to revise.  Parameters can be defined for each schedule that set the thresholds we want for the statistics, and the grid can show where something is outside the desired bounds.

Saturday, December 28, 2019

8 teams, 84 games - Part 4

The Working Grid

Before I actually get into the working product described below I must mention the significant behind the scenes pieces that I am skipping over here.  Maybe someday I can make all this available, but so far my ambition has already far exceeded my followthrough.  So I know better than to say too much.  Perhaps this can provide momentum in that direction.

I use Perl scripts I have developed to turn the series layout as described in earlier parts into the HTML and Javascript that make up the tool with the data contained in it.  I may call it a webpage, which is true in the sense that I work with it in a web browser, but misleading in the sense that it is still just local and not out on the internet.  Again, I hope someday I can get beyond the current point.  The jump from doing a lot of the work in a spreadsheet to having this tool did happen, so maybe more can too.


Tuesday, December 24, 2019

8 teams, 84 games - Part 3

Filling out the seating chart

That pretty grid from the previous part has all of the series nicely laid out in half-weeks.  We just need to reorder those half-weeks into something that fits with design preferences.  What should those be?

Choices

No consecutive series against the same opponent.  You know, spread things around.

Distribute the matchup somewhat evently - i.e., do not have like both 1 v 5 matchups in the first handful of series sets.  You know, spread things around even more.

About 70% of the series are against division opponents, but the end of the schedule even more weighted toward division games like having only division series the last few weeks.

There are some other things I typically do that I will point out later.

Organization

We have 26 half weeks to slot in the series sets.  To put those together into a coherent whole, layout a simple grid for those half-weeks.  On the left is the early-week series, and on the right is the weekend series.

 1  2
 3  4
 5  6
 7  8
 9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26

Set out the design preferences

Make the last 3 weeks be 6 intradivision series ("D"), which means 2 against each team.  Otherwise spread out the interdivision series ("L"), but keep them in pairs - just another choice.  In the original layout it is either all intradivision games or all interdivision, so we know what is what for all teams.

 1  2    D  D
 3  4    D  D
 5  6    L  L
 7  8    D  D
 9 10    D  L
11 12    L  D
13 14    D  L
15 16    L  D
17 18    D  D
19 20    L  L
21 22    D  D
23 24    D  D
25 26    D  D

Next start deciding which rows go into which slots.  I use team 1 as the identifier.  So I use the opponent for team 1 from a row to identify the row.  Right now, exactly which row does not matter.  We just want to order the opponents for team 1 in a reasonable way.

With so few teams, the same opponent can crop up very quickly, but make sure to not slot in the same opponent consecutively.  Also try to make sure the same pattern is not continuously used (i.e., do not have team 1 play 2 then 3 then 4 in that order every time).  Again with so few teams combinations are limited and there will be some repeating, but try to have variety.

 1  2    D  D    4  3
 3  4    D  D    2  4
 5  6    L  L    7  8
 7  8    D  D    3  4
 9 10    D  L    2  6
11 12    L  D    5  3
13 14    D  L    2  8
15 16    L  D    7  2
17 18    D  D    4  3
19 20    L  L    5  6
21 22    D  D    4  2
23 24    D  D    3  4
25 26    D  D    3  2

Things to note...

Each division opponent appears 3 times early in a week and 3 times on the weekend.  The division opponents are decently spread out to avoid cases like constantly playing a certain team after playing some other team, at least as well as can be done with only 3 division opponents.

The interdivision pairings are familiar from the layout.  5 and 6 are paired together twice, and same for 7 and 8.  The order of playing them is reversed though (i.e., first time plays 6 then 5 and second time plays 5 then 6).  Unlike the division matchups against each opponent being spread between early-week and weekend, both matchups against each interdivision opponent are either early-week or weekend.  The reason for that is so that if the pair of interdivision matchups against an opponent are swapped, it does not change the number of weekend series home vs away.

Looking backward, intending for these things went into putting the division slots in the places they went - one pair early-week then weekend, two pairs weekend then early-week, and the last pair early-week then weekend.

Homestands and roadtrips, at least for team # 1

To further narrow down to which rows go exactly where, again through the eyes of team 1, decide on making each matchup either home or away.  A lot to aim to do in that...

  • We want to target 2- and 3-series homestands and roadtrips.
  • We want to to try to avoid play the same opponent either home or away in extremely short order.  Again this is touch with so few teams.  But a prime example is the pair of matchups against team 3 the last two weeks - make one of those home and the other away.
  • Try to balance out the weekends home/away.  There are 13 weekends, so the goal is half (either 6 or 7) of those being at home.

One possible distribution...
 1  2    D  D    4  3    H  H
 3  4    D  D    2  4    A  A
 5  6    L  L    7  8    H  H
 7  8    D  D    3  4    A  A
 9 10    D  L    2  6    H  A
11 12    L  D    5  3    H  H
13 14    D  L    2  8    A  A
15 16    L  D    7  2    A  H
17 18    D  D    4  3    H  A
19 20    L  L    5  6    A  H
21 22    D  D    4  2    H  A
23 24    D  D    3  4    A  A
25 26    D  D    3  2    H  H

Pretty good...  Split of 6 weekends home and 7 away.  All 2- and 3-series homestands and roadtrips except for that 5th week (halfweeks 9 and 10) having a 1-series homestand and 1-series roadtrip.

Remember though that this is still just for team 1 (and team 5 in reverse since the second division was made a mirror of the first).  The result may not be so pretty for other teams.  And in shuffling things around to try to make them ideal, this layout for team 1 will surely be tweaked as part of the changes to address isues with other teams.  But we are not quite ready to worry about that.

The last step for the ordering is deciding where to slot in the 4-game series against the division opponents, one home and one away for each.  We can only put in one in a week so that there are no more than 7 games in a week.  And we do not want to pile the weeks with them all together because that would lead to too many days in a row without an offday.

Sprinkling those 4 game series around...

 1  2    D  D    4  3    H  H
 3  4    D  D    2  4    A4 A
 5  6    L  L    7  8    H  H
 7  8    D  D    3  4    A  A4
 9 10    D  L    2  6    H  A
11 12    L  D    5  3    H  H4
13 14    D  L    2  8    A  A
15 16    L  D    7  2    A  H
17 18    D  D    4  3    H  A4
19 20    L  L    5  6    A  H
21 22    D  D    4  2    H4 A
23 24    D  D    3  4    A  A
25 26    D  D    3  2    H  H4

Now we can put the order defined by this scheme on the matchups layout.  Set each halfweek number (1-26) on the row that matches what was defined for the team 1.

13  3 1 2 3 3 4 3 6 5 3 8 7
22  3 1 2 3 3 4 3 6 5 3 8 7
 3  4 1 2 4 3 4 4 6 5 4 8 7
 9  3 2 1 3 4 3 3 5 6 3 7 8
16  3 2 1 3 4 3 3 5 6 3 7 8
26  4 2 1 4 4 3 4 5 6 4 7 8
 7  3 1 3 3 4 2 3 7 5 3 6 8
23  3 1 3 3 4 2 3 7 5 3 6 8
18  4 1 3 4 4 2 4 7 5 4 6 8
 2  3 3 1 3 2 4 3 5 7 3 8 6
25  3 3 1 3 2 4 3 5 7 3 8 6
12  4 3 1 4 2 4 4 5 7 4 8 6
 4  3 1 4 3 2 3 3 8 5 3 7 6
24  3 1 4 3 2 3 3 8 5 3 7 6
 8  4 1 4 4 2 3 4 8 5 4 7 6
 1  3 4 1 3 3 2 3 5 8 3 6 7
17  3 4 1 3 3 2 3 5 8 3 6 7
21  4 4 1 4 3 2 4 5 8 4 6 7
19  3 1 5 3 2 6 3 3 7 3 4 8
11  3 5 1 3 6 2 3 7 3 3 8 4
10  3 1 6 3 2 5 3 3 8 3 4 7
20  3 6 1 3 5 2 3 8 3 3 7 4
15  3 1 7 3 2 8 3 3 5 3 4 6
 5  3 7 1 3 8 2 3 5 3 3 6 4
14  3 1 8 3 2 7 3 3 6 3 4 5
 6  3 8 1 3 7 2 3 6 3 3 5 4

Order the rows based on halfweek...

 1  3 4 1 3 3 2 3 5 8 3 6 7
 2  3 3 1 3 2 4 3 5 7 3 8 6
 3  4 1 2 4 3 4 4 6 5 4 8 7
 4  3 1 4 3 2 3 3 8 5 3 7 6
 5  3 7 1 3 8 2 3 5 3 3 6 4
 6  3 8 1 3 7 2 3 6 3 3 5 4
 7  3 1 3 3 4 2 3 7 5 3 6 8
 8  4 1 4 4 2 3 4 8 5 4 7 6
 9  3 2 1 3 4 3 3 5 6 3 7 8
10  3 1 6 3 2 5 3 3 8 3 4 7
11  3 5 1 3 6 2 3 7 3 3 8 4
12  4 3 1 4 2 4 4 5 7 4 8 6
13  3 1 2 3 3 4 3 6 5 3 8 7
14  3 1 8 3 2 7 3 3 6 3 4 5
15  3 1 7 3 2 8 3 3 5 3 4 6
16  3 2 1 3 4 3 3 5 6 3 7 8
17  3 4 1 3 3 2 3 5 8 3 6 7
18  4 1 3 4 4 2 4 7 5 4 6 8
19  3 1 5 3 2 6 3 3 7 3 4 8
20  3 6 1 3 5 2 3 8 3 3 7 4
21  4 4 1 4 3 2 4 5 8 4 6 7
22  3 1 2 3 3 4 3 6 5 3 8 7
23  3 1 3 3 4 2 3 7 5 3 6 8
24  3 1 4 3 2 3 3 8 5 3 7 6
25  3 3 1 3 2 4 3 5 7 3 8 6
26  4 2 1 4 4 3 4 5 6 4 7 8

Next steps...

We have the structure all laid out, so we could turn it into the schedule that OOTP uses.  But first it can still gain refinement, character, and personalization.  That is just fancy talk for saying it can be further edited to make sure teams have reasonable homestands and roadtrips, spread around the offdays, and make sure other design parameters are met.  This layout may be great for team # 1 but others may be quirky like with lots of 1-series homestands and roadtrips (e.g., team # 2 goes H-A-H-A-H the first 5 half-weeks).  And I prefer not having everybody always playing on all the same days.  It would be nice to have a good tool for making edits to various details to try to make the schedule as good as possible collectively.

8 teams, 84 games - Part 2

Lay out the series

I use a spreadsheet for setting out the series.  It provides a nice structure for gridding things and simple math functions can be used to take care of some of the work like duplicating series and adding +1 to team numbers to create subsequent matchups.

I defined a series with a triplet of numbers.  From left to right the numbers in the triplet are:

  1. number of games in series
  2. away team
  3. home team.

The number of games I underline to make it stand out visually when working in the spreadsheet.  Here I will show the info with a fixed-width font rather than copying spreadsheet views.

So this represents a 3-game series of team 1 playing at team 2:
 3 1 2
That is one series, and we need to do all the series.

8 teams, 84 games - Part 1

Define parameters

We are going to build a ILN_BGN_SL1_D1_T4_D2_T4_C_ schedule!  That is the OOTP formatting for defining league structure and means...

One subleague, with 2 divisions, each with 4 teams

Games

84 games
Play each of 3 other teams in division 20 times (10H/10A)
Play each of 4 teams in other division 6 times (3H/3A)

That seems a likely choice for distribution of games for such a league configuration, but mostly it turns out nicely for illustrative purposes.