Script engine speed
by Galavm Shot · in Torque Game Engine · 07/06/2004 (8:56 am) · 7 replies
Hi to all
I bought the TGE and i began study some engine parts. I found the scripting implementation of the 3D math - it was a little pain to see all the time sprintf.
I am wondering is it possible to detach the AI Part of the scripting engine and "port" it to other scripting engine (i though to use gecko - not a script engine, just clear C++). So, in this way current script will load and initilise all resources, after that it will switch to "another engine" for the gameplay and AI. My question is how hard is to replace the AI part with another one?
I am really interested in that, i would like to do it and to send the result back to the community, any help is welcome.
Best regards, twoflower
I bought the TGE and i began study some engine parts. I found the scripting implementation of the 3D math - it was a little pain to see all the time sprintf.
I am wondering is it possible to detach the AI Part of the scripting engine and "port" it to other scripting engine (i though to use gecko - not a script engine, just clear C++). So, in this way current script will load and initilise all resources, after that it will switch to "another engine" for the gameplay and AI. My question is how hard is to replace the AI part with another one?
I am really interested in that, i would like to do it and to send the result back to the community, any help is welcome.
Best regards, twoflower
About the author
#2
sprintf and sscanf aren't all very bad for performance. Ever done any benchmarks? You're likely to spend more time on a single GL call than on a printf. :)
07/06/2004 (10:14 am)
Josh Ritter already did this with Python, actually - you might want to check that out.sprintf and sscanf aren't all very bad for performance. Ever done any benchmarks? You're likely to spend more time on a single GL call than on a printf. :)
#3
07/06/2004 (10:44 am)
I will check the speed of the string manipulation functions. I hope you are right (in fact i prefer to work on my game, not in the scripting engine).
#4
07/06/2004 (3:07 pm)
I know that there are at least a dozen professional games that use TorqueScript and none of them were bound by scripting engine performance... Tribes2 is the biggest example but there are many others.
#5
Doing a few math operations in script is fine for something that is getting called once every few frames. But if you're doing a lot of calculations per frame, then it's best to write a C++ implementation and expose that to Torque Script.
07/06/2004 (4:45 pm)
From my (very informal) tests so far, Torque Script is indeed fast enough. If something is too slow, then I'd do as Paul suggests and look about re-structuring your algorithm. Doing a few math operations in script is fine for something that is getting called once every few frames. But if you're doing a lot of calculations per frame, then it's best to write a C++ implementation and expose that to Torque Script.
#6
07/06/2004 (9:32 pm)
A rule of thumb: If script code is showing up in your profiles then you're probably doing something wrong.
#7
07/06/2004 (11:44 pm)
Thank you for your answers. You are right the C++ implementation is the best solution for a lot of math calculations.
Associate Paul Dana
Perhaps you need to elaborate more on the benefits you think you would gain by doign this?
If you are worried about optimization then you can just take larger parts of what is done in the AI script code and move it into C++ instead...no need for a separate game or engine just replace stuff that is in script with C++ code.