If an entire game is written in TorqueScript, ...
by Sammy · in General Discussion · 05/02/2006 (8:57 pm) · 16 replies
Hi all,
1. If an entire game is written in TorqueScript in TGE 1.4,
will the speed be very slow?
(Some doc. say that advantages of script could access all functions.)
2. Is it the fact that for fast speed, we must finally modify the source
in C++ language???
Thanks in advance
Sammy
1. If an entire game is written in TorqueScript in TGE 1.4,
will the speed be very slow?
(Some doc. say that advantages of script could access all functions.)
2. Is it the fact that for fast speed, we must finally modify the source
in C++ language???
Thanks in advance
Sammy
#2
05/03/2006 (1:51 am)
It depends just _what_ code you're talking about. Physics and other processor intensive calculations should be handled in C++. All other game logic can be handled in script. You can even prototype some complex things in script (like AI routines) where it's easier to test things, then port the script into C++ later for speed.
#3
Get everything possible running in scripts first, get it functional, measure!!! where the performance bottlenecks are and then do something about those. Re-measure so you actually see the numbers go down, and only optimize one bit at a time.
05/03/2006 (3:43 am)
The good old mantra "code first, optimize later" is still true.Get everything possible running in scripts first, get it functional, measure!!! where the performance bottlenecks are and then do something about those. Re-measure so you actually see the numbers go down, and only optimize one bit at a time.
#4
05/04/2006 (1:56 pm)
Torque script is a great way to prototype,debug, and test code.
#5
(1) Is the difference between TorqueScript and C++ great?
(2) After we finish prototype and debug a game, will it take a long time
to port to C++? In fact, TorqueScript could use all the functions (which should be
fast enough) of Torque. Will there make any difference?
Which parts are needed to be ported to C++? (eg. game logic? AI? others ?)
Or should we port the whole program?
Thanks in advance
Sammy
:)
05/17/2006 (5:41 pm)
Hi all,(1) Is the difference between TorqueScript and C++ great?
(2) After we finish prototype and debug a game, will it take a long time
to port to C++? In fact, TorqueScript could use all the functions (which should be
fast enough) of Torque. Will there make any difference?
Which parts are needed to be ported to C++? (eg. game logic? AI? others ?)
Or should we port the whole program?
Thanks in advance
Sammy
:)
#6
game logic, AI, and other higher-function but lower-frequency things are best for script.
for example stuff you do on rare events like keyboard presses or mouse clicks, or on timers.
low-level, high-frequency things, eg stuff you do every frame is best in C++.
05/17/2006 (5:46 pm)
Sammy -game logic, AI, and other higher-function but lower-frequency things are best for script.
for example stuff you do on rare events like keyboard presses or mouse clicks, or on timers.
low-level, high-frequency things, eg stuff you do every frame is best in C++.
#7
05/17/2006 (7:24 pm)
I think Orion put it very well there are some things that work well in script and some that work well in C++. You never want to be calling a function in script repeatedly too often. One things I can think of in my own game that would be better off in C++ is the AIBrain which is called every 2 seconds per AIPlayer and hits performance pretty hard.
#8
That's not a torque-thing specifically, just a common pattern.
Orion's advice is probably the best place to start. After that, profile and optimize, repeat as needed!
05/19/2006 (2:56 pm)
For script-based apps, one strategy I often hear is writting the thing in the script language, then profiling it, and accelerating the slow parts with sprinkles of C++.That's not a torque-thing specifically, just a common pattern.
Orion's advice is probably the best place to start. After that, profile and optimize, repeat as needed!
#9
Can a script language really slow down a game ?
To such extent that it can really make a difference ? not a bench test ,I mean
There are so many other bottlenecks
May be C++ is more flexible but in terms of performance...bahh
05/20/2006 (10:56 am)
Just as a gut feeling,actually I never made a comparisonCan a script language really slow down a game ?
To such extent that it can really make a difference ? not a bench test ,I mean
There are so many other bottlenecks
May be C++ is more flexible but in terms of performance...bahh
#10
Thank you for your expert advice.
As Master Treb, if I "AIBrain" should be optimized with C++,
is it difficult to do so? Do I need to understand the whole
piece source code or just change this part only???
(I have basics of turbo C++ 2.0)
Thanks in advance
Sammy
:)
05/22/2006 (7:51 pm)
Hi all,Thank you for your expert advice.
As Master Treb, if I "AIBrain" should be optimized with C++,
is it difficult to do so? Do I need to understand the whole
piece source code or just change this part only???
(I have basics of turbo C++ 2.0)
Thanks in advance
Sammy
:)
#11
Get everything possible running in scripts first, get it functional, measure!!! where the performance bottlenecks are and then do something about those. Re-measure so you actually see the numbers go down, and only optimize one bit at a time."
Silliest thing I have ever heard, no you need to be able te diffrentiate what to do in scripting and what in C++. A good thumb would be, implement game logic in script such as when the player hits spacebar you apply a force to him and when he is dead he respawns. Then implemet game engine stuff in c++ such as deform terrain, particle management and so on.
05/26/2006 (7:56 am)
"The good old mantra "code first, optimize later" is still true.Get everything possible running in scripts first, get it functional, measure!!! where the performance bottlenecks are and then do something about those. Re-measure so you actually see the numbers go down, and only optimize one bit at a time."
Silliest thing I have ever heard, no you need to be able te diffrentiate what to do in scripting and what in C++. A good thumb would be, implement game logic in script such as when the player hits spacebar you apply a force to him and when he is dead he respawns. Then implemet game engine stuff in c++ such as deform terrain, particle management and so on.
#12
C++ is much faster because it doesn't need to be processed and collected into memory. Nor does the game have to go through plenty of checks as to what the scripts are ordering it to do. Look at it this way.
This is what the game has to go through with scripts:
Starting -> Computer -> Windows/Linux/Mac -> Security -> Program -> Script loading -> Misc. loading -> Started.
And the loop the program has to go through to generate each frame.
Script processing -> Check script wants this -> Check script wants that -> AI -> Object mapping -> Physics -> Z-Sort -> Backface removal -> Generate pixal plot to back buffer (depends on size of screen how long this takes) -> Copy back buffer to surface buffer (i.e., Actually showing the user the picture) -> Repeat
This is what the game has to go through without scripts:
Starting -> Computer -> Windows/Linux/Mac -> Security -> Program -> Misc. loading -> Started.
And the loop the program has to go through to generate each frame.
AI -> Object mapping -> Physics -> Z-Sort -> Backface removal -> Generate pixal plot to back buffer (depends on size of screen how long this takes) -> Copy back buffer to surface buffer (i.e., Actually showing the user the picture) -> Repeat
Remember: The program has to run through these loops atleast 30ish per second to make it look realistic to the player as an animation.
It also depends on how you program your engine to run that makes it fast or slow.
05/27/2006 (3:22 pm)
I'll be very blunt.C++ is much faster because it doesn't need to be processed and collected into memory. Nor does the game have to go through plenty of checks as to what the scripts are ordering it to do. Look at it this way.
This is what the game has to go through with scripts:
Starting -> Computer -> Windows/Linux/Mac -> Security -> Program -> Script loading -> Misc. loading -> Started.
And the loop the program has to go through to generate each frame.
Script processing -> Check script wants this -> Check script wants that -> AI -> Object mapping -> Physics -> Z-Sort -> Backface removal -> Generate pixal plot to back buffer (depends on size of screen how long this takes) -> Copy back buffer to surface buffer (i.e., Actually showing the user the picture) -> Repeat
This is what the game has to go through without scripts:
Starting -> Computer -> Windows/Linux/Mac -> Security -> Program -> Misc. loading -> Started.
And the loop the program has to go through to generate each frame.
AI -> Object mapping -> Physics -> Z-Sort -> Backface removal -> Generate pixal plot to back buffer (depends on size of screen how long this takes) -> Copy back buffer to surface buffer (i.e., Actually showing the user the picture) -> Repeat
Remember: The program has to run through these loops atleast 30ish per second to make it look realistic to the player as an animation.
It also depends on how you program your engine to run that makes it fast or slow.
#13
Thank you for your advice.
BTW, are there any link or tutorial for porting torqueScript to C++?
Thanks in advance
Sammy
05/29/2006 (5:38 pm)
Hi all,Thank you for your advice.
BTW, are there any link or tutorial for porting torqueScript to C++?
Thanks in advance
Sammy
#14
05/29/2006 (5:45 pm)
Nope. It's not a defined process, you have to know the engine and C++ pretty well to covert script coding into C++. Some stuff is simple, some isn't. TS is typeless, has a simpler environment, and is easy to "cheat" with... I have a bunch of script I'll need to move into C++ eventually, but I really don't have the skill to myself right now.
#15
but really, instead of worrying about script versus engine at this stage,
you'll probably be way ahead by just starting your project.
chances are that for the first several months you'll have more important things on your plate than deciding whether some given functionality is better in engine or script.
05/29/2006 (6:11 pm)
What paul says is pretty accurate - you basically just have to be comfortable in both.but really, instead of worrying about script versus engine at this stage,
you'll probably be way ahead by just starting your project.
chances are that for the first several months you'll have more important things on your plate than deciding whether some given functionality is better in engine or script.
#16
Mounting a rifle. No. it's just fine in torquescript.
05/29/2006 (6:33 pm)
Not everything needs to be ported into C++.. i depends on what the function is. Real Time Torquescript Pathfinding? Yeah, that should be converted over.Mounting a rifle. No. it's just fine in torquescript.
Torque Owner Martin de Richelieu
But a game written in script will be slower than a game written in c++ as there's an extra layer of opcode. But then again a game written in c++ would most like also be slower than one written in native machine code.
2) Yes if you are going to develop a "real" game, you will need to modify the engine code. But not just for speed but also for adding new features.