Predictable results?

Official forum for the Chipmunk2D Physics Library.
Post Reply
abeck99
Posts: 1
Joined: Fri Dec 05, 2008 9:56 am
Contact:

Predictable results?

Post by abeck99 »

I am making a puzzle game where a ball bounces from place to place, trying to get it to an exit. I am using chipmunk, but every time I run the simulation the results are different. I searched the SDK to find any randomness, but couldn't find any. If I set the enviornment exactly the same every time, use the same step time, so how could I be coming up with different results every time? Nothing is ever drastically different, but the differences add up to become drastically different.

Any insight into why this is would be appreciated.

/andrew
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Predictable results?

Post by slembcke »

Chipmunk can be made to be deterministic. The main issue is that iteration of the collision pairs is different based on their IDs. If you call cpResetShapeIDCounter() (http://code.google.com/p/chipmunk-physics/wiki/cpShape) whenever you create and populate a new space, it should ensure a consistent iteration order. Keep in mind that floating point math is not consistent between processors or compilers.

You should rely more on general behavior (balls roll down slopes) rather than specific behavior of a complicated simulation. For just about any game physics library, the aim is to provide plausible looking physics over 100% exact physics. There is an old riddle, if a rooster lays an egg on the peak of a roof, will the egg roll to the left or the right? Chipmunk may choose left or right depending on the user's machine or the phase of the moon. The correct answer is of course that rooster's don't lay eggs, but realistically most players aren't going to catch that. ;)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests