PulseCore

Chapter 6 · Section 1

From a Field of Bodies to Galaxies

BPT Part 3.14 (The Game's Reading) states the method this chapter documents: "A galaxy in the game holds tens of bodies, not the hundred thousand arms need ... So, as cosmological simulations do, its inner structure is drawn by the known laws from what the simulation measures in it: from the mass round its well, its rotation curve, and from that its shear rate, epicyclic frequency, disk surface density, its number of arms (Arm Number) and their pitch (Arm Pitch Angle); the disk itself turns by the Disk Turn Rate on a flat curve, each star on its own orbit, the arms' pattern with it, in the galaxy's own sense." The simulation decides where each galaxy is, which bodies and stars are its own, its mass, gas, metals, young share, turning sense, the mass profile round its well, and how it moves. The laws decide its arms, pitch, disk scale length, turning rate and inner layout, from the numbers the simulation measured.

The reading runs in a fixed order, once two steps of pulseCounter (one Pulse, GAL_EVERY) have passed since the last, from the Physical Nova on (from v8.6, 14 November 2026; before, every 8 steps by the step's own number, which the paced mode's later wells tick seldom met, Part 6.11): measureFeeding() app.js:793, which stepWells() app.js:818 calls each step, calls updateGalaxies() app.js:3130 at app.js:816.

  1. The index. galaxyIndex() app.js:2956 bins all bodies, gives each body to the well that pulls it hardest, measures each well's halo reach, makes every well inside a heavier halo that halo's satellite, and reads the knee of the galaxy mass function. (Part 6.2.)
  2. Each galaxy read once. galaxyOf() app.js:3000 reads, for every non-stellar well, the bodies it owns: their mass, rotation, gas, metals and stars, its type, its disk, arms and pitch, its brightest kinds of star, and its true and drawn size. (Parts 6.3 to 6.5.)
  3. The wells fed, the sites sized and tested. Each well is fed from its galaxy's star formation (wells chapter); each site's halo and core radius are set by haloRadius() (Part 6.7); the waiting sites are tested for direct collapse (wells chapter).
  4. Star formation by heat. Each body's sfHeat and gal are set from its galaxy's heat (stars chapter); the literals sit in updateGalaxies() and are listed in Part 6.6.
  5. The list for the scene. Every galaxy with lit stars, not a cloud and not empty, goes on the list with its turn rate from diskTurnRate() (Part 6.6); each is enlarged toward its nearest neighbor (Part 6.5) and handed to setGalaxies() scene3d.js:483 (Part 6.8), which also lays out the streams (Part 6.9).

Each frame, placeGalaxies() scene3d.js:616 puts every galaxy point round its well's current place and turns it, and placeStreams() scene3d.js:598 moves the stream stars in.

Separately, at every life sample, sampleSites() app.js:1489 measures how much of the surface lies inside the sites' cores, for the Site Lift (Part 6.7), and the field drawing marks the web's dense places (Part 6.10).

Two things this code calls belong to other chapters and are only referenced here: the heat of a galaxy's gas and its star formation share (galaxyHeat in heat.js, the stars chapter) and the feeding and direct collapse of the wells (feedWellFromStars, testDirectCollapse, the wells chapter). Their literals in this code are listed where they sit.

What the player sees, in order. Before the Physical Nova (Harmonic 3, the big bang) there is no matter and no galaxy. From it, the 3D view of the torus fills with matter; the readings begin, and a galaxy is drawn round a well as soon as the bodies it owns hold living stars. In a universe too shallow for stars (below the star line) no galaxy is ever drawn, and the Language Block marks every galaxy line "skipped: no stars". Over the life the galaxies turn, grow, merge and change type as their stars age; when the universe returns to the Source the galaxies fade out with the rest of the scene, and in the full decay they are cleared once the matter is in (app.js:2681). After the return, a tap on a well opens the banner that names its galaxy (Part 6.3). All of this is drawn only in the 3D view ("3D · the torus" in the view menu); the 2D field view shows the data, not the galaxies.

The method, in plain steps:

every 8 flips, from the bodies of matter:
    give every body to the well that pulls it hardest (the galaxy index, Part 6.2)
    read each well's galaxy: its mass, its spin, its stars, its gas, its type (Part 6.3)
    measure its disk: rotation, shear, arms, pitch (Part 6.4); its size (Part 6.5)
    set its turn (Part 6.6), its site's sizes (Part 6.7), and hand the list to the scene to draw (Parts 6.8 to 6.10)

The code:

// public/game-v8.4/app.js:3130 updateGalaxies()
function updateGalaxies() {
    if (!rings || !matter || !matter.bodies || novaCount < U.PHYSICAL_LAYER) return;
    const top = rings.sources.filter((w) => !w.stellar).sort((a, b) => (b.mass || 0) - (a.mass || 0)), list = [], idx = galaxyIndex(top);
    /* ⚠️ WHERE GAS CAN FORM STARS (2026-10-28; book Part 3.12): each galaxy's gas forms stars at the share its heat allows (heat.js
       galaxyHeat: full while it cools faster than it falls, t⇓/t⊹ when not, none in a hot halo its feeding well keeps hot, less in a
       small galaxy after reionization); gas outside every galaxy, after reionization, is too warm to collapse. stars.js reads b.sfHeat. */
    const lf = physStart !== null && physLife ? (pulseCounter + subDone - physStart) / physLife : 0, field = lf >= 0.75 / 11.0 ? 0 : 1;
    for (const b of matter.bodies) { b.sfHeat = field; b.gal = null; }
    /* its winds' reach (stars.js, Wind Mass Loading; book Part 3.12, Winds): escape speed v_esc = v_c·√(2(1 + ln 10)) for gas at a tenth
       of the halo's reach (Halo Escape Speed), over light physical, and comoving in cells a flip; hot for its cooling time, at most the
       billion years a fountain takes to fall back (Oppenheimer et al. 2010) */
    const lightC = matter.light || lightCells(), aG = Math.max(1e-6, expansionA()), ESC = Math.sqrt(2 * (1 + Math.LN10));
    const gs = top.map((w) => galaxyOf(w, idx));   /* each galaxy read once a reading (it was read twice, 2026-10-28) */
    top.forEach((w, i) => { w._mdot = 0; if (w.heart) { heartNow(w); w._feed = null; w._lam = 0; } else w._lam = 0; const g = gs[i];   /* a heart banks its growth so far; a fresh feeding starts (or none, with no stars forming round it) */ if (!w.site && g && g.bodies && g.bodies.length) feedWellFromStars(w, g); });
    top.forEach((w, i) => { w.siteR = haloRadius(w, gs[i], 0.9); w.siteCore = haloRadius(w, gs[i], 0.5); });
    testDirectCollapse(top, gs);
    for (const b of matter.bodies) b.sfAcc = 0;   /* read once: the next reading counts afresh */
    for (let i = 0; i < top.length; i++) { const w = top[i], g = gs[i]; if (g && g.heat && g.bodies) { const besc = ESC * (g.heat.vc || 0) / 299792.458, gal = { r: w.r, c: w.c, vr: w.vr || 0, vc: w.vc || 0, besc, vesc: besc * lightC / aG, hot: Math.min(g.heat.tcool, 1e9 * 3.15576e7) / LIFE_S * (physLife || 0) };
            for (const b of g.bodies) { b.sfHeat = g.heat.f; b.gal = gal; } w._vHalo = besc / ESC * lightC / aG; }
        if (scene && scene.setGalaxies && g && g.alive > 0 && g.type !== 'cloud' && g.type !== 'none') list.push({ id: w.id, r: w.r, c: w.c, type: g.type, stars: g.alive, sense: g.sense, R: g.R, rd: g.drawRd, hideR: g.hideR, arms: g.arms, pitch: g.pitch, omega: diskTurnRate(w), gamma: 1, pop: g.pop, seed: w.id }); }
    /* ⚠️ GALAXIES DRAWN WHERE THEIR TURNING CAN BE SEEN (2026-10-29, the author; measured: drawn at a disk's true size a galaxy was about 5 px across
       at the default view, 300 stars in a dot): each is drawn nearly halfway to its nearest neighbour (0.45), never under its own size nor
       past 0.45 of the field's mean spacing between galaxies, its scale length with it (book Part 3.14: drawn enlarged, as the field is far coarser than any disk) */
    { const cap = 0.45 * Math.sqrt((rows * cols) / Math.max(1, list.length)); for (const g of list) {   /* the cap: 0.45 of the field's mean spacing between galaxies (2026-10-29; was 20 cells of 256) */ let nn = Infinity; for (const o of list) if (o !== g) { const d = Math.sqrt(wrapDist2(o.r, o.c, g.r, g.c)); if (d < nn) nn = d; }
        const R2 = Math.max(g.R, Math.min(cap, 0.45 * (Number.isFinite(nn) ? nn : 3 * cap))), k = R2 / Math.max(1e-6, g.R); g.R = R2; if (Number.isFinite(g.rd)) g.rd *= k; } }
    if (scene && scene.setGalaxies) scene.setGalaxies(list);
    for (const g of list) routinesSeen.add('galaxy:' + g.type);
    if (matter.stars && matter.stars.byType && matter.stars.byType.giants) routinesSeen.add('giants');
}