Synchronized games and floating point

Started by
26 comments, last by jdi 16 years, 10 months ago
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.
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.

For local multiplayer retro themed games, visit Domarius Games.

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]
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.
One solution could be that they are simply transmitting user interactions.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
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.
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.

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
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]
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.

This topic is closed to new replies.

Advertisement