Deterministic Multiplayer RTS game questions?

Posted by Martin K on Game Development See other posts from Game Development or by Martin K
Published on 2012-07-06T21:58:01Z Indexed on 2012/07/07 3:23 UTC
Read the original article Hit count: 273

Filed under:
|
|

I am working on a cross-platform multiplayer RTS game where the different clients and a server(flash and C#), all need to stay deterministically synchronised.

To deal with Floatpoint inconsistencies, I've come across this method: http://joshblog.net/2007/01/30/flash-floating-point-number-errors/#comment-49912 which basically truncates off the nondeterministic part:

return Math.round(1000 * float) / 1000;

Howewer my concern is that every time there is a division, there is further chance of creating additional floatpoint errors, in essence making it worse?

.

So it occured to me, how about something like this:

function floatSafe(number:Number) : Number 
{return Math.round(float* 1024) / 1024; }
  • ie dividing with only powers of 2 ? What do you think?

.

Ironically with the above method I got less accurate results:

trace(  floatSafe(3/5) ) // 0.599609375 

where as with the other method(dividing with 1000), or just tracing the raw value I am getting 3/5 = 0.6

or Maybe thats what 3/5 actually is, IE 0.6 cannot really be represented with a floatpoint datatype, and would be more consistent across different platforms?

© Game Development or respective owner

Related posts about multiplayer

Related posts about rts