RSS

Minesweeper Automation

October 26th, 2008

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.

On the bright side

October 15th, 2008

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

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

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...]

Sustainability MMORPG

August 17th, 2008

games, sustainability

I recently read this blog post entitled Sowing the Seeds of a Future Society (emphasis mine):

Given that I believe a major environmental crisis is unavoidable, how might we ensure that genuinely sustainable communities could become a reality? Firstly I believe we should use the most powerful tool of the current age to design exactly how future communities should look, what technologies and system of government would be most appropriate, and how to ensure that such communities remain sustainable over time. Computer games already exist which allow users to design cities and societies. It would be a relatively simple undertaking to design an on-line computer game which would allow interested parties worldwide to refine the details of exactly what such a future society should look like. Remember that if communities develop in a haphazard manner, it is likely that they will fall into many of the traps that our current society has.

This, along with my current interest in educational science games, inspires me to reimagine Spaceship Earth Beta, my ongoing imaginary platform for exploring issues and strategies of sustainability, as a massively-multiplayer computer game.

First, there must be two competing goals which different players are working towards:

  1. To develop a society proven to be sustainable over a large time-scale;
  2. To be selfish or violent or “evil”, taking advantage of loopholes for personal wealth or power or ego, which ultimately leads to making the whole society unsustainable.

The first goal must be concretely measurable. Concrete definitions of a small number of metrics must be defined such that, if they can be maintained or improved over several generations of players, they would indicate that the society as a whole is sustainable. These metrics would at least include:

Playing the game through multiple generations of players, with different personalities and each generation being more detached from the start of the project, is important; cultural values are not transmitted by default to the next generation.

The second goal, while perhaps irritating to the larger community which devotes itself to the first goal, is nonetheless vital and the players which achieve it must be revered, even as the players who attempt it must be reviled. All systems which are composed of humans with individual volition will have members who desire to destroy the system, even if they must sacrifice themselves. The system must be resilient against any single point of failure, or any small-scale collusion against it. The exile or incarceration of citizens for what amounts to this “treason” must be enforced; their murder must carry the same emotional weight as it would in reality.

I do not believe that we can plan from the outset a completely sustainable system; the “metarules” that are in existence from the outset of the project, and the texts which define its culture and values, are all we can really control, and their ramifications can only be understood from playing them out to a reasonable conclusion. Now, the results of a computer game are obviously not the same as the results of the same experiment conducted in reality. However, we can work to create and refine the starting set of metarules to have the greatest probability of success.

This simulation will have to be run many times with many different people. This makes it different from existing MMORPGs which run continuously, with game designers (”GDs”) modifying the game rules to maximize fun and membership. Many variants will be obviously flawed, others more subtly so, but they should be aborted if and when they are irretrievably broken, and the system analyzed post-mortem to find the flaws that led to its demise, and a new system started with the modified meta-rules.