Temple of The Roguelike Forums

Development => Programming => Topic started by: Serefan on January 05, 2012, 02:02:09 PM

Title: Combat Balancing
Post 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?
Title: Re: Combat Balancing
Post by: Brigand on January 05, 2012, 02:26:56 PM
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?)
Title: Re: Combat Balancing
Post by: Z on January 05, 2012, 02:36:04 PM
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?).
Title: Re: Combat Balancing
Post by: Serefan on January 06, 2012, 06:38:58 AM
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.
Title: Re: Combat Balancing
Post by: guest509 on January 07, 2012, 12:53:03 AM
  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.
Title: Re: Combat Balancing
Post by: wire_hall_medic on February 05, 2012, 07:00:57 AM
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.