NES emulator with API/scripting support

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
andrepd
Posts: 2
Joined: Tue Apr 19, 2016 4:45 pm

NES emulator with API/scripting support

Post by andrepd »

Hi. I was hoping to try my hand at writing a machine learning bot to play through Super Mario Bros (sort of what SethBling did in his popular video: https://www.youtube.com/watch?v=qv6UVOQ0F44). To do that I need an emulator that has some sort of API that I can access (preferrably C, C++ or Python) to read memory, send input, and control emulation start/pause.

I was looking into BizHawk but it only seems to have Lua support, and I'm totally unfamiliar with the language. I would prefer to work with Python or C or C++. Are there any other emulators our there that have this API I am looking for? Thanks!
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NES emulator with API/scripting support

Post by rainwarrior »

FCEUX also has Lua support.

If you want a C++ interface to an emulator, though, why not just get the source code and work with that?
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NES emulator with API/scripting support

Post by koitsu »

If you can code in C and/or C++, you can code in Lua. The learning curve will not be steep. It's one of a very few number of "recent-ish" programming languages which I actually like and endorse for that exact reason (in addition to it's incredibly small footprint). If you prefer books on PLs, I can personally recommend Programming in Lua by Roberto Ierusalimschy. Other Lua books are so-so compared to this, IMO.

Otherwise, I second rainwarrior's recommendation/question. There are a ridiculous number of NES emulators you could tinker with. There won't be an "API" in most cases though, at least not in the way (I think) you mean; in other words, you get to reverse-engineer the code and modify it to do what you want/need.
andrepd
Posts: 2
Joined: Tue Apr 19, 2016 4:45 pm

Re: NES emulator with API/scripting support

Post by andrepd »

Thanks for the suggestions, I've actually been looking into the fceux source code to see if I can put together a more or less nice interface to do what I want. I am very unwilling to use Lua because is slow and not really suited to what I want to do. I would very much rather just program in C++
adam_smasher
Posts: 271
Joined: Sun Mar 27, 2011 10:49 am
Location: Victoria, BC

Re: NES emulator with API/scripting support

Post by adam_smasher »

If you're concerned about speed your desire to use Python over Lua makes exactly zero sense; Lua is in the same general performance class as Python.

Also, if the issue is speed, and you really want to use C/C++, you can write your core logic in it and use Lua to glue it to an emulator with an existing scripting interface. Lua's C interface is incredibly simple; the language was designed to be glue.
Post Reply