|Topic was automatically imported from the old Question2Answer platform.
I am a student and work on machine learning, especially reinforcement learning. I want to use Godot as environment instead of Gym (https://gym.openai.com/ ) because I want to make a little bit complex scenarios.
Is there a way to communicate Godot with a Python script? I mean, I take the screen data, some sensor datas (distance to road lines and other cars for example) from the game and process them in python script with machine learning libraries and send some actions (go ahead, steer, slow down etc.).
Thanks in advance.
There is a Python binding for Godot: GitHub - touilleMan/godot-python: Python support for Godot 🐍🐍🐍 but I don’t know if it will work with the libraries you are using.
An alternative would be to make your Python system and Godot communicate with network, shouldn’t be too bad for local use and it’s a pretty good solution to make so wildly different systems work together.
Another way is to use the C# version so you can embed IronPython and use Python under that (far fetched hehe) but similarly it might not work depending on your libraries.
Another alternative would be to do it all in GDScript or compile Godot in C++ with the libraries if they have a C API instead of Python.
Thank you Zylann!
I will consider all of them. But first and second ones seem more applicable for me =)
Parjina | 2019-08-14 15:14
Hello! I am also interested in your ideas.
I never understood what I have to do to make the python bindings work with Godot. I downloaded the bindings via the asset library, but I don’t know what to do next. Is there a tutorial?
As for the second option, I also don’t know where to start from. Is there an easy way to use high level api for network communication? I wouldn’t like to reinvent the wheel.
johnygames | 2019-08-14 18:27
I never used the Python binding, I just know it exists^^
As for the second option, you just need to be familiar with networking in Godot and Python. You’d open a socket (TCP maybe) to connect the two ends together. Either of them can be server, the other client. I’m sure Python has modules for that, and Godot has TCP classes exposed to GDScript.
Zylann | 2019-08-14 18:32
JayJay99 | 2021-07-08 15:24