Tweaking the programming...

Non-platform specific questions.

Tweaking the programming...

Postby BeyondtheTech » Thu Aug 25, 2005 1:39 pm

One of my biggest concerns of a game of such magnitude (as in Battlestar, where a bunch of operations are going at every frame), is how GE handles math and logic operations.

Would the game increase in performance if I used Integers instead of Real variables? For instance, I have the shields set at 100.00%. Shields regeneration is based on the efficiency of another variable, the Shield Generator, and the speed of its repair is based on the Crew Complement. Imagine this with all the other functions of the Battlestar, such as Weapons, Engines, Hull, etc.. If I used all integers and started with a large number like 100000 and when it comes to display it, I just show the value divided by 1000, would that help any?

Also, I have a bunch of logic statements that are have multiple conditions and/or nested if's. Which one is theoretically faster?

Code: Select all
if (condition1)
{
   if (condition 2)
   {
      if (condition 3)
      {
         perform function;
      }
   }
}


or:
Code: Select all
if (condition1 && condition2 && condition3) perform function;


I'm assuming the first one would be faster, even though the code is longer, since it only has to perform the first condition test and bypass the rest. Then, it would have to be up to my logic to make sure I ask the right question (test) in the right order.

But, according to GE, which would perform better?

Thanks.
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby willg101 » Thu Aug 25, 2005 1:42 pm

I know this probably won't help, but I remember reading a C/C++ book, and it said that trying to shorten commands or make the computer do something through shorter commands doesn't nessescarily speed things up, but of course, I'm absolutely no expert, so my advice should be taken with a grain of salt...
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Re: Tweaking the programming...

Postby makslane » Thu Aug 25, 2005 2:01 pm

BeyondtheTech wrote:Would the game increase in performance if I used Integers instead of Real variables?


I think that not

Which one is theoretically faster?

Code: Select all
if (condition1)
{
   if (condition 2)
   {
      if (condition 3)
      {
         perform function;
      }
   }
}


or:
Code: Select all
if (condition1 && condition2 && condition3) perform function;




The second code will be executed a little bit more fast
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby ondy1985 » Thu Aug 25, 2005 6:53 pm

Indeed. IF is a simple boolean operation and should not consume much of CPU cycles.
User avatar
ondy1985
 
Posts: 99
Joined: Thu May 05, 2005 7:43 pm
Location: Slovakia
Score: 1 Give a positive score

Postby Fuzzy » Thu Aug 25, 2005 9:38 pm

Another option, but one that would make the game itself larger, is to build lookup tables.

Either at the beginning of the game, or as part of the compiled game, you build an array containing a multiplication table, or division... or any sort of logic table..
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest