FCEU Redux

Well, I’ve decided to give that crazy idea about using genetic algorithms to “teach” a computer to play Super Mario Bros. We’ll see how well this turns out.

The first step, of course, is to retrofit a NES emulator to be able to do the input and output manipulation I need. And being a Linux user, the best NES emulator around is FCE Ultra, even despite not having been actively maintained for quite some time. Plus, FCE Ultra has built-in support for making and playing movies (really, recording and replaying input), which should be very helpful. In fact, FCE Ultra movies are one of the preferred formats for people who do that sort of thing.

One of the few obnoxious things about FCE Ultra, however, is the utter lack of a GUI under Linux — everything is passed on the command line, and you have to remember the keys to activate the various features. That’s not quite going to cut it for my purposes.

So, the first step is to port FCE Ultra to GTK (and, to a lesser extent, GNOME). That way there’ll be a usable GUI on which to add an interface for working with the genetic algorithms (and, of course, making it easier to play around in general).

Now, I’ve had a little experience before hacking on FCE Ultra — the SDL joystick code is derived from a patch I wrote a few years back. And I remember that the FCE Ultra source code isn’t pretty to look at. The emulator’s an impressive piece of work at run-time, but the main developer really could’ve used that space bar a lot more, and one-space tabs really don’t cut it. It’s not like he used the saved space for comments or anything.

However, despite its flaws, the FCE Ultra source code does have one thing going for it: it already has a pretty good separation between the emulation code itself and the platform-specific interfaces. Sure, the “drivers” for different platforms are fairly tangled together at first glance, but it does mean that porting things to GTK is essentially just a matter of implementing a new driver and plugging it into the rest of the program. It also means that going further to shovel input in and analyze the output of the emulator should be quite doable.

So, at this point, I’m working on implementing basic GTK support into the last official release of FCE Ultra, thus familiarizing me with the ins and outs of the code and providing a friendlier interface for when I get to start working on the fun stuff.