Tested Configurations
Adaptive Startup
On first load,adaptiveCount() selects a safe default organism count based on device capability:
pointer: coarse(touchscreen) → 2,000 (small screen) or 4,000 (tablet)- Wide desktop (>1500 px) → 8,000
- Mid desktop (>1100 px) → 5,000
- Narrower → 3,000
Spatial Hash Grid
The spatial hash grid is the single most important performance feature in Primordial. Without it, each of N organisms would need to check every other organism for behavioral interactions — O(n²) distance calculations, or 2.5 billion checks per frame at 50,000 organisms. With the grid:- The map is divided into 40 px cells.
- Each cell holds up to 64 organism references.
- Each organism checks only its 3×3 cell neighborhood — at most 576 candidates.
- In practice, each organism checks ~30–50 neighbors per frame.
- This reduces behavioral scan complexity to effectively O(n) — linear in organism count.
WebGL Rendering
All organisms and food pellets are rendered as point sprites using a single WebGL draw call per frame:- Four interleaved attribute buffers track position (x, y), hue, alpha, and size for every visible entity.
- Buffers are uploaded to the GPU as
DYNAMIC_DRAWevery frame — no persistent GPU state between frames. - The fragment shader computes a soft circular glow per point using HSV color, avoiding texture lookups entirely.
- Additive blending (when glow mode is on) allows thousands of overlapping sprites to composite naturally with no sorting required.
- Trail mode replaces the frame clear with a semi-transparent fade quad, creating motion trails with zero additional draw calls.
Structure of Arrays (SoA)
Organism data is stored in parallel typed arrays rather than an array of objects:Settings That Most Impact Performance
Browser Requirements
Primordial requires only WebGL 1 — no WebGL2, no extensions, no plugins. It runs in any modern browser:
The simulation runs fully offline — no network requests are made during simulation. The AI Lab Partner requires internet access (or a local model server) for API calls, but the simulation itself has no network dependency.