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.
That is really cool, Something I never would of thought to create on my own. Did he use Python?
Seems to be Java
Only part I’m not clear on: is the bot actually navigating the stages or is it basically just taking a pre-established route through the game and fighting enemies along the way?
Well, you can stop the AI, play it yourself, and restart the AI. It picks up where you left off, so doesn’t sound pre-established even if preferred.
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?
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”
TAS?
That Auction Site?
(i.e. eBay)
https://en.wikipedia.org/wiki/Tool-assisted_speedrun
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
This should have been called “CastleBotnia”