PulseCore

Chapter 3 · Section 12

Wells and Sites in the Gravity Grid: binWells, nPull, wellsNear and the P³M Switch

The BPT law

BPT Part 3.14 (Galaxies: the Wells and the Stars Around Them) makes a galaxy "a well's basin gathering stars": its Data Matter, "laid on the scaffold before any matter (Part 3.13), is its dark halo; the Proto Well at the halo's densest place is its site, where its central well is born." Its reading of the game says a site "pulls and gathers its galaxy but is no well." The code reads that as a site that pulls only through the grid (matter.js:242–245, ruling 2026-10-29). How the pull is computed is not a BPT law. BPT does not state this; it is a game method that serves the Formation Condition's sites and the galaxies built round them.

The established physics

The particle-particle/particle-mesh (P³M) split: a mesh carries the long-range force, and near neighbors pull directly (Hockney & Eastwood 1988, as the code names it). Cloud-in-cell deposit and interpolation are part of the same method.

The game's math

The grids. Matter.meshForces(wells) matter.js:212 builds two potentials on the B-cell mesh by FFT Poisson.

  • (ar, ac), felt by bodies: matter + Data Matter + every well's mass, deposited cloud-in-cell.
  • (arW, acW), felt by wells: matter + Data Matter + sites only (Ms, matter.js:246–249). A well does not pull on itself through the grid, and a site is felt only here.

binWells(wells) matter.js:272:

  • nPull = the count of wells that are not sites.
  • Each well's softening _soft = reach(w) (Part 3.10) is stored once.
  • The pulling wells are binned by mesh block.
  • If more than 8 pull and the mesh is wider than 7 blocks, each well writes itself into the 7 × 7 blocks around it. A body's near-well list is then one lookup (2026-10-28; profiled: 14 % of a step).

wellsNear(r, c, R, wells) matter.js:291 returns the wells within R blocks:

  • all pulling wells when nPull ≤ 8, or when 2R + 1 spans the mesh;
  • the cached 7 × 7 list when R = 3;
  • else it gathers from the bins.

accel(b, wells, isWell) matter.js:331:

  • A site moves with the bodies' grid alone: cloud-in-cell interpolation of (ar, ac). No direct pull.
  • A body feels its grid and each well within 3 blocks directly, with the softened pull a = near·G·M/(d² + ε²) and near = max(0, 1 − d/(2B)), so the direct pull fades out by two blocks where the grid holds it.
  • A well, with nPull ≤ 256, feels the wells' grid (arW) and every other pulling well directly at every range (near = 1).
  • A well, with nPull > 256, is treated as a body: isWell is turned off, so it feels the full grid (wells included) and the wells within two blocks directly, fading. This is the P³M switch (2026-10-29; profiled at level 202).

In the game

This is what makes the stars gather. From the big bang on, the matter falls along the scaffold toward the sites, and the player watches filaments form, clusters gather where they cross, and galaxies settle round the sites and wells (the HUD epoch line reads "Universe · expanding, N% of its final size · M stars", app.js:2146–2148; the toasts "half grown" and "the web stands" at a = 0.5 and 0.9 are held while notices are quiet, app.js:672–673). Each galaxy's stars are drawn round its well's place every frame, following it as it moves (scene3d.js:615), and larger galaxies draw two or three cold streams of stars falling in along the filaments from their nearest neighbors (scene3d.js:563–565). A site itself is never drawn; it is seen only as the place its galaxy turns round. The drawer's "Colour by" menu, once there is matter, can show the motion (hue the direction, brightness the speed) or the density (index.php:188–189), so the pull of the grid toward sites and wells can be read directly.

The scale model

The mesh is drawn: B is chosen by meshB() app.js:1169 so the mesh is at most 64 blocks a side on a phone, and 128 or 256 on a desktop by cores and memory. That device switch belongs to the gravity chapter but sets the grid the sites live on. Masses are drawn masses. At level 202 on a desktop, 16,384 drawn Proto Wells less one in sixteen failed leave about 15,360 sites, which agrees with the comment's "15,000 sites".

Fixed numbers

Number Where What it is Kind
256 accel() matter.js:339 wells before P³M for wells METHOD (a cost switch between exact pairs and P³M; changes the force at long range only within the mesh's accuracy)
8 binWells() matter.js:281; wellsNear() matter.js:293 few wells: every well pulls directly METHOD (cost switch)
7, ±3 matter.js:281–286 the 7 × 7 near-well cache METHOD (a body's direct-pull reach of 3 blocks)
3 matter.js:349 a body's direct reach, in blocks METHOD (beyond 2 blocks the fade is zero anyway)
2 (2B) matter.js:352 the direct pull fades out by two blocks METHOD (P³M split radius; Hockney & Eastwood 1988)
0.5 matter.js:247, 336, 341 cloud-in-cell offset to the block center METHOD
1 matter.js:247 least well mass on the grid BPT (one Zinf quantum, Part 1.8)
64; 128, 256 meshB() app.js:1172 mesh blocks a side by device CAP (device-class switch)

Measured

  • "profiled at level 202: with 15,000 sites every well pulled every other directly, 2 × 10⁸ pairs a sub-step, a step took 53 s and the matter barely moved" (comment matter.js:332–333, 2026-10-29).
  • "profiled: 14 % of a physical step was each block of bodies gathering its 7 × 7 neighbourhood of well bins anew every sub-step" (comment matter.js:278–279, 2026-10-28).
  • "At level 202 a desktop holds 15,000 sites" (comment matter.js:245, 2026-10-29).