The computer I used to make the second screenshot was actually slower than the one used to make the first screenshot (the messed up one).
I tried this on my computer again, and added some junk looping code somewhere to slow things down. Result seemed to show that the orbits change less dramatically.
Another strange thing: the middle planet only moves either horizontally or vertically but never diagonally.
EDIT: Updated file.
http://contland.110mb.com/perso/ob/test2.swf (the link is weird, you have to copy paste it, not click on it)
- Runs at 120fps (meaning code runs 120 times per second and updates the image 120 times per second), may be unsuitable for low-end computers.
- The rock on the left is disabled for the moment.
- The middle planet's mass is 10^16kg, and the rock's mass is 1kg.
- Initial distance between them is 250m (VERY close! Maybe too close).
- The initial velocity vector of the rock is 0m to the right and 50m down.
- The path lines redraw after 7200 frames which should mean 1 minutes but is actually around 5-10 minutes depending on computer (clear some memory).
- Some debug info is available.
Now the orbit seems much more stable.
Maybe the thing that went wrong was just the "universe configuration". The middle planet was too "light" and the distances were too close so that even a 1kg rock could pull it slightly.
What's left to do is to rework on the displaying, like to add the ability to zoom in/out, so that I can make greater distances work. Calculating the timesteps stuff might also be something to consider.