Deterministic Multiplayer RTS game questions?
- by Martin K
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?