Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python support? #1243

Open
twoATOMS opened this issue Jul 15, 2018 · 12 comments
Open

Python support? #1243

twoATOMS opened this issue Jul 15, 2018 · 12 comments
Labels
Meta Relating to code organisation or to things that aren't code

Comments

@twoATOMS
Copy link

twoATOMS commented Jul 15, 2018

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
Copy link
Contributor

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

@spiiin
Copy link

spiiin commented Jul 15, 2018

@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

This comment has been minimized.

@YoshiRulz YoshiRulz added the Meta Relating to code organisation or to things that aren't code label Feb 2, 2019
@YoshiRulz
Copy link
Member

see also previous rejection of Python #707

@vadosnaprimer
Copy link
Contributor

vadosnaprimer commented Feb 4, 2019

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
Copy link

spiiin commented Feb 4, 2019

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
Copy link
Contributor

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

@Warepire
Copy link

Warepire commented Feb 4, 2019

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
Copy link

elcolie commented Feb 4, 2020

+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
Copy link
Member

YoshiRulz commented Feb 4, 2020

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
Copy link

elcolie commented Feb 5, 2020

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

@magnusjjj
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta Relating to code organisation or to things that aren't code
Projects
None yet
Development

No branches or pull requests

8 participants