Monday, July 21, 2008

Designing A Hockey Power-Play System: Part 2

After thinking about this for a few days, I've got some new thoughts about the whole thing. First off, in my previous post, I made a mistake. I stated that if the same team commits a second penalty prior to the first penalty expiring that we should set the 5 on 3 timer to (duration of the second penalty) - (remaining duration of the first penalty). In fact, each successive penalty situation after the first would be set to the lowest remaining time of all current penalties against that team. Even simpler is the fact that there are only 3 possible penalty levels: 5 on 4, 5 on 3, or 4 on 4. Remember, if a team commits a penalty when they are already at a 5 on 3 disadvantage, they remain at that disadvantage, but they have to sub a player out.

The reason this problem is so tricky is that all of this work is only to provide the heads up display to the user. That is, when you watch hockey on TV, it tells you when it's a 5 on 4, 5 on 3, or 4 on 4. Because of that, we can't simply just pull guys off the ice, each with their own timer, and put them back on when it expires. We have to keep track of the penalty situation (5 on 4, 5 on 3, 4 on 4, etc...) and also provide the user with the proper timing information for how long that particular situation will last.

In the background we'll handle penalties in that simple fashion of giving each player in the penalty box a timer and then when it expires, place him back on the ice. However, the tier system is what will handle the proper heads up display for the user.

That's all for now, I just wanted to write down the areas that I've cleaned up in these past few days. More to come soon.

-Z

1 comment:

HappyCodeMonkey said...

I'm really glad you're follow up on this post, that's a great mental exercise. Anxious to see more.