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!
NES emulator with API/scripting support
Moderator: Moderators
- rainwarrior
- Posts: 8731
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: NES emulator with API/scripting support
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?
If you want a C++ interface to an emulator, though, why not just get the source code and work with that?
Re: NES emulator with API/scripting support
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.
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.
Re: NES emulator with API/scripting support
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++
-
- Posts: 271
- Joined: Sun Mar 27, 2011 10:49 am
- Location: Victoria, BC
Re: NES emulator with API/scripting support
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.
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.