Comments (1)
Non-deterministic behaviour
The solution 2 was implemented but we had a serious issue: Box2D is non-deterministic [1, 2, 3] and some very small differences between simulations created situations where the moto crashed at random different places before finishing the level (usually after about 30 seconds on complicated levels)
[1] http://box2d.org/forum/viewtopic.php?f=3&t=5453
[2] http://www.box2d.org/forum/viewtopic.php?f=3&t=4489
[3] http://www.box2d.org/forum/viewtopic.php?f=3&t=4614
It worked each time only in one specific situation : when creating a replay on Chrome on the first try, saving the replay on its textual representation, and then passing it in params to XMoto. The replay then worked correctly but only on the first run. If the replay was restarted using "ENTER", then the moto crashed.
On Firefox it failed almost each time (except on short-simple levels of course).
The reason is quite simple : Box2D is only deterministic for "one binary, on a specific system and if the action is taken at the exact same moment of the simulation".
In our case, it could be interpreted as "in one browser, on a specific system and only for the first run".
Solution (key-steps)
We implemented the following solution : Every x steps, we save a key-steps containing the following informations of each part of the moto and the rider :
position:
x: object.GetPosition().x
y: object.GetPosition().y
angle: object.GetAngle()
linear_velocity:
x: object.GetLinearVelocity().x
y: object.GetLinearVelocity().y
angular_velocity: object.GetAngularVelocity()
These informations are concatenated to the inputs informations of the solution 2 and when the replay is run, each part of the moto and rider are positioned manually in the world. This solution prevents moto parts to drift off their original path because of the non-deterministic behavior.
Size: Of course the replay size increases a little bit because of this trick. But it still manageable since the key-steps can be saved with low-frequency like one time every second (60 steps). The total size of the replay (input + key-steps) is about 20ko/minute.
from xmoto.js.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmoto.js.