Planet generation

This commit is contained in:
BirDt_ 2025-12-09 23:35:17 +08:00
parent 79845bee13
commit fbb7e72390

View file

@ -134,13 +134,66 @@ These rules provide some base sanity for planet generation and prevent things li
- If it could be gas, it's gas.
- And finally as a fallback, if none of the previous conditions match, the planet is terrestrial.
The atmosphere is also based on a classification system, with atmospheres being either None, Light, Earth-like, or Heavy.
The atmosphere is also based on a classification system, with atmospheres being either None, Light, Earth-like, or Heavy. The following rules govern which atmospheres are possible:
- If the planet is a gas giant, the atmosphere class must be None.
- If the planet is less than 0.5 Earth masses, the atmosphere class must be None.
- If the planet is within 0.1 AU of it's parent star, the atmosphere class must be None.
- Calculate the magnetic flux at the given point as the X-ray Luminosity divided by the orbit distance (in metres). If this value is more than ~100 * pow(mass in Earth masses, 2)~, the atmosphere class must be None. This estimates the impact of stellar wind against a likely magnetic core.
- If habitable generation is forced, and the above two rules are not applicable, the planet has an Earth-like atmosphere.
Otherwise, the atmosphere class is randomly determined: 50% of the time, it is None. 25% of the time, it is Light. 15% of the time it is Earth-like, and the remaining 10% of the time it is Heavy.
Finally, we also determine a classification for the volcanic activity. This can be either None, Low, Medium, High, and Extreme. This is, primarily, a representation of tidal forces - so planets with large moons will have more extreme volcanic activity.
Gas planets always have no volcanism.
Planets that have no moons, or aren't moons, always have no volcanism.
If the planet is not a moon, we calculate the mass, radius, and orbit distance of the closest moon in SI units - if the planet is a moon, we calculate these values for the parent planet instead. We calculate the tidal force exerted as ~G * real_mass * ((2*real_radius)/pow(real_distance, 3))~. From this result: if it's approximately 0, the volcanism is None. If the force is less than 1.2, the volcanism is Low. If it's less than 5, the volcanism is Medium. If the force is less than 20, the volcanism is High. Otherwise, the volcanism is Extreme.
We now generate the atmospheric pressure (in Atmospheres) based off the class:
- A class of None has 0 pressure.
- A class of Light has any pressure between 0 and 0.6.
- A class of Earth-like has any pressure between 0.6 and 1.4.
- A class of Heavy has any pressure between 1.4 and 100.
We also generate the planetary albedo based on planet class and atmosphere class, starting with a base random value from the planet class:
- Terrestrial planets have a value between 6 and 11.
- Metallic planets have a value between 0 and 6.
- Gas planets have a range between 30 and 100.
- Water planets have a range between 10 and 20.
- Ice planets have a range between 50 and 70.
We then add a random value based on the atmosphere class:
- For None atmospheres, we don't add anything.
- For Light atmospheres, we add a value between 0 and 2.
- For Earth-like atmospheres, we add a value between 2 and 12.
- For Heavy atmospheres we add a value between 12 and 100.
We then correct the albedo as a fraction by dividing it by 100. The result cannot be lower than 0 or higher than 1.
We also generate a greenhouse effect component based on the Atmosphere class:
- For None, it's 0.
- For Light, it's between 0 and 0.9.
- For Earth-like, it's between 0.9 and 1.5.
- For Heavy, it's between 1.5 and 500.
Now we can calculate the surface temperature. For this we need the SI values of the system's sun luminosity and the orbit distance of the planetary system. We also calculate the Stefan Boltzmann constant: ~5.67 * pow(10, -8)~.
This allows us to calculate the surface temperature like so: ~(pow((L/pow(d, 2)) * ((1-albedo)/(4*stefan_boltzmann)) * (1 + ((3.0/4.0)*greenhouse)), 1.0/4.0))/2~ Kelvin.
We also determine the planet's elemental composition - for the surface, we only look at the crust. We first filter to possible elements by looking at natural elements, and filtering based on the planet class.
- For Terrestrial planets, we only filter to elements which are solid given the surface temperature. We also remove heavy elements: any element with an atomic number greater than 34.
- For Metallic planets, we again filter to solids, and we also remove all non-metals, noble gasses, halogens, metalloids, alkali metals, and alkali earth metals.
- For Water planets, we filter to elements that can be either solid or liquid for the surface temperature.
- For Ice planets, we filter to solids only.
- For Gas planets, we filter to gasses only.
We then look in the system abundance, and copy all elements that pass the above filters, with their percentage abundance in the system. The only exception is Silicon - if the planet class is Terrestrial, we set the percent of Silicon in the planet to 50%.
Now for the copied elements and percentages, sorted by their percentage, we randomly determined the composition. The first and most abundant element of Terrestrial planets is Silicon. Otherwise, we pick a random element from the 5 most abundant elements and push it to the crust composition with a random range between 0.4 and 0.8 (if this is the first element selected) or 0 and 1.0 - the sum total of all currently selected elements. We do this anywhere between 1 and 10 times, to get the major crust composition.
If the atmosphere class is not None, we also need to determine the planet's atmospheric composition. For this we filter to natural elements, and only those that are gasses given the surface temperature.
Then we look in the system abundance, and copy all elements that pass the above filter. If the element is not a nonmetal and not a noble gas, we divide it's percent by it's atomic number * 10 - this makes it more unlikely for heavy elements to be part of the atmosphere.
Then, we pick a random element from the 5 most abundant elements and push it to the atmosphere composition composition with a random range between 0.5 and 0.9 (if this is the first element selected) or 0 and 1.0 - the sum total of all currently selected elements. We do this anywhere between 1 and 10 times, to get the major atmospheric composition.
** Limitations
- Elemental abundances are fully random beyond the top 10.
- Non-unary system generation is not implemented because I don't want to write the orbit math for it.
- Only main sequence stars are currently generated.
- Planetary orbits are circular, because I'm too lazy to do it otherwise.
- Volcanism is only based on tidal forces.
* FAQ
** What does "semi-realistic" mean?