Fractal eXtremePapers

Game Scripting in Python

other papers...

This paper was presented at the 2002 Game Developers Conference.

The PowerPoint presentation and the paper in MS Word format can be obtained here.

A sample build script - including e-mailing a simple report on errors - can be found here. Full error parsing still needs to be added.

Watch for more information - including more sample Python scripts - to be posted here in the future.

The updated list of games that use Python is:

  • Freedom Force
  • ToonTown
  • EveOnline
  • Blade of Darkness
  • Cars with Guns
  • Frequency (PS2)
  • Game Blender (game engine)
  • PyGame (game engine)
  • MindLathe (AI middleware)
  • All future Humongous PC games

Let me know if you have any experiences to share with Python in games, the HAP Debugger for Python, or anything else that seems relevant.

Correction: Terry Reedy pointed out an error in my paper where I overstated the performance implications of using Python. I'll let him explain my error:

This article is one of the best promotional blurbs for Python I have read. Nothing like actual, positive experience truthfully reported without exageration. There is one minor error that might affect your coding (as well as your readers). You wrote

"
Performance

If you write Python code to do some heavy floating point work and then compare the results to C++ you will be disappointed. Python is a slower language. Every variable reference is a hash table lookup, and so is every function call.
"

While Python acts as if the second line is true, local variables within functions are currently, as a hidden optimization, looked up by index in a fixed-length hidden array. (Exception: you put something like 'from module import *' within a function so the compiler can't know what the run-time vars are.) Consequently, a particular chunk of code may run faster within a function than at top level. Also, code within a function may run faster by creating a local reference (alias) to global or builtin var or class members. While the effect on a single lookup is too miniscule to worry about routinely, lookups within a large repetition loop may benefit from this trick. Ie,

for i in range(10000): global_var(i)

might usefully be rewritten

local_alias = global_var
for i in range(10000): local_alias(i)

Thanks Terry for the correction and the nice comments.

Please contact me if you have any questions. Let me know if you find this information useful.

Bored with reading these technical papers? Go check out my cool fractal exploration program for Win32.

other papers...

Why Buy FX? | Download Area | How to Buy FX | The Gallery
Fractal Theory | Comments Area | Company Profile | Tips & Tricks
Main Page | Links | Send Mail
Copyright © 1997 Cygnus Software. All rights reserved.