Monday, March 11, 2013

Gridiron Solitaire #46: Simulation

I spent part of last week play-balancing the offseason, which went reasonably well. There are still a few tweaks needed, but the consensus was that the offseason is fun now, and challenging. And I have the league totals for ratings balanced for a 30-year dynasty without having to artificially trim or inflate ratings if they creep beyond a certain level, because the individual team budgets balance everything.

For the individual player, the budget is a control, plus the chances of a card busting increase with the number of wins the player had the previous season.

There's still a little work to do, to get it just right, but it's 90% of the way there in terms of balance, and I'm very happy with that for now.

I'm taking a look at various subsystems in the game, trying to improve them, and I worked on the game simulation engine last week. It was pretty primitive (and this was in its second iteration). Basically, I compared total team ratings, added home field advantage, used that to weight the odds, and then generated a random number to find out which team won.

To generate score, I had a table of all winning/losing NFL scores for several years, with about 1280 entries in each table. Putting every score into the table created a natural distribution of the scores. I generated a random number from 1 to 1280, looked up that position in the respective table and took the value as the score (for the losing score, if it exceeded the winning score, I genned another random number until it was smaller).

Like I said, that was pretty crude, but it did wind up with actual scores. The problem with generating scores at random (without the table) is that you can wind up with all kinds of scores that are almost never seen in a real football game.

The scores were so random, though--because there was no ratings influence--that it bothered me. And I felt like the sim results in terms of wins/losses needed to reflect the differences in team ratings more closely.

So I started studying how pointspreads reflect win chance, based on historical data. The win chance increases with a larger pointspread, but not in a linear manner.

That helped me understand what I needed to do. So now I calculate the difference between home/away ratings, add a home field advantage, and create a pointspread. Then, when I generate the random number to determine which team wins, I use the pointspread probabilities.

This is far more accurate, because in games with large ratings discrepancies, the chances of the better team winning are reflected in the pointspread. Before, it was a linear increase, but now, it accurately reflects historical data.

[And if this is all gibberish, it's me, not you. Eli 11.7 had the flu all last week, and he was down for the count in a way I haven't seen him for years. So it was a worrisome and exhausting week, and I'm still running on vapors, because now it's spring break. I'm ground down to a fine powder at this point.]

Okay, let's move on to score selection. I was particularly unhappy with how that was being done, because it didn't reflect ratings at all. Now, when a position in the table is generated via random number, that's only the initial position.

Let's do an example. Let's say the random number is 800. That position in the score table might correspond to 31 points. The position in the table is then adjusted based on the net offensive totals (total offense of team X - total defense of team Y). I find out how many positions in the table are above (if net offense is positive) or below (if net offense is negative), then calculate the adjustment.

So let's say at position 800, there are 480 positions available above it when the net offense is positive. So I take a percentage of the 480 positions (theoretically up to 40%, although the range is much more likely to be 1-15%) add add it to the original position, then retrieve the score.

That may not sound like much, but I just want to have an influence. So if the score originally generated is 24, a highly positive net offense number might move that upward to 28, or maybe even a little higher. Over the course of the season, that might be a +5 influence in net score for a team with a strong offense.

I go through the same basic procedure for the losing team, although the initial score that gets generated is below the score of the winning team.

Obviously, this is still limited. Trying to generate scores entirely based on ratings, though, creates its own problems, particularly using a 1-10 ratings scale. It would be very difficult to avoid a ton of very similar scores, and I don't want that.

I'll probably take one more pass at this, at some point, and I think I know what I'll be doing. What I need to do is generate a table that includes the winning margin of those 1280 games. Then I can generate a random number, modify it based on the net ratings difference, and use that number as the position to look up in the table.

Oh, hell, who am I kidding. I'll probably do that tomorrow. Then I can move on to something else.

Site Meter