Box2D是否完美确定性? [英] Is Box2D perfectly deterministic?

查看:114
本文介绍了Box2D是否完美确定性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LibGDX和Box2D编写Android游戏.我正计划在其中添加基于回合的多人游戏功能.

I'm writing an Android game using LibGDX and Box2D. I'm planning on adding a turn-based multiplayer feature to it.

现在,如果在两个客户端上我以相同的速率和相同的时间步长步入Box2D世界,并且在两个客户端上使用完全相同的初始参数启动模拟,那么当模拟结束时,两个客户端的最终状态都将模拟是完全一样的吗?换句话说,Box2D仿真是否具有确定性?

Now, if on both clients I step the Box2D world at the same rate with the same time steps and I start a simulation on both clients with the exact same initial parameters, when the simulations are over, will the final state of both simulations be exactly the same? In other words, is a Box2D simulation perfectly deterministic?

如果不是,则意味着每次模拟结束时,一个充当主机的客户端将不得不告诉另一方放弃其最终模拟的结果,而代之以其使用.

If it's not, then that means every time a simulation is over, one client acting as a host will have to tell the other to throw away its final simulation's results and use its instead.

推荐答案

环顾四周,即使使用了相同的时间步,答案还是否"!这个答案的原因与在许多编译器和处理器中如何实现浮点数学有关.每个周期的微小差异加起来会导致模拟结果大相径庭.

After looking around, the answer is "No", even if the same time steps are used! The reason for this answer has to do with how floating point math is implemented in many compilers and processors. Small discrepancies on each cycle add up resulting in significantly different simulations.

这篇关于Box2D是否完美确定性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆