Food for Thought

Consider two items: a tube of toothpaste, and a bag of spinach.

Which one could potentially pose a hazard?

Which one are you not allowed to take on a plane?

Comments Off

Commuting

Here’s a pop quiz for all of you out there who drive a motor vehicle:

Suppose you are driving on the highway, and your car is in the rightmost lane of a two-lane offramp, on which the prevailing traffic is moving at near-highway speed. True or false: it is an acceptable maneuver to slam on your brakes, cut off the person driving in the left lane of the offramp, slam on your breaks even more, and then cut over to the wedge between the offramp and the main highway and come to a complete stop.

If you answered “false,” congratulations, there’s a good chance you’re not a danger to yourself and others! If you answered “true,” thanks for that little bit of excitement this morning on my way to work, moron. You better thank my reaction time and brake pads that I didn’t rear-end you during your little maneuver, just as I thank the reaction time and brake pads of the person driving behind me that they didn’t rear-end me when I had to slam on my brakes to avoid you.

Comments Off

Avast!

Aye, today be Talk Like A Pirate Day!

If ye land lubbers and bilge rats not be understandin’ how to talk like a pirate, here be a training video I plundered from YeTube:

And if that tharrr instruction be goin in one ear and out ye bilge hole, here be an example:

4|-|0′/, /\/\47135! 1 b3 L00|<1|\|’ 70 d0\/\/|\|L04D 4 (0P’/ 0Ph 74LL4D394 |\|19|-|75. |\|0\/\/ |\|0R/\/\4LL’/ 1′D b3 45|<1|\|9 1|\| ‘/3 1R( (|-|4|\||\|3L, bU7 ‘/3 5(UR\/’/ 0P5 /\/\4D3 /\/\3 \/\/4L|< 7|-|3 pL4|\||< Ph0R |\|07 0PhPh3R1|\|’ 4|\|’/ 0Ph /\/\3 0\/\/|\| b007′/ 1|\| 3><(|-|4|\|93.

And remember, this best be the keyboard ye be usin’ today, else ye be walkin’ the plank!

Pirate Keyboarrrrrrrrd!

Avi Rubin’s day at the polls

Voting expert Avi Rubin writes about working as an election judge in this past week’s primary election. Just in case you still had a shred of confidence in Diebold.

Comments Off

Disenfranchised

Two strikes against Maryland elections:

  1. Only voters who declared a party affiliation on their voter registration form are allowed to vote in primaries. (What’s your excuse for not voting today?)
  2. Maryland uses Diebold voting machines anyway, so it’s not like there’s any assurance the votes wouldn’t be tampered with anyway.
Comments Off

Breaking the Weirdness Barrier

In our last installment, it was found that Japanese cartoons are weird, man. But being ever the scientist at heart, I was left with a question: just how weird can they get? Do they approach some weirdness asymptote as you get farther out, or is the weirdness unbounded? Does the knob only go to 11? Inquiring minds want to know!

I think I found the answer by watching Puni Puni Poemy, a spin-off of Excel Saga made by the same group of people. So right there, you know going into it that it’s going to be weird. But unlike its predecessor, Puni Puni Poemy blows right through mere Weird all the way to Seriously Messed Up, with a generous helping of Just Plain Wrong on the side.

You see, there’s nothing deep or meaningful about Puni Puni Poemy, no real story or significance behind it; it’s just two half-hour episodes’ worth of sheer, unabashed, frantic, no-holds-barred weirdness for the sake of being weird. And it does an outstanding job at doing so.

Allow me to give you a taste of what lurks within Puni Puni Poemy. I suppose what follows could be considered spoilers, but nobody in their right mind would watch it for the plot anyway. (You could also argue that nobody in their right mind would watch it, period.) Those who wish to keep their sanity may want to skip the next few paragraphs.

At its heart, Puni Puni Poemy is a send-up of magical girl anime, though it most certainly not geared for, let alone appropriate for, kids. Its main character is Poemy Watanabe, daughter of Nabeshin and Kumi-Kumi (aka Soup Girl), both reprising their roles from Excel Saga. Poemy can transform into magical girl Puni Puni Poemy by gutting a fish (yes, with a knife), even though she prefers just punching her enemies rather than actually using magic-type stuff, but what she really wants to be is a voice actress. However, she can’t even stay in character — she always refers to Nabeshin as “Director” (which he is) and often refers to herself in the third person as Kobayashi, the name of her character’s voice actress.

Following along so far? Good, because that’s the easy part.

One day, Poemy’s family is killed by Alien 1, a jive-talking alien with, um, interesting genetalia. Poemy returns home to find Nabeshin, Kumi-Kumi, and their pet AIBO all dead, in the most comical use of crucifixion since Life of Brian (with Xenogears getting an honorable mention). Orphaned, Poemy is taken in by the seven Aasu sisters, at the urging of Poemy’s friend Futaba Aasu, who really really really likes Poemy and isn’t at all subtle about it. The Aasu sisters turn out to be their own magical girl team to defend Earth, but their superpowers make Heart look useful (unless you consider “powers” like falling over without getting hurt or having the precognitive ability to sense an enemy while you’re fighting it “useful”). They also don’t much care for Puni Puni Poemy horning in on their turf, even though they don’t realize that that’s actually Poemy, and even then only because they both call themselves Kobayashi and babble about being a voice actress.

Still with me? Well, hang on.

Besides dreaming of being a voice actress, Poemy longs for K, a boy in her class who doesn’t like Poemy in the least. K, meanwhile, is actually the mastermind of an evil alien plot to ravish the planet. You see, as it turns out, the aliens’ reconnaisance of Earth consisted entirely of watching Japanese cartoon porn, and K’s species just happen to be tentacle monsters. He sends Alien 1 to kidnap the Aasu sisters (did I mention one of them works in an S&M dungeon?) and captures Poemy when she unwittingly comes to their rescue. K, of course, had previously sent Alien 1 to kill Nabeshin, so that with the Director dead, he’d be free to have his way with the show, which means having his way with the Aasu sisters, but not Poemy, because he hates voice actresses. However, Alien 1 and Alien 2 (who has twice the unusual dangly bits as Alien 1) reveal themselves to be Nabeshin and Kumi-Kumi in disguise — you see, Kumi-Kumi used her acupuncture skills to bring the two of them back to life. Out of desperation, K tries killing the Writer, but Nabeshin is such a Great Director that he can draw storyboards even without a script, and so Futuba and Puni Puni Poemy combine their powers to bring about world peace.

Like I said, Seriously Messed Up (and that’s just the abridged vesion of the “plot”) with a side of Just Plain Wrong. I now understand what this commenter meant. Heck, if you added a few frames here and there, animated the “hidden” scene where K, um, gets to work on the Aasu sisters, and edit out a certain duck that keeps getting in the way of the bath scenes, you’d pretty much turn the second episode into porn. Heck, according to Wikipedia the show is banned in New Zealand for some of what’s in the second episode (and if it’s on Wikipedia, it must be true).

Even though Puni Puni Poemy’s a spin-off of Excel Saga, there’s no real continuity between the two of them (aside from Nabeshin and Kumi-Kumi having gotten married in final scene of Excel Saga), though there’s quite a few references between them, from the overt (whenever Poemy auditions for a part, the other voice actresses are all dressed like Hyatt), to the subtle (Poemy’s middle school and Excel‘s high school are both in the Inunabe (literally, “Dog Stew”) school district), to the meta (Poemy’s voice actress also sang the opening song for Excel Saga and played wannabe pop-idol Excel Kobayashi on it), to the lazy (pretty much all of Puni Puni Poemy’s background music is lifted directly from Excel Saga).

Nevertheless, even though the premise is all messed up and the plot makes no sense, and you’ll probably be rendered incapable of rational thought after watching it, Puni Puni Poemy is surprisingly well-executed, especially for something that essentially started off as an in-joke in Excel Saga. If you can keep up with it, there’s more than enough weirdness to revel in. And even if you can’t, there’s still plenty of visual gags.

In short, as a wise man might’ve said, it’s the sort of think you’d like, if you like that sort of thing.

Just don’t let your kids watch it.

Inside the Mushroom Kingdom

I spent a ridiculous amount of time this weekend hacking on Wallace. Of course, a lot of that was due to a near-total overhaul of the earlier code, refactoring thousands of lines to make the way forward easier (since I now have a decent mental picture of what I need, instead of aping the existing FCEU code.)

Of course, that doesn’t mean refactoring was the only change since the last update. As you’ll recall, I had been using screen scraping to get information about the current state (things like score, number of lives, etc.), but along the way found it was way more complicated than I had anticipated. Plus, even Super Mario Bros. has pathological cases where screen scraping is more problematic than recognizing ten digits, as anyone who’s ever gotten more than nine extra lives can tell you.

So, screen scraping is dead and buried. (Using image recognition to detect events, however, is still there, since it’s easy to implement, easy to understand, and widely applicable.) Luckily, there’s a much richer resource for getting game information: the game’s memory itself. Naturally, in-game memory has all the information we’re likely to need, assuming we can find it, and the FCEU core’s debugging hooks lets us access it easily from code.

Ah, but how to find it? The FCEU core comes to the rescue again; part of its cheating interface lets you search game memory for interesting values. (As you may know, cheating devices like the Game Genie work by replacing values in memory; an “infinite lives” cheat, for example, just returns a constant value whenever the game looks to see how many lives are left.) Since FCEU is happy to do the heavy lifting, Wallace just has to provide a graphical interface to it.

To get an idea of how this works, let’s figure out where in memory Super Mario Bros. keeps track of the number of coins we’ve collected. We start by resetting the search, which saves a snapshot of the current contents of memory:

Before

In this example, we currently have 3 coins, and we’re about to collect 19 more. After we do so, we search for all bytes in memory that were originally “3″ but are now “22″.

After

We lucked out in this example: there’s only one byte in the address space that changed in the way we were looking for. In most cases, there’ll be some false positives, but they can be screened out by doing another search on the results.

Also, we assumed that the coin total is stored as a single byte in memory. More pathological situations are also possible, of course. For example, since the score is a six-digit number, there’s no way it can fit into a single byte (which can range only from 0 to 255), so it must be spread across multiple, presumably contiguous, bytes. Additionally, the data might not even be laid out like you’d expect a multi-byte integer to be; for example, the score in Super Mario Bros. is stored in six bytes, one byte per digit, starting with the millions digit (which only appears on screen if your score gets that high) and leaving off the ones digit (which is always 0 anyway). And, of course, endianness is also potentially an issue.

Of course, with a little trial and error, we can use the Memory Browser to find where the data we want is stored, and then extract it when we need it:

Score

Since I’m sure you’re dying to know, here’s where some interesting values can be found in Super Mario Bros.’s memory:

Data Address Format Notes
Current Score 2013 6 bytes, base 10, big-endian Multiply this by 10 to get the score
High Score 2007 6 bytes, base 10, big-endian Likewise
Coins 1886 1 byte
World 1887 1 byte Zero-based (i.e., World 1 is stored as 0)
Stage 1884 1 byte Likewise
Time Remaining 2040 3 bytes, base 10, big-endian
Lives 1882 1 byte Zero-based

So, what can we do with this? We can use the Evolver window to evaluate the fitness of an input. First, we specify our fitness function on the Fitness tab. This is mostly things we’ve seen before, just with a somewhat nicer interface. However, now a weight is associated with each metric; overall fitness is a weighted sum of all metrics.

Fitness

Next, we specify the initial conditions for our run in the Game tab:

Game

The Breeding tab will eventually be where we specify how to generate new candidate solutions in our genetic algorithm, but for the time being there’s nothing there. All we can do is do a manual test of our setup on the Population tab, where the human plays and the Evolver evaluates how well he or she does:

Playing

You’ll note that our fitness function weights world and stage much more heavily than score, as can be seen in the computed fitness value. There’s also a very heavy penalty for game over:

Over

So now, the main missing piece is the genetic algorithm.