AI Bot Plays Castlevania So You Don’t Have to

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.

10 thoughts on “AI Bot Plays Castlevania So You Don’t Have to

  1. It’s sort of a semi automated TAS approach but with extremely game specific abilities. Reminds me a bit of other contemporary approaches to more general purpose game playing AI research. Not sure it is capable of actually beating human created TAS runs at present though maybe it could do so with further development?

    1. The write-up says the ‘bot was specifically designed to not play optimally, because that’s less interesting to someone watching.

      The same sort of difference as TAS “minimal %, no glitches” runs vs TAS “playarounds”

      1. It does seem fairly clear that the current form and goal of this software is not to beat TAS speedruns. Curious if it would be able to do so if it was further developed? It’s an oddly specific program but it might actually wind up beating the current TAS record of 11:15.11. Seems somewhat unlikely though that it would be easily capable of figuring out bugs and other things like luck manipulation though?

        http://tasvideos.org/3780M.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.