Work Offer. Different physics issue

Hi

We are building box2d based flash game. You can take a look here:http://www.playgamemm.com/game.html
It is beta and it is not ready yet. We have one big issue. Game concept is that you can build different machines to pass the level and later you can save this machine and share it with friends. So it must work so that saved and shared machines will pass the level exactly the same way if you look solution again. But it does not in our game. The difference is more visible with more complicated machines and levels.

If we build machine and run it again without loading stage again, then physics is the same with every run. But if I save machine and will load this machine again (then whole machine together with map is loaded again) then sometimes physics is different and machine passes level in different way.

We already know where the mistake is . Problem is in joint order. If I build machine then joint order might be different than after saving and loading map and machine again. We have heard that it is box2d issue that it does not sort joints well. And so far we know that the mistake has to be repaired in box2d engine that system will sort joints same way all the time.

We are start-up company and we are not box2d experts so we are looking for specialist who can help us to fix this issue and we can pay for it. If you are interested then please write us: [email hidden]

Thanks.
How are you saving the machines? If you save/reload everything in the same order that it was created, loading a game/machine from xml (or however you're doing it) should be the same as how the user first created it.

A moderately complex simulation will usually be slightly different each time also, no matter what you do, because of floating point errors I think. I mean, roughly things will always look the same, but if you watch closely, there are tiny differences every time, and even these tiny differences can add up over time.

I remember that Fantastic Contraption, which it seems you got some inspiration from, also had this issue, even when not saving and reloading. It was mostly with really complex machines on really tough levels that you noticed things working slightly different each time. Sometimes it was enough that a machine could win a level one time, but fail the next.

Also make sure that however you are saving your machines, floating point numbers don't get truncated or corrupted along the way.
Thanks for the comment. I think it should be possible to get end result where at least 99% of machines run the same way all the time. In our case almost everything runs differently. We have tested and I can use very complex level (with lot of physical objects) and if I add only wheels or single rod pieces, then everything runs the same way. Seems that issue starts when we make machines where there is more than 1 joint in same place. For some reason joints are not in same order after saving machine or loading it again.

Is it possible to modify box2d ,so it will sort all the object before starting physics simulation? So all objects and joints will always be in same order?
I already have source code in my own game engine to do precisely what you need. It recreates an empty Box2D world with exactly the same structure as the one that it took apart. I can read from svg, a special xml format, or a binary file, and write to the xml format or a binary file. In particular, recreating the broadphase tree (where most of the changes in determinism come from) was interesting.
One more thing, try using a fixed timestep if you're not already, but I'm guessing you are.

Original thread: https://box2d.org/forum/viewtopic.php?t=6484