Jump to content
  • Advertisement
Sign in to follow this  
Daniel Miller

Synchronized games and floating point

This topic is 4040 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There has been discussion about this already, but no real answer was given. How do modern RTS games (which all employ synchronized simulations for each client) handle floating point numbers? Normally, floating point numbers can vary slightly between different computers, which would throw each and every game off sync. Does anyone know how they pull this off? Games can't trust one of the clients for "corrections", that would completely open the door for all sorts of hacking.

Share this post


Link to post
Share on other sites
Advertisement
I don't think it's any different than any other network game. The server keeps the best record of what is really going on, and sends out updates to the clients at intervals. Inconsistancies due to floating point numbers won't even show up before the next update.

Share this post


Link to post
Share on other sites
Interesting question.

One thing you can do if you're windows only and using MSVC is to enable fixed floating point accuracy. It has some overhead though, so I wouldn't call it a solution.

Using a certain amount of bits, perhaps?

[Edited by - SymLinked on May 22, 2007 6:19:38 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Daniel Miller
How do modern RTS games (which all employ synchronized simulations for each client) handle floating point numbers?

What modern RTS games do employ synchronized simulations? I don't have any actual info, but I'm quite sure that a client-server model is usually used.

Share this post


Link to post
Share on other sites
We had a big thread on this recently: http://www.gamedev.net/community/forums/topic.asp?topic_id=446873

Quote:
Original post by CTar
Quote:
Original post by Daniel Miller
How do modern RTS games (which all employ synchronized simulations for each client) handle floating point numbers?

What modern RTS games do employ synchronized simulations? I don't have any actual info, but I'm quite sure that a client-server model is usually used.

Probably the Age Of Empires games ( http://www.gamasutra.com/features/20010322/terrano_01.htm ), and judging from the sheer number of units probably Supreme Commander as well.

Share this post


Link to post
Share on other sites
Quote:
Original post by CTar
Quote:
Original post by Daniel Miller
How do modern RTS games (which all employ synchronized simulations for each client) handle floating point numbers?

What modern RTS games do employ synchronized simulations? I don't have any actual info, but I'm quite sure that a client-server model is usually used.


Supreme Commander does, it was mentioned in an interview. Warcraft 3 does as well, judging from their replay files.

Share this post


Link to post
Share on other sites
Check out fixed point math. Basically, you use integers for all simulation values, and adjust your algorithms to recognize that 15.492 == 15492, for example. Check this thread for some good posts by hplus0603.

- Mike

Share this post


Link to post
Share on other sites
Thanks for the link. How would I get sin and cos values if I only used integers?

edit: I should elaborate. If sin and cos return doubles, I couldn't trust the returned value to be the same across all systems.

[Edited by - Daniel Miller on May 23, 2007 1:00:32 AM]

Share this post


Link to post
Share on other sites
The differences are tiny - by the time you've rounded them up to the 'safe' range they're almost guaranteed to be the same.

Ultimately, if you're not going to have an authoritative owner of the simulation, then you're always open to synchronisation issues, whether deliberate (hacking) or accidental (loss of precision). Luckily the chance of the latter being an issue is statistically minimal compared to the first.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!