Thursday, May 2nd, 2024
 
 
 
Updates automatically
Twitter Link
CHN iOS App
 
NCAA
1967 1970

ECAC
1967 1968 1969 1970 1973 1980 1986 1996 1997 2003 2005 2010

IVY
1966 1967 1968 1969 1970 1971 1972 1973 1977 1978 1983 1984 1985 1996 1997 2002 2003 2004 2005 2012 2014

Cleary Spittoon
2002 2003 2005

Ned Harkness Cup
2003 2005 2008 2013
 
Brendon
Iles
Pokulok
Schafer
Syphilis

My brain hurts...

Posted by CowbellGuy 
My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: April 24, 2002 01:09PM

So I have a list of penalties in a game for each team, the time the penalty occurred, and length of each penalty. Then I have a list of goals for each team, and the time of the goal. What I'm trying to do is figure out the number of skaters on the ice for each goal. The 96 lines of code I amassed to do this works about 98% of the time, but the game against Wilfrid Laurier (with 17 penalties and 42 PIM) broke it handily.

So, obviously, I need to rewrite it, and it would be very helpful to have a clear flow chart to know exactly how to approach it before I start and I was hoping some of you here might be able to help. Things like "count the number of Cornell goals from time A to time B" but NOT "count the number of power play goals from time A to time B" are possible. Goals are simply recorded as goals. Penalties as penalties. Any help would be greatly appreciated, since the assholes at collegehockeystats won't offer any help whatsoever. :-(



 
___________________________
"[Hugh] Jessiman turned out to be a huge specimen of something alright." --Puck Daddy
 
Re: My brain hurts...
Posted by: tml5 (---.twcny.rr.com)
Date: April 24, 2002 05:38PM

An irresistable puzzle. I hate you. :-))

(note - flow charts I can do, but you're on your own for writing/debugging the actual code, since I can't actually program)

Just to make sure I've got this straight:
You want to know the number of skaters for each team on the ice.
This means you need a flow chart of sorts that incorporates rules for the following:
(Cornell number on left in all cases)
Goals scored at 5x3, 5x4, 5x5
Goals scored at 4x3, 4x4, 4x5
Goals scored at 3x3, 3x4, 3x5

You're trying to get these rules based on inputs of penalty time, penalty length, and time of goal scored. I guess the biggest snags are major penalties and multiple matching penalties.

Assumptions and terms:

Opp = opponent
Cor = Cornell
G = Goal
P = Penalty
Tg = time of goal
Tp = Time of penalty
S = duration of penalty in seconds
Tpn = Time of penalty n
P1 = penalty 1
P2 = penalty 2

Pn = penalty n

Note that I did not build in the counting of the penalties. You should have it set to count the number of penalties assessed to Cornell, and the number of penalties assessed to opponent, so that each penalty will have a unique combination of cornell/opponent and n value.


Rules:

Initial, Opp=Cor=5
If Tg<Tp1, Opp(Tg)=Cor(Tg)=5.
Expiration of penalties defined:
Tp+S = Te
At time Te:
Cornell penalty: Opp(Te)=N, Cor(Te)=(N’+1)
Opponent penalty: Opp(Te)=(N+1), Cor(Te)=N’


When a penalty occurs:
If S=<120, p=minor
If S=300, p=major
If Tpncor = Tpn'opp, p=matching
Is p matching?
If Yes
If p is major, Opp=N(Tp) Cor=N’(Tp).
Is Cor=Opp=5?
If No, Opp=N(Tpn), Cor=N’(Tpn)
If Cor=Opp=5
Multiple penalties?
Yes – multiple matching
Opp=Cor=5
Yes – 1 matching plus extra
No match on extra, go to minor penalty
If matching, non-major, not multiple, and no existing penalty:
If Tp<Tg<(Tp+120), Opp(Tg)=Cor(Tg)=4
If Tg>(Tp+120) Opp(Tg)=Cor(Tg)=5

If non-matching
Is p major?
If Yes
Cor penalty: If Tp<Tg<(Tp+300) Opp(Tg)=N(Tp), Cor(Tg)=(N’(Tp)-1)
Opp penalty: If Tp<Tg<(Tp+300) Opp(Tg)=(N(Tp)-1), Cor(Tg)=N’(Tp)
If minor penalty
Cor penalty: If Tp<Tg<(Tp+120) Opp(Tg)=N(Tp), Cor(Tg)=(N’(Tp)-1)
Opp penalty: If Tp<Tg<(Tp+120) Opp(Tg)=(N(Tp)-1), Cor(Tg)=N’(Tp)
If Tp<Tg<(Tp+120), earliest p expires at Tg


So that's what I've got. What did I miss? I'm sure I missed something. I'll look at it again later, but I have to leave now.

I just realized what I missed. What about a situation where the team is already two men down. . . damn it. I'll figure that out later and put it in, which means I have to stop being lazy and include the n values. If you see anything else, let me know.
 
Re: My brain hurts...
Posted by: CowbellGuy (---.twcny.rr.com)
Date: April 24, 2002 08:28PM

Heh, sorry, but we're just scratching the surface here. Unless I'm missing something, that doesn't take into account penalties being released by PP goals being scored before the one currently being considered, or early release of the first of a double minor. And the real pain in the ass, more than 2 nonmatching minors where the third doesn't start until the first has been scored on or expires. :`( And we're back to the title of the thread... What I can do is have it "remember" the number of skaters for a previous goal.

 
Re: My brain hurts...
Posted by: tml5 (---.twcny.rr.com)
Date: April 25, 2002 06:31AM

Sorry, I was assuming some kind of memory function. I guess I didn't make that clear. It's way too early (um, late?), and I won't get to more of this until sometime this weekend, which is roughly when I plan to get out of bed. I'll give it a better go then.

Edit - I have no idea what I'm talking about. Your memory function is totally different from what I was thinking of. Ugh.
 
Re: My brain hurts...
Posted by: jkahn (216.146.73.---)
Date: April 25, 2002 02:22PM

This may be too simplistic, but can't you just merge the goal and penalty files by time, and flow through the game. C=CU players, O=opp. players, start C=5, O=5 and reduce where appropriate for penalties and then add back when appropriate for expiration or early release for goals. Each time a goal occurs, you'll know the values of C and O.

 
Re: My brain hurts...
Posted by: David Craine (---.nyc.rr.com)
Date: April 25, 2002 04:44PM

That probably wouldn't take into account goals at even strength 4 on 4 which wouldn't allow anyone out of the box. Would it be possible to set up an if-then statement saying if C<O then C+1=C and vise versa?
 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: April 25, 2002 04:45PM

nope. well, yeah, but you still need to figure out if C<O based on penalty and goals. vicious little circle.

 
Re: My brain hurts...
Posted by: David Craine (---.nyc.rr.com)
Date: April 25, 2002 05:45PM

Not only that but you have to account for major penalties where players aren't let out of the box.
 
Re: My brain hurts...
Posted by: jkahn (216.146.73.---)
Date: April 25, 2002 05:58PM

Admittedly, it's been 30 years since I wrote a program (although I did have a summer job as a programmer in '69, '70 and '71). Anyway, if you start at C=5 and O=5 and adjust for every penalty and goal ( the program should be able to act like a ref and know how many should be on the ice at any time), I don't see why you wouldn't be able to get the values of C and O each time a goal is scored. The input would be the penalties and goals processed sequentially, which are the events that control the values of C and O at any time. Obviously, you'd need to program in the rules, such as you don't increase the value of C or O if the player in the box is serving a major, and more complex things such as if two guys in the box on same team, first penalty expires, etc.

 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: April 26, 2002 09:30AM

Because it doesn't know how many men are on the ice going into a situation without figuring it all out again. The only way it could do that is step through the entire game a second at a time and have an array with 3600 values for each team. Hardly efficient or elegant. Also, I need to be able to plug in a goal and get its type back without doing the whole procedure for a game (ie, count power play goals for a player in a season). I'll just show you how I was doing it, in this case for a Cornell goal. I started with C=5 and O=5 as you mentioned.
I. Get time and length from opponent 2 minute penalties in the last 120 seconds and 5 minute penalties in the last 300 seconds.
A. If 5 minute
1. O decreases by one. (Simplistic and wrong, but I was having enough trouble getting the 2 mins right and didn't even get to deal with 5's right)
B. If 2 minute
1. Count 2 minute penalties at that time for Cornell
a. If there are any and O=5 and C=5, O decreases by one
b. Get time of Cornell goals in the 2 minutes prior to this penalty.
i. Here it checks if there were any other goals scored at this time that it already figured out (this was a kludge and obviously wouldn't work in the actual version). If it's a Cornell goal, and there were more Cornell skaters than opponent skaters, O increases by one.


Anyway, you get the idea. Then it walks through more or less the same procedure for Cornell penalties in that time span and does the opposite. It doesn't take into account a LOT of things, and obviously isn't satisfactory for the issues I described earlier.

 
Re: My brain hurts...
Posted by: ursusminor (---.nrl.navy.mil)
Date: April 26, 2002 10:52AM

Age, I think that you really have to walk it through the entire game adjusting every time that a penalty is given or a goal is scored, because conceivably in the third period there might be delayed penalties that have backed up from the first period. Clearly, such games are rare, but it is not unknown to have a series of penalties backing up for ten minutes. The only possible way of getting around this is by adding up the total amount of penalties in the game and thus conclude that such a sitation couldn't happen.

The other way of getting around it is checking if Clarkson is playing. rolleyes
 
Re: My brain hurts...
Posted by: jtwcornell91 (---.phys.utb.edu)
Date: April 26, 2002 12:00PM

ursaminor wrote:

The other way of getting around it is checking if Clarkson is playing. rolleyes
LOL! laugh

 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: April 26, 2002 12:40PM

Heh. OmniGraffle is cool.



 
Re: My brain hurts...
Posted by: KeithK (---.dsl.snfc21.pacbell.net)
Date: April 26, 2002 01:39PM

Interesting programming problem, but... Seems to me the easiest way to do it is to just write a script to preprocess the goals from each game as a block and then store the nxm numbers in the DB. That way you could step through the entire game but would only do it once and never real time.
 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: April 26, 2002 02:32PM

But then if anything changes or you correct a mistake you have to reprocess the game. And if you're going to store stuff statically, might as well just flag the goals when you enter them into the db. That's no fun.

<ego>
Also, if collegehockeystats is doing it on the fly and they refuse to throw me a bone, I'll be damned if I settle for anything less.
</ego>
 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: April 26, 2002 03:51PM

If there are offsetting 5 min majors at 5x5, do the teams skate 4x4 for 5 min or not?

 
Re: My brain hurts...
Posted by: Greg Berge (---.dial.spiritone.com)
Date: April 26, 2002 05:55PM

No, you only remove manpower from the ice simultaneously for coincidental minors from full strength.
 
Re: My brain hurts...
Posted by: Robb (---.152.232.250.dial1.dallas1.level3.net)
Date: April 26, 2002 10:54PM

You don't need 3600 values in your table, you just need a 3 column table where the three columns are time, #cornell players, #opponent players. There would only need to be 2 x number of penalties + number of goals rows. 2x penalties because each penalty has a beginning and an end. This would capture all events that change the number of players on the ice (naturally, there would be overlap, since a goal often coincides with the end of a penalty). Then you just have to look at the rows in the table that represent goals and see how many players were on the ice at the time (i.e. in the previous row, just before the goal was scored). Doesn't seem that bad to me - but then, no problem seems that bad before you actually try to solve it...
 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: May 06, 2002 02:37PM

Well, I think I finally got it doing 2 minute penalties right. 4's and 5's should be easily integrated. *phew*

 
Re: My brain hurts...
Posted by: CowbellGuy (---.biotech.cornell.edu)
Date: May 15, 2002 03:00PM

Well, I would like to just send out a resounding flipd to the asshole at Collegehockeystats who wouldn't help out with the penalty system, as I finally got mine working today, for real, and should work in any potential situation. yay!

 

Sorry, only registered users may post in this forum.

Click here to login