ElectroDruid wrote:
... to debug nondeterministic behaviour, really your best weapon is a completely thorough logging system. Run the game, and log the state of every meaningful variable every frame, to the highest accuracy you can manage. Do it a few times, and get different logs from runs which end up with different outcomes. Then go through the logs (some kind of diff tool is handy for this) to find the first frame where a variable is different, and then try to work out why that happened.
Just wanted to add my two cents on this. I used a very similar system where I generated a crc number for every frame of the physics stepping, then checked if that number was the same on a subsequent run with the same input. This reduces the amount of data needed to pinpoint the frame where the two simulations first differ.
Then I made a textual dump of the world state from each run, and used tortoise svn's diff (just put the two files in the same folder, select them both, right click and choose 'Diff', gives you a very nice visual diff.
Something to be aware of is that floating point numbers with very small differences will not be visible in the textual dump if you do it using for example printf("%f", myfloat);
You will probably need to convert the float to its hex representation to make sure that even one bit of difference will show up.