RSS

Minesweeper Automation

October 26th, 2008   Filed Under code, games, portfolio, projects  

A few years ago, I was playing a lot of Minesweeper, and I realized that I was spending most of my time implementing two very simple rules repeatedly:

  1. If the number of mines indicated by this square is equal to the number of neighboring mines already flagged, clear any uncleared/unflagged neighbors.
  2. If the number of mines indicated by this square is equal to the number of neighboring mines already flagged plus the number of uncleared neighbors, then flag all uncleared neighbors as mines.

These rules should be obviously correct to anyone who’s ever played Minesweeper; in fact, I can’t even imagine making any progress in a Minesweeper game without them. So I decided to implement these rules in Gnomine, the open source version of Minesweeper that comes with Gnome on Linux. It only took me a few hours before I had this patch (applicable to gnome-games v2.20.1). Of course, this patch assumes that no mines are ever incorrectly flagged, but I think that’s a reasonable assumption.

And after playing with it, it’s surprising how much of the board can be cleared mechanically before you ever even get to any interesting decisions. When the sweeping does stop, what’s left are a few random decisions, where you can’t do any better than a 50/50 guess, and also the genuinely interesting positions where you have to apply set theory to make deductions.

I sent this patch off to the gnome-games mailing list owner, and have yet to receive a response. I’m sure that adding minor features to gnomine is absolutely no one’s top priority, but maybe if someone else has been similarly inspired, they might find this patch useful.



Watchmen by Alan Moore

October 24th, 2008   Filed Under books  

I never really got into comics as a kid. As an adult, I was once near a conversation about graphic novels, and couldn’t help but scoff and deride the material as juvenile. A friend who was involved in the conversation insisted I was wrong, and lent me a copy of Maus. From the first page, I was completely blown away. It’s an amazing work of art, and by the time I finished it, it had become (and still is) one of the best books I’ve ever read, graphic novel or otherwise. Its Pulitzer is well-deserved, and I would wholeheartedly recommend it to anyone, especially people who scoff at the irrelevance of graphic novels.

After this eye-opening experience a few years ago, I’ve been biding my time, waiting to give the genre another chance. Maybe I’d only read the chaff, and never gotten into the wheat. I’ve been told by many a graphic novel enthusiast that Watchmen is a classic, one of the best there is; a deconstruction of the entire genre. The same friend that lent me Maus also lent me his copy of Watchmen, and the back of the book itself says “If you’ve never read a graphic novel, then Watchmen is the one to start with”.

So I sat down to read it with high expectations. The artwork is colorful, the framing dramatic, the themes enduring, and the story itself mildly interesting. But it just didn’t grab me like some books do. I found myself bored by the graphic-novel-within-a-novel, which takes up substantial page space but somehow never integrates into the main storyline. Even though I knew about its self-aware intentions, the thin characters and wild violence and abundance of detail just left me limp.

I guess I just don’t like graphic novels; Maus must’ve been the anomaly. I’ll probably give Persepolis a read at some point, but otherwise, I’ll stick to plain old boring words and the occasional Sunday funnies.



On the bright side

October 15th, 2008   Filed Under news, politics  

At least the 10% of my 401k that I lost today is not as much as the 10% I lost yesterday.

As a side note, it is interesting that the stock market performs better and with less volatility during Democratic presidencies:

Using the Dow Jones industrial average as the benchmark, Stock Trader’s Almanac shows a $10,000 investment compounded during Democratic presidencies since 1901 would be worth $279,705 after 48 years. The same $10,000 investment during 56 Republican years would have been worth just $78,699. If you adjust for inflation, the value of a $10,000 investment under Democratic presidents is $33,426.The inflation-adjusted value under Republican presidents is $26,145.



President Palin Bumper Stickers

September 18th, 2008   Filed Under politics  

The very idea of Sarah Palin being President of the United States (POTUS) scares the piss out of me. It’s not just her take on the issues (well, the ones she’s actually thought about) and her ignorance and her appalling lack of experience–though they should be enough to disturb any conscious American who cares about their country. But her brazen disregard for some basic principles of democracy has left me dumbfounded. Trying to ban books from the library, and firing the librarian who wouldn’t? You can hardly make this stuff up.

So I got inspired to spread the message, both about Sarah’s Scandals and the horror that may soon be her presidency. (Do you really think McCain will live long enough to become a Maverick again?) I found zazzle.com and went on a tear.

The great thing about bumper stickers written in the future satirical tense is that if the unthinkable comes true, they actually become more stylish. At least until President Palin signs the Protect America First Act into law, which bans any bumper stickers which do not contain a Pro-Palin message.

Share and enjoy!



Youtube to MP3 Converter

August 19th, 2008   Filed Under code, portfolio, projects  

My mom found some of her favorite music on Youtube. She’s been looking for some of these songs for a long time, and now that she’s found them, she’s scared that Youtube will pull them and then she won’t have them again. She wants to download them so she can listen to them whenever she wants. The CDs are out of print. There are several torrents of this artist’s music that were around in 2006, but now they have 0 seeders (and 3 leechers). legalsounds.com has them for 10 cents apiece, but I cautioned her against giving her CC number to the Russians.

I know the quality of audio on Youtube is pretty bad, but she doesn’t care. She’s excited that she can finally listen to these songs again, and she’d be content with just having an mp3 constructed from the Youtube videos. In fact, she’d be ecstatic.

How hard can this be? I’m learning some jQuery myself–it’s all the rage, what with the mashups and the AJAX–and I thought I could make a simple client-side webpage that AT LEAST just gets at a user’s favorites from youtube and prints the URLs of each .flv for download. Youtube has a nice little API, you just GET from a sensible URL, and it returns XML. jQuery has some nice functionality to get elements from the XML and I would just add a few rows a table with the right information. No problems anticipated.
[More...]