Temple of The Roguelike Forums
Development => Programming => Topic started by: Serefan on January 05, 2012, 02:02:09 PM
-
Hi!
I've been working on my RL for a while now, and just started on the calculations for combat mechanics (health, tohit, damage, etc.). After thinking stuff through for a while I've found myself going back to using log10-based calculations time after time; they seemed to always give the most balanced output.
My only question is, will the constant use of logarithms in my calculations have an impact on performance?
-
For a turn based game? I wouldn't think so. The absolute maximum number of times per turn this calculation would be called would be equal to the maximum number of creatures you on the map (big O of n?)
-
Yeah, my computer does this in one second:
float s = 0;
for(long double f=1; f<20000000; f++) {
s += log(f);
}
Replacing log with multiplication or addition is 10 times faster, and integer addition is about 20 times faster. I don't why it would be a problem for combat mechanics (100 attacks per second, what's that?).
-
Thanks for the input guys. For the record, as it stands the game is turn-based, but I would like to try and implement a real-time version as the project moves along.
-
If by real time game you mean action game then animation and hit detection would be replacing a lot of the hit calculations. And that would be even more process intensive.
-
Yahoo Answers says the average processor these days is about 2 GHz. I think 2 billion calculations per second is more than you should really need.
And I agree that graphics are what will be the most processor-intense.