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:
- If the number of mines indicated by this square is equal to the number of neighboring mines already flagged, clear any uncleared/unflagged neighbors.
- 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.
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...]