android - Box2D 是完全确定的吗?

标签 android box2d multiplayer deterministic

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

现在,如果我在两个客户端上以相同的速度和相同的时间步长进入 Box2D 世界,并且我在两个客户端上使用完全相同的初始参数开始模拟,当模拟结束时,两者的最终状态将模拟完全一样?换句话说,Box2D 模拟是完全确定的吗?

如果不是,则意味着每次模拟结束时,作为主机的一个客户端将不得不告诉另一个客户端丢弃其最终模拟结果并使用它。

最佳答案

官方常见问题解答引用

官方常见问题解答中有一段话证实了您的推断http://web.archive.org/web/20160131050402/https://github.com/erincatto/Box2D/wiki/FAQ#is-box2d-deterministic :

Is Box2D deterministic?

For the same input, and same binary, Box2D will reproduce any simulation. Box2D does not use any random numbers nor base any computation on random events (such as timers, etc).

However, people often want more stringent determinism. People often want to know if Box2D can produce identical results on different binaries and on different platforms. The answer is no. The reason for this answer has to do with how floating point math is implemented in many compilers and processors. I recommend reading this article if you are curious: http://www.yosefk.com/blog/consistency-how-to-defeat-the-purpose-of-ieee-floating-point.html

或者换句话说:Fixed-size floating point types

为什么维基被删除,我不知道。人类。不过,我很高兴他将项目名称小写了。

关于android - Box2D 是完全确定的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30674389/

相关文章:

iOS游戏中心游戏不同步

java - 将速度应用于无与伦比的 AI Racket ,打造简单的乒乓球游戏

互联网连接关闭时 Android 应用程序崩溃

java - 如何在Android的onCreate方法中使用全局变量

box2d - 我应该如何让 body 在 box2d 中以恒定速度在地面上移动?

algorithm - 是否有一种算法可以在 Http 上工作,用于估计时钟偏差?

android - 移动实时多人游戏 SDK

java - 在java中将文本文件转换为字符串

java - 使角色绕圈移动

java - Box2D 在破坏 body 时崩溃(表达式 : m_bodyCount < m_bodyCapacity)