Python integration?

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Do we want Python integration?

Yes, and expose nearly everything(UI,Empire,Universe,AI)
7
32%
Yes, but only expose specific parts
8
36%
No, we'll not need it for a looong time
0
No votes
No, we probably never need it
6
27%
I couldn't care less
1
5%
 
Total votes: 22

Message
Author
Tyreth
FreeOrion Lead Emeritus
Posts: 885
Joined: Thu Jun 26, 2003 6:23 am
Location: Australia

#31 Post by Tyreth »

I remember oceanmachine mentioned he had troubles that sound the same as yours, he couldn't get it to work either.

drekmonger
Space Kraken
Posts: 146
Joined: Mon Jul 07, 2003 10:17 am

#32 Post by drekmonger »

hrmpf,

come to think of it...why bother with python at all? FreeOrion doesn't have need for 90% of the features python offers.

Why not embedded something like Small or Lua? I'm looking at Lua now, and the bindings look a hellavlot simpler. (plus there wouldn't be as much memory or processor overhead.)

http://lua-users.org/wiki/SimplerCppBinding

tsev
Space Kraken
Posts: 167
Joined: Thu Jun 26, 2003 2:17 pm
Location: Pittsburgh, PA

#33 Post by tsev »

drekmonger wrote:hrmpf,

come to think of it...why bother with python at all? FreeOrion doesn't have need for 90% of the features python offers.

Why not embedded something like Small or Lua? I'm looking at Lua now, and the bindings look a hellavlot simpler. (plus there wouldn't be as much memory or processor overhead.)
:roll: or we could just write simple scripting functionality using XML.

it makes sense if we don't need the advanced features of python.
FreeOrion Programmer

drekmonger
Space Kraken
Posts: 146
Joined: Mon Jul 07, 2003 10:17 am

#34 Post by drekmonger »

I'm thinking in terms of AI scripts, plus maybe galaxy generation and event scripts (for a GC mod).

On second thought though, Lua doesn't seem any easier than python. It's simpler than the Python C API, but if someone can get boost.python to work, that would be the easiest route.

Yoghurt
Programmer
Posts: 376
Joined: Sat Jun 28, 2003 8:17 pm
Location: Heidelberg, Germany

#35 Post by Yoghurt »

drekmonger wrote:On second thought though, Lua doesn't seem any easier than python. It's simpler than the Python C API, but if someone can get boost.python to work, that would be the easiest route.
I'm already working on this Python thing, as posted on Monday. I propose we postpone the pro and contra of using Python till the first prototype arrives. If someone wants to help me, just drop me a line.

tsev
Space Kraken
Posts: 167
Joined: Thu Jun 26, 2003 2:17 pm
Location: Pittsburgh, PA

#36 Post by tsev »

This is about 50% off-topic....

At work I've just integrated Python into one of the smaller programs I've been working on. I'm working in Java here and I used Jython to run scripts from files and it took about 8 minutes....you can call your class methods directly from java. It is about the coolest freakin thing I've ever seen!!

That being said.....I'm still against it for freeorion.

So far the only real use for it is that it's really cool.....but theres nothing I can think of that I'd want to use it for. Plus it is REALLY slow....and I'm just running some tiny little print statements and method calls. Now I know its Java and its going to be slow anyway....but I'd be very wary of using it in a game situation. I can certainly see it being very dangerous if we're not careful about what we encapsulate. Jython actually lets you access ALL of your native code, but it takes no effort to set up. I'm not sure how boost::python or CPython works, but I would assume there is some additions that need to be made in the code.

...but integrating python into your code is so cool....i'm going to use it in one of my personal projects just for that reason! :)
FreeOrion Programmer

Tyreth
FreeOrion Lead Emeritus
Posts: 885
Joined: Thu Jun 26, 2003 6:23 am
Location: Australia

#37 Post by Tyreth »

I still say we should wait for Yoghurt to finish his demo before a final decision :) Then we can see first hand if it will be slow in out project.

drekmonger
Space Kraken
Posts: 146
Joined: Mon Jul 07, 2003 10:17 am

#38 Post by drekmonger »

Just as an aside, check out scripting under the .NET framework. Unbelievably easy, and it compiles to (and runs on) the same CLI virtual machine as the rest of the code. Basically, scripts act almost just like any other piece of code in a project, cept it's compiled at runtime.

As creepy as microsoft's master plan for .net probably is, it's a really nice piece of technology.

Starrh
Space Squid
Posts: 55
Joined: Thu Feb 12, 2004 4:37 pm
Location: California

#39 Post by Starrh »

I may be a simpleton here and I am sure tzlaine will let me know that I am! :D All the programmers on this project have far and away more ability then me. So if I get spanked I will not take it personally I will simply view this as one more post that gets me away from Space Squid. :lol:

So on that positive note it seems to me that since you are already sending info with xml between the Client and the server. The fact that Python has the ability to parse XML and looking at your code you seem to have your AIClientApp set up to do the same thing. Why not use python in a similar way just create an object in python that checks all parameters against your XML standards as it is creating the XML file that gets sent back to your server. I am no great shakes at programing but you give me a set of parameters and I can make sure if something will pass or fail them. Granted if those parameters are hard coded into the C++ section of the code you may have to make it possible for python to see them. I am also not sure how that interferes with the whole oop concept. Ultimately in my ever so humble and ignorant opinion it seems doable. Of course after I hear you experts give me your opinion I will probably find this an idiotic concept. :D
If it was easy then we all would be doing it!

Vadus
Space Krill
Posts: 2
Joined: Wed Aug 18, 2004 12:38 pm

#40 Post by Vadus »

Hi all,

I think that you will need a python integration, because the gamers community will ask for that. Why ?
Because Civilisation 4 will come out with a python scripting ability ! It's planned to source GameRules, Maps etc. out to XML files, which will be interpreted with python.
With that, you will be able to change the hole game down to it's cpp-engine.
The possibilities are almost unlimited!
You want another fighting system? just do it !
Trigger/Events in a Scenario ? No problem !
This will be at least a great gift for the modders community.
And you know, that most civ players are playing also turn based space strategy like Moo and FO in future , and the other way round!
And such a ability to mod a game could be an example to other similar games ;)

noelte
Juggernaut
Posts: 872
Joined: Fri Dec 26, 2003 12:42 pm
Location: Germany, Berlin

#41 Post by noelte »

Vadus wrote:I think that you will need a python integration, because the gamers community will ask for that. Why ?
Already on the way.
Press any key to continue or any other key to cancel.
Can COWs fly?

Yoghurt
Programmer
Posts: 376
Joined: Sat Jun 28, 2003 8:17 pm
Location: Heidelberg, Germany

#42 Post by Yoghurt »

noelte wrote:Already on the way.
Will probably be finished 2 weeks after "Duke Nukem Forever" ;)

noelte
Juggernaut
Posts: 872
Joined: Fri Dec 26, 2003 12:42 pm
Location: Germany, Berlin

#43 Post by noelte »

Yoghurt wrote:
noelte wrote:Already on the way.
Will probably be finished 2 weeks after "Duke Nukem Forever" ;)
Hehe, i thought you were on it and 40% through. :-)
Press any key to continue or any other key to cancel.
Can COWs fly?

Yoghurt
Programmer
Posts: 376
Joined: Sat Jun 28, 2003 8:17 pm
Location: Heidelberg, Germany

#44 Post by Yoghurt »

Yes, but don't forget that the last 10% take 90% of the time ;)

Marijn
Space Squid
Posts: 65
Joined: Thu Feb 19, 2004 10:26 am
Location: Nijmegen (NL)

#45 Post by Marijn »

I think the idea of using an embedded scripting language would have been much more viable if it had been there from the start and almost all game-related things would have been programmed in the scripting language, with the C++ system providing just a basic environment. I do not see the problem people have with the client containing python, if the multiplayer communication model is any good this will not make cheating any easier than it would be otherwise. But python was not embedded from the start, half the game has been written in C++ already, so this point is irrelevant.

Having half the game implemented in C++ and half of it in python seems somewhat inconsistent and messy to me. It kind of obscures the distinction of who is responsible for what, which will not make debugging easier. I do like the suggestion someone made of writing the AI logic in python. This is a clearly separate module from the rest of the game and a module where easy tweaking will be very useful. If you can come up with a good interface between the AI logic and the underlying game this would be very powerful.

Post Reply