TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.18k stars 382 forks source link

Python support? #1243

Open twoATOMS opened 6 years ago

twoATOMS commented 6 years ago

tl;dr for future humans: There is no change to Python scripting support, it's still not planned. You have the choice of Lua scripting or compiling C# to CIL which you then add into EmuHawk dynamically. That said, the community have created ways to use Python scripting with a C# shim.

On the subject of ML specifically, don't bother with Lua, either use ML.NET, or exfiltrate the data to something like TensorFlow (Python). There are a few ML hackers in the ApiHawk Discord server if you're interested in the latest and greatest.

Original inquiry follows.


Hello guys, I have a question about the emulator. I am trying to learn Machine Learning and want to apply it to video games, however I only know Python2.7 as a programming language and I was wondering if BizHawk will ever have Python scripting support in the near future?

Thanks.

vadosnaprimer commented 6 years ago

Clearly not in the "near future". Dunno about "ever" - maybe?

spiiin commented 6 years ago

@twoATOMS You might want to check out Nintaco (http://nintaco.com/api.html). It provides programmatic control using C, C#, Java, Lua and Python.

g0me3 commented 6 years ago

maybe first you may try Man Learning? maybe learn lua or something to begin with learning the machines lol

YoshiRulz commented 5 years ago

see also previous rejection of Python #707

vadosnaprimer commented 5 years ago

Right, recently we had a talk, and if someone makes a PR, we'll most likely accept it.

To actually throw something on the table, here's the approach that looks very promising: http://tasvideos.org/Feos/CallingCSharpMethodsFromPython.html You expose the methods from C#, have a C# Python interpreter, and then Python scripts just call those methods dynamically. Bonus points if it can be done using the newly updated APIHawk.

spiiin commented 5 years ago

It's not very hard to implement lua server, and connect to it from ANY language via sockets. Example for fceux emulator: https://github.com/spiiin/fceux_luaserver

vadosnaprimer commented 5 years ago

Yeah, this dynamic approach should also allow any language with C# bindings to use those functions.

Warepire commented 5 years ago

Clarification, the PythonNET module is a module for the python interpreter which allows for calling dynamic-exposed objects in C#.

Which means that in theory, you should be able to use any interpreter you want, as long as the interpreter can load aforementioned module.

elcolie commented 4 years ago

+1 on Python websocket support for Machine Learning. Then with Dockerfile will be great! I will make an article for building this. Can anyone here guide me through this?

YoshiRulz commented 4 years ago

Several people have suggested and ML project using BizHawk, so I'm writing this out to save repeating myself: The easiest way to get memory access and playback controls is with an external tool. You could use Lua to bridge to another process, but it'll be slower. External tools need to be in C# (or, maybe, F# or VB). The library you'll use will probably be ML.NET what with Microsoft throwing money at it. For completeness, you could use C# instead of Lua to bridge to another process. I imagine that even calling into C from C# would be slower than a pure C# solution. edit: Less sure about this, especially if you're running under Mono.

I'm personally willing to help anyone with the implementation of an external tool (I don't know much about ML, sorry). So, @elcolie, if you know that it's going to be annoying and still want to try, I'm on IRC and Matrix.

elcolie commented 4 years ago

Thank you @YoshiRulz I will learn the material and when I am ready I will contact you 🙏

magnusjjj commented 3 years ago

Time to be annoying and necro a thread: https://github.com/magnusjjj/FakeControllerDesu

Rudimentary python support, at least for the restart function ;). I am looking for testers, to make sure that it's reasonably stable for other people to, well, I guess toy with.