MultiplayerBook / MultiplayerBook

628 stars 210 forks source link

Hello I have some questions about float synchronization in RoboCatRTS project. #9

Closed insooneelife closed 8 years ago

insooneelife commented 8 years ago

Hello!! The project and book were so impressive and helped me a lot! I read the chapter "implementing peer to peer" and there were so many good skills introduced. But I have some questions about float synchronization.

  1. Is this "RoboCatRTS" project implemented including perfect float synchronization?
  2. In the book, it introduced checksum(with CRC) at part "Verifying Game Synchronization". Does it have nothing to do with float synchronization?
  3. If not, is it impossible for achieve float synchronization except for using only integers?

I've searched a lot but couldn't find reasonable float by integer library. I wonder how the games like "age of empires" achieved synchronization. They wouldn't have done it only with integer, isn't it??

chalonverse commented 8 years ago

Synchronization of floating-point numbers can be difficult, if anything because different platforms might perform floating-point computations slightly differently.

Using CRC to verify the synchronization will catch any discrepancies in what is compared, including floating-point numbers. That being said, it's possible to get false positives in desychronization if the floating points just very barely differ from each other.

Some games will choose to use fixed-point decimal numbers, rather than floating-point decimal numbers.

Here's a further discussion: http://gafferongames.com/networking-for-game-programmers/floating-point-determinism/