2007
03.31

I haven’t been posting anything in a while, and with good reason. I’ve been working furiously on my school work, trying to keep up as best as I can. After about a month of procrastination, my professor finally handed back our graded midterms. I was pleased to see that I had a 92, but found that he had claimed that my heuristic for one of the solutions was not admissible, even though it was exactly the same as his. We’ve been bombarded with homework as of late it seems, so I’m doing my best to complete them on time.

So the project I had to do was play a game of 9 Man’s Morris. I’ve mentioned it here before, so I’ll skip the introduction. It took me approximately 5 hours to write the initial version. That initial version was about 80% correct and very readable. It’s too bad that I have since learned that professors and TAs never read your source code, but I’ll talk about that near the end. It then took me a mere 20-ish hours to debug the program and iron out the problems that accumulated over the course of development. Since this was a largely recursive algorithm that analyzed tons of stack data, it was very difficult to distinguish good and bad behavior.

Over the course of development, I discovered (and rediscovered in some cases) why Perl is one of the most complete and challenging languages available. So I figured I’d share my refreshed love and respect for Perl.

First, the map function is the best example of simplicity. Here is an example of some code that just makes map the absolute best method for reducing simple loops down to single statements.

Crappy Original:

for(my $i = 0; i < $#array; $i++) {
   $array[$i] =~ s/search/replace/g;
   print "$array[$i]\n";
}

Better Original:

for(@array) {
   s/search/replace/g;
   print "$_\n";
}

Map Improvement:

map { s/search/replace/g; print; } @array;

It’s fairly obvious that using map is the best way to clean up that few-liner list loops (remember that @array is not restricted to a typical array, as many things can placed into list context).

Next on my list of things that I love is the prepackaged module Carp. If you love to use the die statement to help identify problematic situations, then you’ll love Carp. Carp is the bastard child of gdb backtraces and the die function. If you use the cluck function, you can cause a warning that will be accompanied with a stacktrace. When I discovered this, I was having trouble with my recursive function at only certain depths. So I tossed the following at the top of my function to check all of my parameters and optional parameters:

my ($self, $var1, $var2) = @_;
cluck "Var2 not specified" if !defined $var2;

That example was similar to how I found my problem. The example simply tosses a warning, complete with a stacktrace, when one of the variables on @_ is undefined. This is how I found out that I was never technically passing in an optional parameter to a function. Since use of optional arguments will basically leave them as undef, using them in the function with being set to undef is a valid use, just incorrect behavior. I would certainly hope there is a much better way to using optional arguments (I’m sure there is a clever module to do it).

I wanted to talk about references and tie, but I don’t think I can keep my eyes open long enough to express myself well enough. I’ll post some more this weekend as I get time.

2007
03.18

Minor Site Tweaks And Updates

So I’ve finished my AI project and started tweaking the site some. I cleaned up the links and installed the WP-Tiger admin plugin. I really like this plugin as it’s much cleaner than the default WordPress interface. The top-side menu on WordPress has been driving me nuts from day one, so it’s nice to see a left-side control panel. My only wish is that it would expand sub-menu items below rather than across the top.

You may also notice the sidebar has changed slightly. A few weeks back I noticed that the Archives section had grown rather large and seemed to obscure the reader from the actual content. So I installed a few archive page plugins and none of them were very intuitive. Then I tried Super Archives. This plugin was neat but was a nightmare to setup, so I changed to Extended Live Archives. The concept is that the archives is a dynamic CSS based AJAX archive component. The default look was exactly the same as the Super Archives, but I found some people had styled them to be very attractive. I tried my hardest to do this alone, but in the end, I ended up using someone else’s CSS as a basis that accomplished the layout I wanted. I would have really loved it if the author had styled it this way from the beginning. Then I modified it to remove the annoyances and fixed the colors. So from now on, all archives can be accessed through the archival page.

I’ve also started adding social bookmarking links to the posts and pages via the Gregarious plugin. This plugin is nice, but the default styling looks like crap under my theme. I accidentally wiped out all of my settings so I am trying to get the Share This link to show the default sites again. Feel free to test the digg links as I don’t think it would be good netiquette to do that myself.

Lastly, I ran a race yesterday and performed very well. I updated the race page and added a section to track my current PRs (personal records). I am thinking of adding a sidebar widget to list those PRs but we’ll see. I am leery about trying to continue to use fGallery to upload pictures of the event because I simply don’t want to upload things that slow. I also want tag support but there doesn’t seem to be anything in that realm. I’m hoping someone takes on my f-spot idea.

Anyways, I have to wrap up my project and prepare it for submission. I will post the code later so other people may find interest in the subject. I will also post the version that I will submit for the tournament (winner gets 15 points on their final grade!). Then maybe before the summer starts, I’ll publish the modules on CPAN.

By the way, you can now pre-order the Year Zero album on Amazon.

2007
03.12

Okay, so it’s been a while since I posted anything. Last weekend, sunshine and I went to Seattle to get away from things. I will talk about it more in a separate post, but we had a good time. There’s a lot to talk about, so I’ll reserve that for a dedicated post.

Lately, I’ve been holed up in my office working on my AI project. We have been tasked to play a game of 9 Men’s Morris. This is basically an ancient version of Tic Tac Toe. The branching factor on this game is significant enough to warrant the intelligent searching algorithms we’ve learned in class. I am working mine in Perl and have about 85% complete. I haven’t performed any performance enhancements yet which has left it running for 1:24:36 so far analyzing a ply of 7. With a ply of 6, it only took 20 minutes. I haven’t applied alpha-beta pruning (which is part of the assignment), so I expect that to significantly drop the run-time. Anyways, I hope to post that project on CPAN eventually, so other people can work on variations of the game.

I spent a few minutes the other day and worked on the archives page. Right now, it looks like a much better way of sifting through the old postings here on zero-blog. When I finalize the style, I’ll remove the category and archive listing on the sidebar and try to add something more useful (or nifty). No progress on the photo album though as I grew extremely frustrated with uploading the photos 5 at a time since doing a whole album times out the PHP runtime. I’m trying to pump the f-spot guys to creating an output plugin for WordPress.

Lastly, I went on a long run with the usual suspects yesterday (I’ve switched to Saturday for long runs) and ran a complete 10.1 miles. That is officially the longest I’ve run consecutively and the first time I ever broke double digit miles. I’ve read about people who have done this for the first time and they were completely right. Afterwards, I felt like Superman. It was the greatest reward in my running since I was able to complete a 5K. On top of that, we took the clockwise loop around White Rock Lake, which is not an easy task, and my time was still around what I would expect it to be for such a distance. I have 2 races coming up, so this is the best thing to get me mentally into the race.

Spring break ends today, so I have to get back to working on my project while I have the time. I’ll post the aforementioned posts when I get the time.