Skip to content

Generation Overview

Red Reaper edited this page Oct 11, 2026 · 5 revisions

Generation overview

See generators folder and system-gen.js file specifically.

The process is driven by SystemGenerator class object from system-gen.js. Calling startGeneration() method does the following:

  1. Seed & setup
    • Uses a user-provided seed (or generates a new one if user seed is not set).
    • Seeds the PRNG.
    • Creates a new System object from the current GeneratorSettings.
  2. Star formation (star-system-gen.js)
    • Generates the primary star (or close binary) via generateStarFormation(). Star instances generation is handled by star-gen.js.
    • Optionally adds a secondary single/binary star on a wide orbit.
    • Stars can form hierarchical systems (single → binary → triple/quadruple).
  3. Planet generation around each star/binary (planet-system-gen.js + planet-gen.js)
    • For every star (or binary), generates a set of planets.
    • Planets receive initial semi-major axes, masses, and basic properties (stage 1).
  4. Planetary migration simulation (migration-sim.js)
    • Runs a discrete-time simulation of Type I / Type II migration inside a decaying protoplanetary gas disk.
    • Planets migrate inward (or outward under Grand Tack conditions for giants ≥ ~60 M⊕).
      • Optional "Grand Tack" can reverse giant migration when multiple giants are present later in the disk lifetime.
    • Close encounters are resolved via mutual Hill-sphere checks:
      • Merge (mass + composition combined, impacts counted)
      • Eject
      • Orbital scattering / shift
    • Bodies that fall inside the Roche limit or become unstable are removed.
  5. Stage 2 planet generation + moons
    • For surviving planets: more detailed physical properties generated (planetGeneration_Stage2() in planet-gen.js).
    • Moon systems are generated around them (moon-system-gen.js).
  6. Finalization (stage 3) & orbital setup
    • Bodies are sorted by orbital distance.
    • Recursive passes over the entire hierarchy (binaries → children):
      • Calculates the final set of physical properties for planets.
      • Sets full orbital elements (semi-major axis, eccentricity, inclination, argument of periapsis, mean anomaly, etc.).
      • Computes orbital periods, speeds, synodic days, and min/max temperatures.
  7. Optional filtering (see Generation filters)
    • If the filtering is enabled, a filtering script is applied which stops the systems generation loop or continues it (restarting the whole system generation).
    • The generator retries (up to 1000 attempts) until the predicate succeeds or the limit is reached. Pre-generation, predicate, and post-generation scripts can be run (eval’d in the browser).
    • Status is reported in the UI.
  8. Generated system is passed via Event Bus to the Renderer (renderer.js), which prepares the system for visualization and initiates the inspector profiles generation (inspector.js).

"The Butterfly Effect"

Only one instance of PRNG is currently being used in the system generation process. Every time when PRNG is called, it returns a random value and increments the seed value internally. Thus, any change in number of calls at one stage of the generation significantly alters the outcome of all following operations. Until the sub-seeding has not been implemented, systems generated with the same seed but with different generators will continue to be drastically different.

Clone this wiki locally