New to MyFootballNow?  Click here for a tour!

Tuesday, May 6, 2014

Passing the Bar: How field goal logic works

In MyFootballNow, each game is simulated using a complex 2-D game engine. Each player in the game is what is called an "autonomous user agent" - which basically means that they make completely independent decisions based only on what they know about their place in the game, without any sort of overview that we as the viewer might have.  There are several games that use this type of logic - Madden NFL is the most obvious one - and it is contrasted with games that might use probability calculations to derive an approximate result based on the attributes of players on the field.

While the players are simulated in 2-D, any time the ball is in flight it is simulated in all three dimensions. The height of the players it passes determines whether or not they are able to touch and consequently influence the flight path of the ball. This is illustrated in the game center by the size of the football as it rises and descends in altitude. I wanted to write a short blog entry detailing how something like a field goal is simulated to illustrate how it's not just a "72% chance for success," but instead the chance of success is determined by far more complex math as the actual physics of the ball are simulated in the game engine. A gentle warning, there is math in the following description; but hopefully I'll be able to explain it in such a way that makes sense even to the greatest mathophobic.

When a field goal is attempted, the direction that the ball needs to travel to arrive at the center of the goal posts is calculated. Then, using the kicker's accuracy attribute, a value is arrived at that is the standard deviation for the launch angle.  The lower the accuracy attribute, the larger the standard deviation.  Then the launch angle error is calculated using a normal distribution, and the flight path of the ball is adjusted to go in that direction.

That last sentence may have flown over the head of most casual text sim gamers. What in the world is a standard deviation? There is a principle in statistics that states that if you have enough samples of data for what is known as a "normal population," that most of the data will be close to the "mean," or average value. 68% of all samples will be within one standard deviation of this mean, and 95% will be within two standard deviations, with 99% being within 3 standard deviations.  The graph looks like this:


Note the hump in this graph, where the middle line indicates the mean. As you go further and further away from the mean, the number of times that value exists becomes less and less, indicated by the graph getting lower and lower.  Each vertical line indicates one standard deviation.  The larger the standard deviation, the greater the range of the resulting values.  There are lots of random numbers generated in MyFootballNow, and most use some form of the normal distribution.  By choosing a mean and a standard deviation, we are able to generate random numbers that will be distributed with a range that matches the graph above.

So, we decide the amount of error based on a normal distribution, with the standard deviation being dependent on the kicker's accuracy attribute.  The strength attribute applies in the same manner, except instead of the standard deviation being calculated from the attribute, the mean value is used. A strength value of 100 will be able to kick a 70-yard field goal if the random value is 3 standard deviations away from his mean.  As mentioned above, 99% of all values will be within three standard deviations of the mean, and the remaining 1% will be split between the high and low side; so if a kicker has a 100 strength score and his launch angle error is 0, he will have a 0.5% chance that a 70-yard field goal will be good.

One more comment about standard deviations.  I said that 68% of all values will fall within one standard deviation of the mean, which is where the 70% accuracy value comes from on your misc. game planning screen.  Yes, I took a little liberty and rounded the amount to the nearest 10%.  This it is the distance where your kicker is within one standard deviation of making the field goal, using the shortest distance when considering his accuracy and strength.

No comments:

Post a Comment