www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Making floating point deterministic cross diffrent platforms/hardware

reply Chainingsolid <chainingsolid gmail.com> writes:
I planning out a game that has to use a lock step, peer to peer 
networking model to achieve multiplayer, and thus I need to have 
any floating point used produce the exact same results, no matter 
what, aka be completely deterministic. What would I need to do to 
achieve this?
Nov 20 2016
next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
write your own software fp library. this is the only way to cover 
all your broad cases.
Nov 20 2016
prev sibling parent reply Guillaume Piolat <first.last gmail.com> writes:
On Sunday, 20 November 2016 at 19:12:06 UTC, Chainingsolid wrote:
 I planning out a game that has to use a lock step, peer to peer 
 networking model to achieve multiplayer, and thus I need to 
 have any floating point used produce the exact same results, no 
 matter what, aka be completely deterministic. What would I need 
 to do to achieve this?
I think you can roughly have that with ldc, always using SSE and the same rounding-mode. If you use the FPU then the excess precision will make things diverge. I've not compared the results across OSes but I get the exact same results across 32-bit and 64-bit. Another way for deterministic FP is to round to a lower precision, or used fixed-point/integers. If you use client prediction, and the server (authoritative) sends the correct player position to clients regularly (action game), then no determinism is actually needed. Ask Manu who knows more about this.
Nov 20 2016
next sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Sunday, 20 November 2016 at 21:31:09 UTC, Guillaume Piolat 
wrote:
 I think you can roughly have that with ldc, always using SSE 
 and the same rounding-mode.
ARM. oops.
Nov 20 2016
parent Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
On Sunday, 20 November 2016 at 21:42:30 UTC, ketmar wrote:
 On Sunday, 20 November 2016 at 21:31:09 UTC, Guillaume Piolat 
 wrote:
 I think you can roughly have that with ldc, always using SSE 
 and the same rounding-mode.
ARM. oops.
No problem with ARM + x86 for double and float.
Nov 20 2016
prev sibling parent reply Chainingsolid <chainingsolid gmail.com> writes:
On Sunday, 20 November 2016 at 21:31:09 UTC, Guillaume Piolat 
wrote:
 If you use client prediction, and the server (authoritative) 
 sends the correct player position to clients regularly (action 
 game), then no determinism is actually needed. Ask Manu who 
 knows more about this.
I'm making an rts so the client/server model would require very unrealistic bandwidth, hence the lock step peer to peer system.
Nov 20 2016
parent Guillaume Piolat <first.last gmail.com> writes:
On Sunday, 20 November 2016 at 22:36:12 UTC, Chainingsolid wrote:
 I'm making an rts so the client/server model would require very 
 unrealistic bandwidth, hence the lock step peer to peer system.
Indeed, peer to peer require determinism I guess.
Nov 20 2016