Posts Tagged ‘football’

OnScreen QB Stats: A New iPhone App for Evaluating Quarterbacks During and After a Game

Wednesday, December 30th, 2009

OK, having spent several weeks working on OnScreen QB Stats™, a sports-category iPhone app that just made it to the iTunes App Store about a week ago, I want to say something about it and how it came to be. As its name will probably imply to most readers, the app concerns American football (I’d forgotten the field has a different length in Canada, so Canadian football must wait), specifically the player that is most important on most teams, the quarterback (QB). He’s the player that handles the ball on virtually every play and has the biggest chance of deciding who wins the game through his ability to move the ball down the field in big jumps by completing passes, including some that score touchdowns. Of course the quarterback can also squander a down by throwing a pass that can’t be caught or, much worse, he can give the ball to the other team by throwing a pass that’s intercepted. Naturally people would like to quantify quarterback performance, so, in addition to being a very important player, the quarterback is the player for which there are the most statistics recorded and calculated. OnScreen QB Stats enables one to record a quarterback’s raw passing results during the course of a game and review the derived stats such as completion percentage as well. It can be used to record and display on an iPhone or iPod Touch the passing stats of every quarterback in the game for each team.

The full set of quarterback statistics recorded and calculated by OnScreen QB Stats is shown below.

The User’s Guide for OnScreen QB Stats is available as a pdf file. There every button and display is briefly explained.

After finishing my first app, OnScreen Pitch Count™, I had begun to think about making a version for the iPhone of OnScreen DNA (my virtual model of the double helix molecule of life, which runs on Macs and Windows PCs). I had already started experimenting with OpenGL ES toward that end, when it occurred to me that a lot of the nitty gritty coding I’d already done for OnScreen Pitch Count, which allows a user to record and review the results of baseball pitchers’ pitches, could be easily adapted to an app that followed quarterbacks’ passing results. That is, the machinery for saving and restoring the passing results, for reviewing those results, and for setting up the data storage for the results of individual quarterbacks on the two opposing teams, would be but a minor change from that already developed for the pitchers in OnScreen Pitch Count. That actually turned out to be pretty true. One modification was that I had to allow for the possibility that a quarterback might re-enter the game after being replaced for a time, which is not something that happens in baseball.

I had also assumed that the actual data entry by tapping buttons on the screen would be at least as simple for the pass results as for the pitch results. I thought the bookkeeping involved would be simpler for football, since I wouldn’t have to worry about strikeouts, walks, outs, base runners, and innings (not to mention complications such as charging runs to pitchers after they’d left the game). I thought I’d be able to write the football app in three weeks or so, finishing it in time to justify working on it for the current season. Since every high school, peewee, and non-bowl college game in the country (as far as I know) had been played before the app finally became available, I obviously misjudged the complexity of the task. All in all, when I consider things like the extra choices that had to be coded for undoing an action (e.g. completely wipe out a touchdown pass, call it incomplete, or place the ball short of the goal line), and the numerous states to which the app might need to be restored after an interruption (e.g. awaiting line of scimmage determination after a pass completion) the quarterback app seems to have been more work than the pitching app.

There is less to record for a quarterback than for a pitcher. We need to record attempted passes, completed ones, and intercepted ones. Then we need to keep track of the yards gained passing and the number of touchdown passes. Those are the basics. I added quarterback sacks and longest completed pass for good measure, but from the basic pass statistics we can calculate derived quantities such as yards gained per passing attempt and the rather arcane numbers called quarterback rating in the NFL and passing efficiency in the NCAA. Both of these rating methods use pass completion percentage, yards per attempt, interceptions, and touchdown passes to come up with a number that serves as a basis for comparison among quarterbacks. Although, the number is much less meaningful in a single game than in a season, it can be of interest to know what it is for a game, and OnScreen QB Stats will calculate and display whichever measure of quarterback performance the user desires.

Although the data to be recorded might seem at first glance to be simple, in practice it is more complicated. Someone sitting in a press box with a spotter to provide the details of each play could get by with an app that recorded completions, incompletions, yards gained, interceptions, and touchdowns. But for someone watching a game from the sidelines or stands or even on television, there is the problem of determining how many yards were gained on a given play. The only way to do that with full confidence is to keep track of where the ball is after each play, since one doesn’t know in advance which plays are going to be passes. Once a play is underway, it is difficult to note the line of scrimmage from which play started and then calculate yards gained by noting where the receiver was brought down. It’s a lot to take in and keep straight in a short time, even assuming one has a good view of the sideline yard markers, which is often not the case when watching a game on television. The additional challenge is to do all the data entry on the iPhone without recourse to pencil and paper or on-the-spot mental calculations.

OnScreen QB Stats solves the problem of passing yardage calculation by making it easy to record the new line of scrimmage after each play; and if the play leading to the change of field position is a completed pass, the app automatically calculates the corresponding gain in yards and adds it to the total for the game, while adjusting all other stats that depend on passing yardage as well.

It took me a lot of trial and error to come to this easy way of recording the new line of scrimmage after each play (or penalty). At one point I had thought that using a slider control to just slide a pointer along a representation of the 100 yards of the field to mark the current line of scrimmage would be both intuitive and fast. I ran into two problems with the slider method. For one thing it was hard to quickly obtain the precision I needed down to the yard, which is only 1% of the length of the control. So, I added a second fine-tuning slide control to move the pointer just within plus or minus a couple of yards of where the full-field control pointed. This solution worked, but frequently required using both controls, which was a nuisance. I might have decided to live with it, given the intuitiveness of the slider, but the controls turned out not to be reliably responsive on an actual device. Sometimes the sliders were easy to drag, sometimes they seemed in need of a squirt of WD-40. It was hard to ditch all the work that I had put into that method of yard line setting, but I decided I had no choice but to code a new method.

The solution I came up with can be seen below.
The screen above shows how one enters the new line of scrimmage after a play has been completed. This screen appears whenever the user taps a button to record a play from scrimmage or a penalty (or simple need to adjust the current setting for the line of scrimmage). In the example shown the team with the ball has reached its opponent’s eleven yard line. Note that the “Defense’s End” is highlighted in the top control to indicate which end of the field the ball is in. That control also adjusts so that the ends of the field in the sense of right and left correspond to what the user sees, assuming the initial setup has been made correctly and the correct quarter has been maintained. Whenever the ball goes to the other team (currently called Defense), the labeling of the top control reverses (Offense becomes Defense and vice versa), so that the field situation is correctly mirrored. At the end of the first quarter, for example, the same switch takes place.

The yard marker for the current line of scrimmage is shown to be 11, and that choice has been made by tapping the tens place control (blank to 5) on its “1” and the ones place control (0 to 9) also on its “1”. There is no keyboard to deal with, and for short yardage plays only the ones place control needs to be adjusted in many cases.

The number 24 beside the “Check Gain” button shows that the user has tapped that button in order to see how many yards will be recorded as having been gained, assuming the ball is marked at the 11 yard line. The previous line of scrimmage must have been the opposing team’s 35. The “Record Pass” button is to be tapped once the user is satisfied with the choice of yard line (here the 11) and need not be tapped until the final spot has been made to minimize the need for adjustments. The button’s title being “Record Pass” indicates that the play just over was a completed pass. On a running play (or pass by someone other than the quarterback), it would be reading “Record Gain” (or “Record Loss”). The “Touchdown” button’s use is obvious, and in the case of a touchdown pass, there is no need to set the yard line button by hand.

The screen below shows the most basic results of the quarterback’s passes and also contains the buttons for registering which type of play has occurred. The pass results shouldn’t need description. The four buttons stacked in the lower right are for recording pass results or for canceling out the previously recorded play (“Undo”). We are especially interested in eliminating the chance for accidental recording by unconscious taps for these four buttons, so they all require a double tap to work. Double-tapping the “Incomp” button just increments the number of passes and the Down, which is displayed in the yellow area along with the yards needed to make a first down and the current location of the ball, which is the opponent’s 42-yard-line. The display of the “42” in red indicates the team with the ball has crossed midfield into the other team’s territory.
The down and yard marker are kept up to date by the app as a way of providng a check on whether the user has entered any data incorrectly. For example, if the user had failed to register that the team had crossed midfield, and had chosen the 42 yard line in the quarterback’s team’s end of the field, the display would be in black instead of red. As a further means of insuring ball movement is recorded in the proper direction, the user has two buttons to choose between for plays from scrimmage other than quarterback passes—”Other Loss” and “Other Gain”. If a gain has been chosen, then the new line of scrimmage must be in the right direction for a gain. The other buttons are to be used for what you’d expect given their titles. Kicks and turnovers lead to the other team having the ball, as do touchdowns. The “Go on Def.” button also gives the other team the ball, but shouldn’t be used except to correct a user mistake or when there’s been a fumble lost after a turnover of some kind not on a play from scrimmage (e.g. fumble lost on punt return).

Using OnScreen QB Stats just amounts to keeping track of the line of scrimmage and recording pass results. The app does all the calculations, including yards gained on passes. Recording pass results for a game on television can be challenging because so few announcers now state where the ball is after every play (I’d guess less than 25%). The line of scrimmage is often not shown until right before the snap, and it can often be difficult to see where a runner was tackled due to the camera angle when the tackle occurred (followed by the three replays with no view of the sideline markers). Even a televised game can be followed smoothly, though, after a little practice.

I think I can safely say that as of now there is not another app that allows one to record all of these passing results and view these stats for quarterbacks during the course of a game. So I’m hoping word gets out to those crazy folks (like me) that might like to have that power. If you know one, pass the word. It’s on the iTunes App Store here.

Belichick Is Not a Gambler: He Played the Percentages Last Night

Monday, November 16th, 2009

What got into Bill Belichick, coach of the New England Patriots, last night to make him suddenly become a reckless gambler? That’s the question stunned New England Patriots fans have been asking themselves after he seemed to throw caution to the winds by deciding to go for a first down rather than punting in a key situation last night. The Patriots had the ball on their own 28 yard line in a fourth and two situation with about two minutes to play and a six-point lead in their game against the Indianapolis Colts. The Patriots went down to a crushing defeat when they failed to make the first and the Colts then scored 7 points to win 35-34. Naturally, Dan Shaughessy of the Boston Globe was pulling out all stops to express the monumental stupidity of the coach’s decision, saved from eternal ignominy (perhaps) only by its not having been made in a post season game.

I was as surprised as anyone when I saw the Patriots were going for the first down, but on further review, I am going to argue that Belichick made the right call. The timing of the call is crucial because the first down will be decisive if made. With lots of time to play, of course you punt. And for a random game picked out of a hat, this situation would seem to require a punt without a second thought. Get the ball away from your goal line and play prevent defense. What are the odds the other team can move 75 yards in two minutes in a high pressure situation? What are the odds you’re going to pick up two yards against a team geared to stop a short gain?

But this was not a random game between random teams. First of all, the two best quarterbacks in football were playing in it, and that has a strong bearing on the likely outcomes of different scenarios in the last two minutes of a game. One has to consider all the specific personnel of the teams and their current state of exhaustion, the crowd factor, and that real psychological edge people called “momentum.” No, this is not a question that has a universal answer, though Belichick may be one of the few coaches who would realize that.

In addition to Brady, the Patriots have other veterans of Super Bowl Championship teams, including the invaluable Kevin Faulk. These are players that actually get better in pressure situations. The starting point in a decision has to be what are the odds that Tom Brady will be able to complete a two yard pass to Kevin Faulk on third and two from the Patriots’ thirty? From what I’ve seen of these two clutch performers, I’d say about 80%. I’m sure Belichick has a better estimate. What if it’s fourth and two? The odds could go up a little because the Colts have to be thinking that the whole thing may be just a ruse to draw them offside. The Colts must be holding back until they are sure of the snap, thus giving Brady a fraction of second more time to make a decision and an unhurried throw. On the other hand, they aren’t going to be worried about deep coverage. Lets say the odds are that the Pats make the first down 75% of the time.

If they make the first down, the victory is basically cinched, game over. Thus the pass play gives the Pats a 75% chance of winning the game. True, if they don’t make it, based on the way the Colts have been moving the ball, the odds are great that they will lose the game. But of course that is not the comparison to make at this stage of the game with only two minutes to go. The chance of winning if the Pats go for the first down has to be compared with the chance of their winning if they give the ball back to the Colts, at say (best case scenario of negligible runback) the Colts’ 25 yard line. But what had just happened? The Colts had taken the ball 79 yards in 1:44. Manning had been sharp as could be. That means as sharp as anyone could be. The receivers had been sure-handed and were getting open. The Patriot pass rushers seemed tired. The game is in Indianapolis.

The decision formula is simple. Let the probability of making the first down be F, and the probability of a Colt touchdown after a punt be T. Then if F > (1-T), the Patriots should go for the first down. What were the odds that Peyton Manning would be able to get a touchdown in 2 minutes with 3 timeouts and the 2 minute warning to play with? Were the odds of a Colt touchdown greater than 25%? That’s the calculation Belichick had to make on the spot in a short time. If the answer to that question is a definite yes, then the Patriots should go for the first down.

One may argue about the chances of success with Brady throwing to Faulk to pick up a 2 yard first down. I think 75% is a reasonable number. I also think that the odds of Manning getting the Colts into the end zone after a punt were over 50%, which means Belichick’s decision, far from being crazy, was in fact the reasonable one. The main point is that the odds to compare are the odds of the Patriots making the first down and thus assuring the victory versus the odds of Colts scoring after a punt (not after getting the ball on downs). The decision formula F > (1-T) would still say go for the first down even if the chance of success was 60%, so long as the chance of the Colts scoring after a punt was greater than 40%.

Did Brady choke and overthrow Faulk? No, the pass was perfect. Did Faulk drop the ball even when hit? No, but he did take a split second to gain full possession of it after being hit right at the first down spot. Just enough to make the spot short of the first down marker. The Colts defense did just enough to get the ball back. But it was a close as could be, and the call could have gone the other way. Home field advantage may have helped there. The fact that it was so close just points out to me how likely success was.

Would I as coach have gone for the first down? No, like all normal human beings I would have punted and hoped. I wouldn’t have thought to make the proper analysis in the excitement of the game in the first place, and I wouldn’t have had the guts to go against what first glance intuition said if I had. But I now see that Belichick was both smart and courageous. It’s not as though he didn’t know the consequences of failure. He wanted to win more than he feared what the media and fans would say if he didn’t. Yep, the guy is one of a kind.

This is my first (and probably last) topical sports post, but it’s been so long since I’ve posted anything (tied up with iPhone app development again) that I thought I’d better go with something that caught my attention. Back to “normal programming” soon. Maybe.