# Procedural generation of semi-correct planetary systems

So there are lots of resources you can find via Google or using the search here on how to procedural generate a whole galaxy. But I couldn't find any good resource on how to generate planetary systems that follow these criteria:

The systems don't have to be accurate simulations of orbits but should be close to plausible orbits. I don't care about any simulation that cares about how the system might look in 200k years, the orbits could be rock solid. The main problem I'm facing is how to randomly generate a system that could be seen as plausible. This becomes especially interesting when you have a system with a binary star.

Just randomly creating orbits won't make up a plausible system, you'll end up with obviously non working orbits. Yes, I'm aware of the N-body problem :) but this doesn't help me, at least I think so, to solve the problem of generating a plausible system procedural?

I think you could just randomly spawn planets on their orbit and give them a mass and then use the N-body mathematics to calculate if they're more or less valid, if not start over and randomly generate new orbits until you get something that matches, but this would be very inefficient.

• You could generate a mass or maybe even a density and diameter first (this could happen randomly within certain bounds) and then calculate the needed radius of orbit and velocity based on some formula. If there is already a planet at this orbit radius, just generate again. This should reduce redundant generations a lot and should look rather reasonable, more so if you randomly tilt the orbits a little. This won't account for interplanetary gravitational interaction, however, but seeing as you request a pretty basic representation it may be enough. Dec 4 '17 at 10:50
• In order to answer this question, you need to be an astronomer, not a game developer. It might be more of a question for astronomy.SE. Dec 4 '17 at 15:09
• Create a set of rules for a planet to be viable. Create a set of rules for a set of planets to be viable. Check against those rules. Done.
– Mast
Dec 4 '17 at 19:01
• This doesn't exactly answer your question, but you might find my work helpful: quotientring.com There are some answers in the Cosmos-2 ruleset: alternityrpg.net/resources/1375/original/cosmos-2.pdf Dec 5 '17 at 1:44

In order to create a plausible solar system, make sure every orbit is within the sphere of influence of the parent body, but not within the hill sphere or roche limit of another body.

The sphere of influence is the maximum radius around a planet where stable satellites can be expected.

The roche limit is the minimum orbital radius one celestial body can have around another. When it is on a lower orbit, it breaks apart and becomes a ring.

The hill sphere is relevant when you want to prevent to create two satellites around the same body which have very close orbits. It is the range between minimum and maximum orbital radius a planet "occupies".

All three values can be calculated from the mass and orbital radius with the formulas in the linked Wikipedia articles.

So I would then try the following algorithm:

1. Create a random number of celestial bodies with a random orbital radius and mass. Radius and mass should be on a logarithmic scale.
2. Starting from most to least massive, calculate the hill sphere of each planet. Any less massive planet in the hill sphere of a more massive planet becomes a moon of that planet. Randomly-generate the orbital radius of the moon around the parent with a logarithmic distribution between 0 and the sphere of influence of the parent.
3. Perform step 2 for all moon systems to resolve hill-sphere conflicts of moons. Whether a moon can have a stable satellite is a matter of debate among the astronomy community (no example is known in our solar system). When you don't want any moon-moons, simply delete the smaller moon or put it on a different random orbit.
4. Check the Roche limit of every object around its parent. When it is below the roche limit, convert it to a ring (or just delete it).

This covers single-star systems, but not binary star systems. A binary star system has two stars which orbit a common barycenter. Planets can either orbit one of the stars (S-type orbit) or the common barycenter on a very wide orbit (P-type orbit).

If you want a binary star system, I would recommend to generate the second star as another satellite around the primary star at first. Anything in the hill sphere of the second star orbits the second star and anything with a radius smaller than the hill sphere of the second star orbits the first star. Calculate the barycenter and have both stars with their moons orbit that. Anything with a larger obit than the hill sphere orbits the barycenter of the two stars (P-type orbit).

Trinary and larger n-ary star systems are only stable when the stars beyond the 2nd are very small compared to the other. These additional stars should be handled just like any other planet.

• I'll just add Kepler's Third Law of Planetary Motion to this answer, The square of the orbital period of a planet is directly proportional to the cube of the semi-major axis of its orbit. Dec 4 '17 at 16:39

Simplify to 2-body physics. N-body physics is in general chaotic and you cannot simulate them to a stable orbit.

Single stars

For systems with a single star, I'd ignore the N-body problem and just make a set of planets roughly distributed in a geometrically increasing distance from the sun. Perhaps you could have a rule that if a particularly large Planet is generated, any neighbors that are too close get destabilized and form an asteroid belt.

Planets close to the star are not necessarily rocky as is the case in our solar system.

The mass, distance and orbital speed of a planet are interlinked -- when you're randomly choosing values, make one of these (probably orbital speed) dependent on the other two.

Binary Stars

I didn't really know anything about habitable binary stars previously before checking Wikipedia for this answer, so read up on Habitability_of_binary_star_systems where I got some of these numbers.

1. In non circumbinary planets (the planet orbits only one of the stars in the binary system), if a planet's distance to its primary exceeds about one fifth of the closest approach of the other star, orbital stability is not guaranteed. This means if Stars A and B form a binary system with distance AB, you can have stable planetary orbits around either A or B at distances closer than 0.2 * AB. For these systems, I'd again use 2-body physics as an approximation.

2. In circumbinary systems, as long as the planet is 2-4 times further away from the binary pair as they are from each other, you can again treat this as a 2-body problem where the planet orbits around the center of mass of the two stars

3. You could also have planets orbiting the L4 and L5 Lagrange points of the binary system. I've only seen discussions of this in sci-fi settings -- I think only asteroid-sized bodies are known to occupy Lagrange points of planets in our solar system, although they can be useful for spacecraft. Technically, One of the stars needs to be significantly bigger than the other for these points to be stable, but it's up to you how much you want to let real physics get in the way of your game setting.

• Three-body systems have known periodic solutions that can be hardcoded and picked randomly en.wikipedia.org/wiki/Three-body_problem#Periodic_solutions Dec 5 '17 at 0:10
• @Nakilon The question was asking for plausible planetary star systems, though . Any of the known solutions to the 3 body problem with non-negligible masses are practically impossible to occur naturally. They might, however, occur in a game featuring sufficiently advanced aliens who like to do astroengineering. Dec 6 '17 at 21:56

This is a long comment to supplement existing answers.

Given enough time, a planetary system becomes mostly planar. You may as well simplify your simulation by setting it to be planar from the start. Then you can get the rest done with the Binet equation, at least if you're using the 2-body simplification Jimmy suggested. If you neglect general relativity, the solution is analytic; if you don't, you'll need something like Runge-Kutta.