deterministic behaviour?

Official forum for the Chipmunk2D Physics Library.
Post Reply
popgoblin
Posts: 5
Joined: Thu Jul 23, 2009 9:17 am
Contact:

deterministic behaviour?

Post 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!
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: deterministic behaviour?

Post 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
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
popgoblin
Posts: 5
Joined: Thu Jul 23, 2009 9:17 am
Contact:

Re: deterministic behaviour?

Post by popgoblin »

That helped! It's not 100% - but might be close enough.

thx!
popgoblin
Posts: 5
Joined: Thu Jul 23, 2009 9:17 am
Contact:

Re: deterministic behaviour?

Post by popgoblin »

Hmm. The system is still a bit too un-deterministic. Is there anything else I can do to tighten it up?
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: deterministic behaviour?

Post 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.
User avatar
Tam Toucan
Posts: 141
Joined: Tue Jun 23, 2009 4:26 pm
Contact:

Re: deterministic behaviour?

Post 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.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: deterministic behaviour?

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
popgoblin
Posts: 5
Joined: Thu Jul 23, 2009 9:17 am
Contact:

Re: deterministic behaviour?

Post by popgoblin »

allrighty... i'll drill further down to get a bit more determinism. Thanx for your input, folks!
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests