Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Game Scripting With Python 186

P. Staurou writes "There is very interesting article about game scripting with Python over at Sylphis3d.com. It talks about how game engines should be structured as operating systems with actors being the processes. The proposed design is based on a special version of Python called Stackless and already successfully implemented in their own Sylphis3D game engine."
This discussion has been archived. No new comments can be posted.

Game Scripting With Python

Comments Filter:
  • Civilization 4... (Score:5, Interesting)

    by Fortress ( 763470 ) on Saturday September 17, 2005 @08:13PM (#13587317) Homepage
    ..supposedly will use Python scripts for most of the AI behaviour. It's supposedly the most easily and thoroughly modifiable game ever. I can't wait to see what the community produces. In fact, I'd say that the developers will incorporate user-generated content in the official patch system.
  • by putko ( 753330 ) on Saturday September 17, 2005 @08:48PM (#13587436) Homepage Journal
    Naughty Dog (JAK) used scheme for this. The guy in charge is from MIT, so he's a lisp/scheme hacker.

    They had Franz lisp make it for them -- this I found out at gamasutra.com

    I think the only big deal about this is that they use Python, as opposed to some other language.
  • by indy ( 23876 ) on Saturday September 17, 2005 @09:10PM (#13587486)

    TFA is talking about the use of coroutines to avoid programming state machines. Coroutines are really very useful, as they allow code as simple as the following:

    void Airplane::flyLooping() {
        levelOut();
        centerStick();
        pullElevator();
        while(!flyingUpsideDown())
            yield();
        while(flyingUpsideDown())
            yield();
        centerStick();
        levelOut();
    }
    The code, which is supposed to make an airplane actor fly a looping maneuvre, is much simpler than the corresponding state machine code, which would consist of four states. I used this sort of programming in my hobby flightsim project Thunder&Lightning [tnlgame.net] using this [ds9a.nl] C++ implementation of coroutines. There is also Io [iolanguage.com], an embeddable language with a very small footprint which is easy to learn and nice to program with and which supports coroutines as well (actors in Io's terminology).
  • Oooh! (Score:2, Interesting)

    by keesh ( 202812 ) on Saturday September 17, 2005 @09:24PM (#13587530) Homepage
    So now as well as having to buy faster graphics cards, we'll have to buy faster CPUs to cope with Python's "Oh shit, you seriously want me to call a function? Woah. Hang on a minute..." feature? I'm all for open source, but Python's fucked up hash tables implementation is a perfect example of how more eyes won't get around to fixing things if they're not looking in the right places...
  • by Anonymous Coward on Saturday September 17, 2005 @09:24PM (#13587531)
    As part of Google's Summer of Code, someone with much code-fu has released the initial version of a Python-to-C++ converter.

    Check it out:

    http://shed-skin.blogspot.com/ [blogspot.com]

    http://sourceforge.net/projects/shedskin/ [sourceforge.net]
  • by gsherman ( 30609 ) on Saturday September 17, 2005 @10:24PM (#13587704) Homepage

    Last weekend I pulled in the latest Python (2.4.1) for Winblows, the Ogre 3D engine binary , and PyOgre (http://www.ogre3d.org/index.php?option=com_remosi tory&Itemid=57&func=selectcat&cat=1 [ogre3d.org]).

    This combo rocks fairly hard.

    Run a 27 line Python script, and boom, you're looking at a working 3d engine. It's fast, too, probably because the heavy lifting is being done in the Ogre runtime binaries.

    For developing and prototyping, there's no time wasted (re)compiling changes; tweak some Python and away you go. And there's no reason the code or scene objects can't be tweaked while the engine is running, perhaps by means of a some sort of IPC, whether it's via a telnet/socket-type connection, or an XML-RPC daemon process, or whatever. Some people have even worked up demo on-screen overlays akin to the Quake console.

    I'm looking forward to the day I can interact with a 3D environment and manipulate 3D objects with the same immediacy I'm accustomed to manipulating data in the Python interactive prompt. Heck, I'd even learn Smalltalk if they plugged Ogre directly into something like Squeak. But for now, Python + Ogre (PyOgre) seems to show a lot of promise.

  • by Radius9 ( 588130 ) on Saturday September 17, 2005 @10:38PM (#13587741)
    Having worked on game consoles for years, and having worked on several games using both Python and LUA, I strongly disagree with your statement. I find both languages terrible for console development.

    Although Lua didn't use much memory, I found it allocated and freed lots of memory. Lots and lots of it. This had the nasty side effect of fragmenting memory to all hell. This can be fixed by giving it its own stack, but its still an issue, especially if the LUA calls out to something that needs to allocate memory. It can get very nasty, very quickly. In addition, I found the language syntax to be fairly poor, I mean it was designed with configuration files in mind, and so it works great for configuration files, but it syntactically didn't fit with most of the AI we wanted to do. We just ended up calling C most of the time anyhow. On top of that, the use of LUA meant we didn't have a decent debugger (if any), which meant tracking down crashes and bugs was an adventure in tedium, using lots of printfs.

    Python was a language better suited to Game AI, but once again, memory fragmentation was a big big issue. In addition, it was fairly slow and tended to access lots of memory, which killed the cache on most of the consoles nicely.

    Overall, with all the performance considerations aside, I found the choice of Python and LUA to be poor mainly because they didn't solve the problem that they meant to address. One of the big things that everyone wants is non-programmers being able to edit game behavior. Both Python and LUA may seem easy to those of us who code, but it is incredibly difficult for most game designers, as most of them can not code at all. Generally, in the course of development, there isn't time or motivation for people to learn how to do many new things, and so the programmers end up doing most of the scripting. Once the programmers are doing the scripting anyhow, you may as well do it in C or C++, as you'll have better development tools. The other big argument I hear is that you can update AI in realtime, which sounds great, but in practice, is much more difficult to do than it sounds. If you are going to add scripting for this feature, then make sure if you can't implement the feature, then remove the scripting. You'll save yourself a ton of trouble. Anyhow, I'm sure lots of people will post examples of projects that succesfully used these scripting languages, and I'm sure there are some, but it certainly hasn't for any of the console based projects I've worked. Which isn't to say there aren't scripting style solutions that do work, I've seen them work and am a big proponent of them, but I haven't seen any that worked with a general-purpose scripting language. Remember, there is a price to be paid for it being general purpose, and if you have a specific purpose in mind, that price can be very high.
  • Comment removed (Score:2, Interesting)

    by account_deleted ( 4530225 ) on Sunday September 18, 2005 @01:06AM (#13588130)
    Comment removed based on user account deletion
  • by m50d ( 797211 ) on Sunday September 18, 2005 @06:30AM (#13588798) Homepage Journal
    Either I forgot to do something on my system, or Python is, in my experience, unreliable at best.

    You did something wrong. Python works perfectly on my system.

    Most Linux programs that utilize Python that I've downloaded, didn't work; there's usually a missing, necessary Python module the program needs which either requires downloading from an obscure site or doesn't seem to exist at all from Google searches,

    Most C/C++ programs have a missing library which requires the same steps. Your package manager ought to handle it.

    or even with names that seem they ought already be included (like a module named "os" from a Python-using music tracker program I tried to run).

    If you're missing the os module your python install is majorly broken.

Suggest you just sit there and wait till life gets easier.

Working...