Okay, that's one solution indeed! :-) I guess it's important to remind yourself, what are you trying to achieve. Are you trying to model the actual physics or make something that LOOKS real for gaming purposes? If the latter, then tricks like this or softening which was mentioned earlier (which is used in many 'real' science/astro simulations btw), are perfectly valid. Regarding the suggestion about adaptive timesteps, this is again something you would definitely do to follow the physics more accurately but then you have unpredictable rates since your simulation slows down whenever two stars get close and then speeds up again, all very jerky and unstable. So a fixed timestep works fine if your not bothered about getting things right with close interactions. But if you want to model the physics accurately (out of some scientific curiosity for instance) then definitely consider it.
Definitely going for "close enough"! I will no doubt go for something more advanced later on, but for now, something that is scientifically 'close', but not 'accuracy over usability'.
The advantage is you get more accurate integration of the orbits (actually important for both scientifically accurate simulations and for making it look better) since leapfrog/mid-point gives second-order errors compared to Euler integration which is first-order. A leapfrog integrator is also a special kind of integrator (called a symplectic scheme) which has wonderful conservation properties which amongst others preserves circular and elliptical orbits (e.g. planets or binaries) very well. The thing is, all these schemes are as expensive as each other, just one force computation per timestep so in that case you would use the better one right? :-)
Decisions, decisions. But you do make it sound pretty good, although I will need to study it much closer! I am starting to think I need a mixture...
I'm going to have to disappoint you on this one. You are of course correct for two bodies. This problem was solved by Sir Isaac Newton some 300+ years ago :-) . And in the intermediate centuries, everybody and their cat has tried to add just one more body to solve the so-called 3-body problem. But there is no general solution I'm afraid that can be used like you hope for. There are various special so-called 'restricted' 3-body problems where the motion of 1 body is limited in some way so it becomes a 2-body problem again or has some special solution for some configuration. But in general, and especially when this becomes 4, 5 ... N bodies, you have to do the numerical integration I'm afraid! This is one of the step-ups from linear/soluable equations to non-linear equations. All the 'geniuses' of yesteryear solved the 'easy' linear stuff :-D and left all the difficult non-linear stuff to our generation! :-/ Oh well ...
I am starting to accept that. I am still holding out hope for something similar that is simply 'science-adjacent'. But that is a future thing, I am trying to keep my eyes on the ball for now...
Regarding the oct-tree, I'm still a little unsure if you really need it for gravity integration (for the reasons discussed earlier about the ~1000 body limit). However, if you want to model some kind of larger Universe with large-scale structure and then 'zoom' into galaxies and further, then having a tree structure to organise this data hierarchically is obviously a good thing. If you can combine it with helping to compute the gravity, then great but I'm still unsure if you'll get that much benefit while maintaining 30/60fps.
I am convinced that I will have to do a lot of weighing systems against each other, maybe mix and match. Who would have thought this would be difficult ;-p
I really can't tell if you are trolling, at this point. I'll feed you a Wikipedia page about the subject: https://en.wikipedia.org/wiki/N-body_problem . No, you will not find an analytical solution to anything beyond n=3.
No, not trolling, why would I? I am just hoping that there is something I am ignorant of, but hope is failing me on that particular account... :(
I see octrees already mentioned, but in case you don't know about it, there's a name for this technique used for this specific purpose: Barnes-Hut. You can trade accuracy for efficiency.
Some links that explain more:
https://en.wikipedia.org/wiki/Barnes-Hut
http://www.cs.princeton.edu/courses/archive/fall04/cos126/assignments/barnes-hut.html
Thanks! I am shopping around for good stuff, didn't know the Princeton one!