We’re not allowed to have TV here in the Hackaday Wonder Bunker, but occasionally we’ll pool together the bandwidth credits they pay us in and gather ’round the old 3.5 inch TFT LCD to watch whatever Netflix assures us is 93% to our liking. That’s how we found out they’ve made a show based on, of all things, one of the Castlevania games for the NES. We wanted to play the game to understand the backstory, but since it hails from the era of gaming where primitive graphics had to be supplemented with soul-crushing difficulty, we didn’t get very far.
But thanks to a very impressive project developed by [Michael Birken] maybe we’ll have it all figured out by the time we’ve saved enough credits to watch Season 2 (no spoilers, please). The software, which he’s quick to point out is not an example of machine learning, is an attempt to condense his personal knowledge of how to play Castlevania into a plugin for the Nintaco NES emulator. The end result is CastlevaniaBot, which is capable of playing through the original Castlevania from start to finish without human intervention. You can even stop and start it at will, so it can play through the parts you don’t want to do yourself.
[Michael] started this project with a simple premise: if he could make a bot successfully navigate the many levels of Dracula’s castle, then getting it to kill a few monsters along the way should be easy enough. Accordingly, he spent a lot of time perfecting the path-finding for CastlevaniaBot, which included manually playing through the entire game in order to get an accurate map of the background images. These images were then analyzed to identify things like walls and stairs, so the bot would know where it could and couldn’t move protagonist Simon Belmont. No matter what the bot is doing during the game it always considers where it is and where it needs to be going, as there’s a time limit for each stage to contend with.
Once CastlevaniaBot knew where it was, where it was going, and how long it had to get there, [Michael] moved onto combat. Targets on screen are identified and their severity determined by checking the game’s Object Attribute Memory (a section of the NES’s video memory used to hold sprites) every frame. There are different strategies required to defeat the various creatures Simon faces in the game, and CastlevaniaBot knows them all. The bot will deploy the appropriate strategy for whatever the highest priority enemy is, while still considering the secondary targets and the ultimate goal of getting to the end of the stage before time runs out. All while the emulator runs at roughly 60 frames per second.
If all this sounds interesting to you, we recommend you read the exceptionally detailed write-up that [Michael] has prepared about the development of CastlevaniaBot and how it works as, frankly, he knows a lot more about the ins and outs of it than we ever will. Of course, if you’d rather just download CastlevaniaBot and watch it do its thing, that’s fine too.
This isn’t the first time we’ve seen somebody hack together an automated system for playing games for them, but such exploits are usually done on more recent games and systems. Like the Teensy microcontroller that will grind Zelda: Breath of the Wild minigames for you, or the button-tapping servo that dodges attacks in Final Fantasy X for the PlayStation Vita.