Skip to content

Getting Started

m4bwav edited this page Oct 4, 2026 · 1 revision

Install

dotnet add package UniverseGenerator --version 1.0.0

Or in a project file:

<PackageReference Include="UniverseGenerator" Version="1.0.0" />

The package has two builds, lib/net10.0 and lib/netstandard2.0, and no dependencies. A .NET 10 project loads the net10.0 build; .NET Framework 4.8 loads the netstandard2.0 build. Both were run for this wiki (the .NET Framework run reported .NET Framework 4.8.9345.0 and lib .NETStandard,Version=v2.0) and printed the same output for every example. The README calls the package trimmable and AOT-compatible; this wiki did not test a trimmed or native AOT build. Other .NET versions that read netstandard2.0, Mono and Unity: not tested here. Unity has its own package, described in the README.

Everything is in one namespace:

using UniverseGeneration;

A galaxy at a glance

using UniverseGeneration;

var galaxy = Galaxy.Generate("my-seed");
Console.WriteLine(galaxy.Name);
Console.WriteLine(galaxy.Descriptor);
Console.WriteLine($"{galaxy.Shape}, {galaxy.Map.Count} systems, {galaxy.Lanes.Count} lanes, {galaxy.Regions.Count} regions");

var system = galaxy.System(0);
Console.WriteLine(system.Descriptor);
Console.WriteLine(system.Star.Description);
foreach (var planet in system.Planets)
    Console.WriteLine($"  {planet.Name}: {planet.Descriptor}");

prints:

Wyvern Galaxy
a ring galaxy
Ring, 60 systems, 71 lanes, 7 regions
an orange dwarf and red dwarf pair with 6 planets and an asteroid belt
orange dwarf
  HD 147927 e: a warm desert world under an orange dwarf
  HD 147927 c: a warm rocky world under an orange dwarf
  HD 147927 d: a warm mini-Neptune under an orange dwarf
  HD 147927 f: an ice giant far from an orange dwarf
  HD 147927 g: a gas giant far from an orange dwarf
  HD 147927 b: an ice giant far from an orange dwarf

galaxy.Map is the cheap view: one MapEntry per system with its name, position, star class, region, danger and faction. galaxy.System(i) and galaxy.Systems give the full star system, built the first time you read it. A 2,000-system galaxy therefore costs little until you open its systems. The planets are listed by orbit, innermost first, but their letters are not in orbit order: here e is the innermost (the orbits are on Plausibility rules).

Every level on its own

Each level has its own Generate, and a seed gives a different but stable object at each level:

using UniverseGeneration;

Console.WriteLine(Universe.Generate("my-seed").Name);
Console.WriteLine(GalaxyCluster.Generate("my-seed").Name);
Console.WriteLine(Galaxy.Generate("my-seed").Name);
Console.WriteLine(StarSystem.Generate("my-seed").Descriptor);
Console.WriteLine(Planet.Generate("my-seed").Summary);
Console.WriteLine(StarName.Generate("my-seed").Name);

prints:

the Pale Reach
Halcyon Group
Wyvern Galaxy
a red dwarf with 3 planets and an asteroid belt
1.3 g, nitrogen air at 0.6 bar, -37 °C; hazard 2
HD 45528

A system made by StarSystem.Generate("my-seed") is not system 0 of Galaxy.Generate("my-seed"): its address is v1-my-seed/system, a different place from v1-my-seed/galaxy/system/0. See Same seed, same galaxy.

Seeds

A seed is any text of up to 200 characters, or a 64-bit number. A number is the same seed as its digits:

using UniverseGeneration;

var a = Galaxy.Generate(42);
var b = Galaxy.Generate("42");
Console.WriteLine(a.Address);
Console.WriteLine(a.ToJson() == b.ToJson());

prints:

v1-42/galaxy
True

Seeds are compared exactly: case and spaces count. The details are on Same seed, same galaxy.

Next

Clone this wiki locally