Page 1 of 1

deterministic behaviour?

Posted: Thu Jul 23, 2009 9:37 am
by popgoblin
Hi there

I have a rather simple question, i think.
I have a very simple system set up - a few rectangles, circles etc. I then fire small "balls" with a "cpBodyApplyImpulse" out into this field of simple objects. There's no gravity or anything - and everything has elasticity and friction of 1. The balls behave rather randomly, i'm afraid - and i'd like a very deterministic setup.

I've tried setting a very high amount of iterations - but that doesn't help, I'm afraid. Any ideas?

greetz!

Re: deterministic behaviour?

Posted: Thu Jul 23, 2009 11:30 am
by slembcke
You can get deterministic behavior if you reset the shape id counter. Read here: http://code.google.com/p/chipmunk-physics/wiki/cpShape

Re: deterministic behaviour?

Posted: Fri Jul 24, 2009 1:44 am
by popgoblin
That helped! It's not 100% - but might be close enough.

thx!

Re: deterministic behaviour?

Posted: Sun Jul 26, 2009 12:32 pm
by popgoblin
Hmm. The system is still a bit too un-deterministic. Is there anything else I can do to tighten it up?

Re: deterministic behaviour?

Posted: Sun Jul 26, 2009 4:04 pm
by maximile
It should be easy to get it completely deterministic. Make sure you're adding the shapes in the same order and using a fixed timestep.

Re: deterministic behaviour?

Posted: Sun Jul 26, 2009 5:22 pm
by Tam Toucan
Chipmunk doesn't have any random code in it i.e. the same code runs the same way each time. So if you are getting non-deterministic behaviour it must be introduced from your use of it e.g. as maximile says, adding the shapes in a different order, calling it with different timesteps.

Re: deterministic behaviour?

Posted: Mon Jul 27, 2009 9:12 am
by slembcke
Be careful of trying to achieve too much determinism though. While you can make it run the same way on the same machine, change the processor or compiler or compiler flags and it will be different because of subtle changes in floating point behavior.

Re: deterministic behaviour?

Posted: Thu Jul 30, 2009 5:03 am
by popgoblin
allrighty... i'll drill further down to get a bit more determinism. Thanx for your input, folks!