-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this engine fully deterministic? #820
Comments
I can't say for sure if it is or not, but I believe it is. When you create new bodies, and your a good place to see this is in this example, when you first open it, wireframes are enabled, you can turn them off by going to the sidebar on the right, and scrolling down, and it should be the first option under |
@LeotomasMC This would imply that they in fact use a predefined random seed, but I don't think it's enough to say the engine is deterministic. For example, in this example https://brm.io/matter-js/demo/#wreckingBall the initial condition are the same when you refresh and the results are still different each time :/ |
Nice project! Watching them evolve is pretty mesmerising. Seems to work well? Yes, as far as I know the engine should be deterministic given the exact same conditions and using a fixed timestep, the work I've been doing on testing recently seems to show this too. Do you have a specific example that seems to fail? Are you sure there is no randomness used in the setup and the timestep is definitely fixed? Any idea how big the (initial) difference might be? Did you try different browsers? |
Hi @liabru, all the initial conditions in my genetic algorithm and defined with a seeded random at the beginning of the run and I did a lot of debugging to ensure it was the case. However, I'm not sure about the fixed timestep, I don't remember setting anything particular in the engine to configure the timestep. Did I miss something here? 😃 As an example, in this example, the initial conditions are the same (I suppose) but the result of the simulation change on every re run |
The built in runner currently uses a dynamic timestep by default to prevent visual slow down, but this means the examples don't appear deterministic if your FPS fluctuates at all. This behaviour is due to change in a future update using a more advanced approach, but for now if you're using the built in runner try using a fixed timestep e.g. |
Makes sense 😃 I looked at my code, and apparently I did set the timestep to be fixed here line 41 Also, what I found during my tests is that the less elements are rendered in the scene (so the better the performance) the more deterministic is seems to be. |
Hey @liabru I am still facing issues with non deterministic behaviour. I have a ball drop merger game built with matter.js. Currently I am working on async feature where once I play a game I record all the moves and send them to my friend so he can play against me. Saving the moves and replaying them doesnt show the same output even on same device. Because of the size limit I cant send videos... I have found out that when having balls are spawned and moving slowly it works fine but when you are playing at a higher pace there are a lot of balls moving around it is not deterministic still. Any ideas here? |
Hi there,
Awesome project, I love it!
A while back I made a project for experimenting with genetic algorithms using Matter.js.
It worked, but there was a problem. I noticed that, given the exact same input parameters, the simulations would sometimes give me different results. I tried to track down the problem but eventually gave up.
My question is, therefore: Is this engine fully deterministic? And If yes, what could I be missing in my code? https://github.com/theochampion/genetic-playground
Cheers!
The text was updated successfully, but these errors were encountered: