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.


What it is


This tool features another layout of the grid of series, but with additional components taking advantage of HTML and Javascript to allow to manipulate the schedule in certain ways to do some adjustments.  Rather than just opening the door to reveal the whole thing, we can start zoomed way in and work our way outward...

The series triplet





Again the building block is the triplet of a series - the number of games, the away team, and the home team.  The number of games is smaller white box toward the left, and the away and home team numbers are in the pair of grey boxes.  There are also the small grey box at the left and the peach "m" button on the right.  We will get to these other pieces below.  First we can expand the view a bit.

One halfweek







This is all four series in one halfweek, the first halfweek in the ordered grid made previous.  On the far left are a pink box with the number "1".  That is simply a label for the halfweek - this is halfweek 1, thus "1".  The aqua box next to it is the same sort of thing, just for the day number of the schedule, which starts with 1, thus "1" there also.  These are not really important for anything here, but they serve like mile markers along the road to show where things are.  The day number 1 gets translated by the OOTP game based on the start day, month, and day of the week settings further defined in the schedule file when it is done.  One important thing though about that day number 1 is that it will be a Monday because we want our season to start on a Monday.  The days of the week do matter.

Two halfweeks








Adding in another halfweek starts to illustrate some things in action.  We see the pink box has "2" for the second halfweek, and the aqua box has "4" indicating this halfweek starts on day number 4.  They are a darker shade, and there is shading in the background of the rest of the row, and those things are done to highlight this as a "weekend" half week.  Our season is going to start on a Monday, which is day number 1.  The second halfweek begins on Thursday, the day number 4.

But wait a minute... 3-game series starting on Thursday would end on Saturday and presumably leave Sunday open.  We expect MLB weekend 3-game series to run Friday through Sunday.  That is where the little box on the left of each individual series comes in.  This second row shows that little box with the series triplet is a checkbox, and it is selected in each series in the second halfweek.  The checkbox being checked indicates that the associated series begins one day later than would otherwise be indicated by the aqua day number.  The Perl script I use to generate the webpage tool has a setting that will automatically turn on those checkboxes for 3-game weekend series as shown here.

So as it is at this point, the first half week shows everyone playing 3-game series Mon-Wed on day numbers 1-3 and 3-game series Fri-Sun on day numbers 5-7.

Hmm, no games on Thursday...  You know, maybe we could do something like turn on the checkbox for the 4@1 series in the first halfweek to move that to span Tue-Thu so there is at least a game on Thursday...  We absolutely could, but let us zoom out further before we start changing anything.

All the halfweeks




































Now we see the whole sorted grid.  Sure enough, all the weekend series have their checkboxes turned on, but only when they are 3-game series.  Halfweek number 8, which is a weekend, has all 4-game series, and those checkboxes are not on.  A 4-game series starting on Thursday runs through Sunday, which fits our baseball week plan.  So the checkbox is one action, for sliding a schedule one day later.

What about those "m" buttons?  You might have guessed that the "m" is to indicate "move".  But moving a series is a powerful action that can do much more damage than improvement to a schedule.  It should be used carefully.  Let us zoom out the rest of the way.

The whole grid, including statistics




Okay, quite a bit going on here...  First the additional stuff starting each row.  The first column in green shows the number of games total across the row for that halfweek, and the second column in green shows the number of active checkboxes in that row.  Those we will ignore for now and come back when we are ready for some extra-fine-tuning.  The blank columns we will also ignore until the next part in this series of posts.

The table at bottom is statistical stuff determined from how the schedule would layout from the grid above.  We use this information to see the effects of the changes we will make in the layout.

The statistics

About the table at the bottom that has details about the schedule...

Header row

The team numbers 1 through 8 identify whose stats are in each column.  Those team number boxes are actually buttons, which will be shown in action in the next part.

games away

This is the total number of road games each team plays.  I have not yet gotten into how that might be made to become incorrect.  But having that value shown is a good sanity check.  The original layout could have had something wrong that needs fixing, and the basic road games count could help show that.

games home

Same as for "games away", but for home games.

playing streak

This is the maximum number of days in a row that the team plays.  We do not want to have teams go too long without an offday, and this can show us if we have made changes that cause that.  To start we have everyone at 13 because all teams all play on the same days.  But we will make changes that could lead to exceeding the limit of 20 we want to stay within.

away streak

This is the length in games of the longest roadtrip (continous stretch of games away from home).  The instances of 19 indicate teams playing basically 3 straight weeks, which is longer than we want.  MLB is great about keeping to mostly 2- and 3-series roadtrips (mostly 6-10 games), but I generally allow for up to 14 because it is a constraint generally feasible with reasonable effort.  There is no All-Star Break in this schedule, but I typically allow that to break a streak.

home streak

Again, same as away but for home games.  Same guidelines apply, generally not wanting to exceed 14.  That we have numbers bigger than that shows we will want to make changes.

single series

Similar to the streaks, but in the other direction.  MLB schedules are very good about mostly having 2- and 3-series homestands and roadtrips.  This row counts the total number of 1-series homestands and roadtrips.  Usually I want to make a point to minimize this number to mean there are as few cases of bouncing either home or away for only one series before bouncing back.  In this case we see the count of 2 for team # 1 (and its mirror image in the other division, team # 5) because in the layout done in the previous part a point was made to have almost all 2- and 3-series homestands and roadtrips, which is further illustrated by the small streak values.  But the other teams in the division have considerably more such single-series homestands and roadtrips.

dh

This is a count of doubleheaders, or better stated, the count of instances where a team has been set to play more than one game on a day.  I do some schedules with doubleheaders, but more often zero are intended so something non-zero in the row indicates something needing to be fixed.  E.g., having a team in a 4-game series in the first half of the week and also in the latter half of the week will cause that team to show as having a case of a "dh".

HoH

This is a count of the instances where in three days the team had a home game ("H"), then an offday ("o"), then a home game ("H").  An example of this is in the first week for team number 1 - they play home series Mon-Wed in the first halfweek then a home series Fri-Sun in the second halfweek.  This only matters as an arbitrary choice I have made toward how I like to configure.

My idea is to try to minimize the number of offdays within homestands because that allows for offdays to be utilized as travel days.  It does not matter in the game, but I like the idea.  Doing that is not necessarily more realistic - MLB does not try to minimize intra-homestand offdays.  But it is one way to spread offdays around differently among teams so not everyone plays at the same time.

wknd_srs_h

This is a count of the total number of weekend series each team plays at home.  With 13 weeks, we wanted to get 6-7 because that is an even split.  That matters to some degree in OOTP beyond simply looking more realistic because I believe the game still gives a bump to attendance for weekend games.  To start we have notable discrepancies among the teams with a range from 4 to 9 of the 13 weekends being at home for different teams.  We will want to try to tighten that range so that some teams do not arbitrarily benefit or suffer attendance-wise.  This is the newest significant factor I have incorporated, and it is not always rigorously enforced.


Next steps...

If you are hanging around to see more of my process though I do not have a way at this point to let you utilize it, you will see changes being made along the path from the initial ordered layout to the final grid that gets translated into the end result schedule.

No comments:

Post a Comment