Chapter 5 · Section 8
Drawing the Stars in Lots
The BPT law
BPT Part 6.10's Game's Reading says only that each star draws "its mass from its cloud's gas", and BPT Part 2.9's Initial Mass Function gives the share of stars at each mass, with ξ₀ "how much gas the region turned into stars". Together they fix what an honest draw must do: turn a mass of gas into a number of stars whose masses follow the function. How many stars are drawn at once, and how they are grouped, BPT does not state; it is a game method serving the Initial Mass Function and the Gas Depletion Law.
The established physics
An unbiased draw: the expected number of stars is the gas set aside over the mean birth mass, each mass drawn from the whole function, so the mass balances on average. Waiting until each drawn star can be afforded biases toward small ones (measured, 85 % brown dwarfs; stars.js:186–187).
The game's math
stars.js:186–203, for a body past the gate:
mean = MEAN_MASS[metal-free ? 300 : 150] 27.1 or 0.390 Suns
λ = pend / mean
k = ⌊λ⌋, plus one with probability λ − ⌊λ⌋ (draw(seed ^ 0x5bd1e995, formed + 7))
pend -= k · mean
draws = min(k, 48); base = ⌊k / draws⌋; extra = k mod draws
for d in 0 .. draws−1:
m = sampleIMF(draw(seed, formed + d), metalFree)
n = base + (1 if d < extra else 0) stars in this lot, all of mass m
need = n · m · S.sun cells of gas
if not takeGas(b, need): stop
add n stars of mass m, born now, to a lot with the same mass bin and birth Tempo, or a new lot
formed += k
takeGas(b, need) stars.js:158 takes the gas from the body first, then from the other bodies of its cloud (moving their mass into this body), and fails if the cloud holds less than need. A lot is matched by mass bin mb = round(20·log₁₀ m) (0.05 dex), birth Tempo pb = ⌊now⌋ and metal-freedom; joining a lot averages its metals (stars.js:197–198).
b.sfAcc accumulates the gas turned into stars, read by the galaxy's central well for its feeding (feedWellFromStars() app.js:3060, documented with the galaxies in Chapter 6).
Worked case: a body with pend = 20 Suns in ordinary gas: λ = 20/0.39 ≈ 51.3, so k = 51 or 52; draws = 48; base = 1, extra = 3 or 4: three or four lots of two stars and the rest of one.
In the game
Lots are not shown as such. A body's drawn points cycle through its lots, brightest first (scene3d.js:761, 769), so a lot of many stars of one mass is drawn as that many points of one look. Each birth, death or giant marks the body changed (b.starsV, stars.js:202, 207, 213), and the scene recolors its points only then (scene3d.js:759). The count of stars made goes to the HUD and, as formed, to the end card's Stars born (app.js:2745, 2783).
The scale model
Each drawn star stands for starMult real ones (Part 5.3); each lot is n drawn stars of one mass.
Where the game and the theory differ
- The lots of 48. At most 48 distinct masses are drawn per body per sub-step; with k > 48 stars, each lot holds about k/48 stars of one drawn mass. The total number and the mean mass are kept; the spread of masses within one sub-step's birth is limited to 48 values, against a function that has a mass for every star.
- The formed count can outrun the stars made. If
takeGasfails partway (the cloud runs short), the loop stops, butpendwas already reduced by k·mean andS.formedstill adds all k (stars.js:191, 202). The stars not made are lost frompendand counted informed;ev.bornand the lots count only those made. "Stars born" on the end card readsformed(app.js:2745, 2783).
Fixed numbers
| Number | Where | What it is | Kind |
|---|---|---|---|
| 48 | stars.js:192 | Most distinct mass draws per body per sub-step | CAP |
| 0x5bd1e995, 7 | stars.js:189 | Hash salt and offset for the extra-star draw | METHOD |
| 20 | stars.js:194 | Lot mass bins per decade | METHOD |
| 10⁻¹² | stars.js:161 | Gas below which taking stops | METHOD |