Page 3 of 3

Re: Potential replacement of FOCS with Python

Posted: Sun May 31, 2020 6:57 pm
by Ophiuchus
Geoff the Medio wrote: Sun May 31, 2020 2:41 pm
Ophiuchus wrote: Sun May 31, 2020 2:11 pmI am interested in creating the c++ building types/species... via python. So it seems that is currently not possible.

Does any of you pythonistas have experience with creating c data structures from python? Or would i need to provide an api like we have and expose that?
Even if there was a way to create the C++ data structures in Python, similar to how they are created when parsing FOCS files, you'd need to then pass them into the server and clients, either sending them from server to clients or ensuring they are created the same way on both. You'd need some sort of API exposed to do that regardless.
Ah i thought it could be possible to invoke the python interpreter from inside the c++ program. Maybe having an API makes more sense regardless.

Re: Potential replacement of FOCS with Python

Posted: Sun May 31, 2020 6:59 pm
by o01eg
Ophiuchus wrote: Sun May 31, 2020 6:57 pm
Geoff the Medio wrote: Sun May 31, 2020 2:41 pm
Ophiuchus wrote: Sun May 31, 2020 2:11 pmI am interested in creating the c++ building types/species... via python. So it seems that is currently not possible.

Does any of you pythonistas have experience with creating c data structures from python? Or would i need to provide an api like we have and expose that?
Even if there was a way to create the C++ data structures in Python, similar to how they are created when parsing FOCS files, you'd need to then pass them into the server and clients, either sending them from server to clients or ensuring they are created the same way on both. You'd need some sort of API exposed to do that regardless.
Ah i thought it could be possible to invoke the python interpreter from inside the c++ program. Maybe having an API makes more sense regardless.
It is done with boost-python

Re: Potential replacement of FOCS with Python

Posted: Sun May 31, 2020 7:50 pm
by Geoff the Medio
Ophiuchus wrote: Sun May 31, 2020 6:57 pmAh i thought it could be possible to invoke the python interpreter from inside the c++ program. Maybe having an API makes more sense regardless.
It is possible for C++ to execute Python scripts. But for the Python code to access gamestate or scripted content, or to communicate back into C++ code directly at runtime, it needs an API. Such an API exists for turn events and order issuing, but not for content generation.

Re: Potential replacement of FOCS with Python

Posted: Thu Jun 04, 2020 7:59 pm
by adrian_broher
Geoff the Medio wrote: Sun May 31, 2020 10:14 am -How can you use Python right now to define stuff like building types or species? You can't. Such a system doesn't exist.
The Python bindings to game entity descriptions like ShipHull, ShipPart, BuildingType exist, but are not complete, mostly read only and the binding is configured to not allow instantiation of those game entity descriptions. There is also no API to register those entity descriptions into the currently running game.

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 10:32 am
by ThinkSome
Python is hard to cross-compile, I'd rather see FOCS replaced with Lua.

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 11:06 am
by Ophiuchus
ThinkSome wrote: Fri Jun 05, 2020 10:32 am Python is hard to cross-compile, I'd rather see FOCS replaced with Lua.
Sure, go for it :lol:

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 12:17 pm
by em3
ThinkSome wrote: Fri Jun 05, 2020 10:32 am Python is hard to cross-compile, I'd rather see FOCS replaced with Lua.
Why would you want to cross-compile? The code could be compiled as part of installation process or on the first run.

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 1:46 pm
by o01eg
ThinkSome wrote: Fri Jun 05, 2020 10:32 am Python is hard to cross-compile, I'd rather see FOCS replaced with Lua.
I cross-compiled it for Android and even cross-compiled boost with python support.

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 2:59 pm
by ThinkSome
o01eg wrote: Fri Jun 05, 2020 1:46 pm
ThinkSome wrote: Fri Jun 05, 2020 10:32 am Python is hard to cross-compile, I'd rather see FOCS replaced with Lua.
I cross-compiled it for Android and even cross-compiled boost with python support.
Then you are welcome to join the effort at MXE. Multiple people so far have told me that Python is hard to cross compile and that being the reason why MXE lacks Python support. The only Python-for-MXE project I had found, has heavily patched python 3.3 and even that is broken. It took me some time (and patching) to cross compile boost-python with it and the end result is not very usable for building Freeorion.

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 4:04 pm
by o01eg
ThinkSome wrote: Fri Jun 05, 2020 2:59 pm Then you are welcome to join the effort at MXE. Multiple people so far have told me that Python is hard to cross compile and that being the reason why MXE lacks Python support. The only Python-for-MXE project I had found, has heavily patched python 3.3 and even that is broken. It took me some time (and patching) to cross compile boost-python with it and the end result is not very usable for building Freeorion.
Could you try this project? https://github.com/python-cmake-buildsy ... ildsystem/

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 4:24 pm
by Oberlus
Don't feed the troll (even if it is not malicious), you will only get to pollute the thread.

Re: Potential replacement of FOCS with Python

Posted: Fri Jun 05, 2020 4:48 pm
by ThinkSome
o01eg wrote: Fri Jun 05, 2020 4:04 pm Could you try this project? https://github.com/python-cmake-buildsy ... ildsystem/
I will, thank you.