Tuesday, April 28, 2009

Round 2 Predictions

Well, round 1 is now done, so onto the 2nd round predictions:

Eastern Conference

Pittsburgh Penguins vs Washington Capitals - Gee, do you think Gary Bettman's happy about this matchup? Crosby vs Ovie, the matchup the NHL has wanted in the playoffs for a few years now. It's too bad that both teams aren't playing up to their potential right now. Washington barely squeaked by NY, and if not for the complete collapse of the Rangers in game's 5 and 6 they could've very easily found themselves golfing right now. Even in game 7, it wasn't until the 3rd period that they really stepped it up and took over the game. Pittsburgh managed the win over Philly, but with all due respect to the Flyers, they simply did not bring their A game to that series (not even close). At any rate, kinda tough to call this series. No question that Pittsburgh has the edge in goaltending, and one could argue that they're a more complete team than Washington, but the best player in the series (and the league) is wearing a Caps jersey.
  • My prediction: Caps in 6
  • Wife's prediction: Caps in 6
Carolina Hurricanes vs Boston Bruins - Wow, was that an amazing finish by Carolina, giving NJ a really bitter pill to swallow in this off season. I thought that series could be an upset, but I don't think it's a stretch to say that they barely pulled off that win. Boston looked like, well, Boston in the first round, handling the injury-ridden and not nearly playoff ready Habs in very short order. No doubt for me that Boston's the better team, but I think the layoff combined with the high that Carolina is riding right now might tip things in the Canes favour early.
  • My prediction: Bruins in 7
  • Wife's prediction: Canes in 7
Western Conference

Anaheim Ducks vs Detroit Red Wings - Amazing upset by the Ducks over the Sharks in round 1, but this is easily the biggest mismatch in this round (maybe even this postseason). I think the Ducks might squeak out an early win as the Wings shake off the rust from the long break, but Detroit should be able to coast through this series. The Ducks have always been a team which takes far too many penalties and while the Sharks couldn't capitalize on that, Detroit will.
  • My Prediction: Wings in 5
  • Wife's Prediction: Wings in 5
Chicago Blackhawks vs Vancouver Canucks - My boys. :) Bobby Lou was spectacular in round 1, and the team in front of him played some of their best hockey in front of him. As the series wore on though, St Louis really started to press us, and in all fairness, early on the Blues just didn't play the way they are capable of playing. Chicago is coming off a very physical round against the Flames, where they looked a bit shakey at times early on, but shook off that young playoff nervousness and finished very strong. Khabibulin is getting a lot of credit for the win against the Flames, however, I think this praise has been rather overstated. The Flames simply didn't have a healthy enough lineup to really test him, and in many cases the great saves he made were as much luck as they were skill. No question my team has the edge in goaltending, but the speedy Hawk forwards are going to give the likes of Mitchell and Ohlund fits. This one I think will be really close.
  • My prediction: Canucks in 7
  • Wife's prediction: Canucks in 7

Monday, April 13, 2009

2009 Stanley Cup Playoff Predictions

Well it's that time of the year again, time for the 2009 version of my playoff predictions. Just like previous years both myself and my wife are making predictions and competing for marital bragging rights. On to the predictions:

Western Conference

Detroit Red Wings vs Columbus Blue Jackets
Interesting series, the BJ's (snicker) are in the post-season for the first time. Too bad it's against the defending Stanley Cup champs as even with rookie sensation Steve Mason, this one's no contest. Detroit's been somewhat underachieving (if you can call a #2 finish in the NHL underachieving) all year, but it'll take a miracle for this one to go past 5 games.
  • My prediction: Detroit in 5
  • Wife's Prediction: Detroit in 7
San Jose Sharks vs Anaheim Ducks
San Jose's been at or near the top of the standings all season long, and are arguably the favourites to win it all this post-season. The Ducks had a very slow start, kinda picked it up midseason, then hobbled into the playoffs nearly losing their playoff spot late in the season. Again, this one doesn't look like much of a contest, though given San Jose's history of underachieving in the post-season maybe this is an upset waiting to happen. Yeah right.
  • My Prediction: San Jose in 6
  • Wife's Prediction: San Jose in 5
Chicago Blackhawks vs Calgary Flames
This is the matchup to watch in the west, as the other 3 are likely going to be snoozers. Chicago's got a youthful, enthusastic, and very skilled team with a solid goaltending duo. Calgary has (when healthy) one of the best defensive cores in the NHL, the goaltender who (IMHO) should win the Vezina this season, and arguably the best power forward in the game in Iginla. Should be a hell of a matchup. If both teams were completely healthy I'd give it to Calgary for their experience, but given cow-town's injuries and the fact that they nearly had a complete collapse in the month of March, this one should be close.
  • My Prediction: Calgary in 7
  • Wife's Prediction: Calgary in 6
Vancouver Canucks vs St. Louis Blues
Never would've predicted this one at the end of February. How my boys managed to catch Calgary and how St Louis managed to not only make the post-season but finish in 6th is beyond me. My boys are playing some fine hockey right now, and Luongo is looking like, well, Luongo with 2 shutouts to finish off the season. The addition of Sundin really helped balance the scoring, giving us a bonafide #2 scoring line for the first time in what seems like forever. St Louis has been hot down the stretch, but I just don't see them putting up much of a fight in this series. We simply have more to play for and far more skill than they do.
  • My Prediction: Vancouver in 5
  • Wife's Prediction: Vancouver in 6
Eastern Conference

Boston Bruins vs Montreal Canadiens
This one has the potential to be a legendary series. It's arguably the most well-known rivalry in the NHL, and with Montreal being in their centennial season makes things extra special. Boston has looked like a powerhouse this season and although they cooled off a little bit late, they're still a hell of a hockey team. Montreal is an inexperienced, arguably soft, and very injured team right now, and who isn't playing with a lot of confidence. This one should be fun, but short.
  • My Prediction: Boston in 5
  • Wife's Prediction: Montreal in 7
Washington Capitals vs NY Rangers
Ovie-mania! Washington's played great all season, and given the dissapointment over their loss to Philly early in last year's playoffs should be hungry to go farther. I do think Washington is the most overrated of the division winners though, feasting on a rather weak Southeast division (though Carolina did their best to change that division's reputation down the stretch), and while Theodore is capable of being amazing (we saw that some time ago when he was in Montreal), he's also capable of choking (we saw that in Colorado last year). New York had an amazing start to the season, then struggled as the season went on. Torts was a great coaching change though, and is a proven playoff coach winning the Cup with Tampa a few years back. If Avery can play hockey and not be such a dumbass, this would has upset written all over it.
  • My Prediction: NY in 6
  • Wife's Prediction: Washington in 6
New Jersey Devils vs Carolina Hurricanes
Tough one to call. At points this season NJ looked so solid, with such great balanced scoring and solid defensive play. They're littered with veteran experienced players who know how to win (Shanny being the best example). Then Marty came back and they looked near unstoppable in the first few games after his return. They cooled off in recent weeks though. Carolina looked so-so all season until late, and after they re-picked up Eric Cole went on a huge run, finishing the season as one of the hottest teams in the NHL. This could be an upset, but I still think that NJ will pull it out.
  • My Prediction: NJ in 6
  • Wife's Prediction: NJ in 7
Philadelphia Flyers vs Pittsburgh Penguins
This is it. The series to watch. Playoff hockey at it's finest. Two rivals that absolutely hate each other battling it out in a 7 game series. Philly will be hungry to avenge their loss to the Pens last season, and truth be told, Pittsburgh is lucky to find itself in the post-season given how inconsistent they were throughout most of the season. Should be a bloodbath, and I think either team could win, but I'll go with Philly on this one.
  • My Prediction: Philly in 7
  • Wife's Prediction: Philly in 6
And there you have it. I honestly don't know who I think will win it all, this season more than most in recent memory has a feel of "anyone is beatable", so it could be a year of the upset or the dark horse. If push came to shove I'd go with Detroit as my pick to repeat, simply because they are arguably the most skilled team in the NHL, and have the experience to back it up.

Friday, February 13, 2009

Type Inference

I'm currently teaching CSC 212 - The Practice of Computer Science at UVic this term, and one of the topics we've touched on in the course is that of type inference -- the process by which a statically typed language can deduce the types of expressions without programmer annotation.

First some motivation from personal experience: there truly are moments in every programmers life when they learn about some new technique, concept, or abstraction and they stop, turn into Neo in the Matrix and go "woah". One of the first of them for me was when I learned about inheritance and polymorphism. Another was when I learned about type inference. Until you've used it you really can't appreciate how useful it is. It's yet another argument in favour of static typing, and it is really, really cool. It is without a doubt one of the coolest features I've seen in functional languages (though it is not limited to FP languages -- more on this in a second).

So what is it? Let's look at an example. In Java or C++ you might write a function with a header like:

Vector<somereallylongclassname> myMethodName (SomeOtherClassName foo)

And I don't know about you, but typing "SomeReallyLongClassName" and "SomeOtherClassName" is a pain in the ass. C/C++ alleviates this a bit with typedefs, but you still have to type extra characters to specify types of arguments (and Java doesn't have the typedef keyword). Wouldn't it be nice if the compiler could figure this out for us and save us some keystrokes? And of course it would be, and that's where type inference comes in.

In a language which supports type inference, the types of identifiers in your source code are deduced by the compiler depending upon the context in which the identifier is used. The trivial example I usually show students is the following function declaration in SML (a functional language designed by Robin Milner who is oftentimes credited as the guy who came up with the notion of type inference):

fun foo x = x + 3;

When the above code is compiled, the compiler deduces the type signature of the function foo() to be "int -> int", or (in English) a function which takes an integer and returns an integer. Note however, there is no syntactic evidence of type annotations -- nowhere did I write "int x" or something similar. The compiler figures out the type of x by the "x + 3" expression in foo()'s definition. Since 3 is an int, and the + operator is one which takes two arguments of the same type it infers that x must therefore be an int (and additionally since the + operator returns a value of the same type as its operands it also deduces that foo must return an int as well).

This is magic.

It's also the best of both worlds: all the type safety of static typing, and the "clean" or "uncluttered" code of dynamic typing.

One thing I've been thinking about lately though is how type inference would play out in a OO language. One of the reasons the algorithm works well in a language like ML is because functions can neither be overloaded or overrided (though they can be rebound or redefined). So for example, if I have a function declaration like:

fun foo x = bar (x);

There's no trouble in figuring out what which function bar() refers to (since there's only one). In an OO language like Java you could have a situation like:

Foo f = new SubclassofFoo();
f.someMethod(x, y, z);

and suddenly the problem becomes more complex -- is someMethod() a part of the Foo class or SubclassOfFoo? Or is it defined in some other parent class to Foo? And since we can overload methods in Java we also need to know the types of x, y, and z to figure out which version of someMethod we need.

Now imagine we lived in the C++ world and we bring in multiple inheritance and suddenly the world gets even more complicated as now someMethod() could be in one of many parent classes.

I suppose this is about the time I put on my snooty elitist academic hat and say that this is another example of why we should all be coding in functional languages, but I'll save that for another blog entry. :)

At any rate, type inference is a staple feature in many functional languages: SML, Haskell and CAL all use it. The Gem Cutter visual programming environment I'm using in my thesis work is a great tool as well for learning about type inference -- as you make or break connections between functions, type inference is applied and the types of inputs and outputs change accordingly. This allows newer programmers to more visually see the cause and effect nature of the algorithm.

Thursday, January 8, 2009

Xbox Avatars on your desktop

So last November Microsoft introduced the New Xbox Experience (NXE) and along with it, the addition of Avatars. Now we can have little digital versions of ourselves on our 360's. Additionally a few websites have made use of them as well (for example www.360voice.com displays your avatar on your Xbox's blog page).

I wanted to be able to check out the avatar's of some of my friends on XBL, and I thought it would be cool to have them on my desktop. From this, a Perl script for doing so was born.

For example, right now my desktop on my netbook looks like:

As you can see, the avatar's (and gamercards!) for 4 of my friends are drawn on my wallpaper. This script which started off so simple, has now become quite complex (as most programming projects do), and is quite versatile. You can now:

  • Specify the number of columns of gamers (in the above screenshot this is set to 1, but you could have 2 or 3 or as many columns of avatar's and gamercards as you want)
  • Set the opacity (transparency) of the avatar's so that you could have your background image partially show through.
  • Have as many or as few gamers as you wish
  • Change the card look by specifying a different base URL from MyGamerCard.net
  • Output the image in 8 bit, 24 bit, or 32 bit colour depth
  • Output the image as a PNG file or Windows BMP
  • Only generate an image consisting of Avatars & gamercards or have them drawn on a suppplied background image (in GIF, JPEG or PNG format)
  • Specify the width & height of avatar's and/or gamercards
  • And much more
The script itself is written in Perl, and runs fine with v5.10.x of ActivePerl for Windows (if using older versions, you'll need to install the GD library as well). It is command-line driven and intended for relatively "advanced" users. For help:

perl genWall.pl -?

will show all the options. And lastly the script itself can be found at:


And it is released under the conditions of the GNU Public License (GPL), so is free to use and modify as you see fit. Enjoy!