
I’ve always wanted to do this. And, I think, there’s still a lot of work to be done, but I’ll put this on GitHub and see if any others are interested in taking it on. I had my own personal goals when making it, specifically to combine the concept of Conway’s Cellular Automata with the birth of our universe from four fundamental forces. While I haven’t quite done that here, my goal, as almost always, was to see complexity evolve from simple rules.
As it is now, Primordial Cosmic Soup is a single self-contained HTML file with no external dependencies. It runs entirely in the browser using an HTML5 Canvas 2D context and vanilla JavaScript. There is no server, no required framework, and no build step required.
Performance-critical data is stored in typed arrays (Float32Array, Uint8Array) for cache-friendly memory layout. The spatial grid uses a linked-list bucket structure (gridHead / gridNext) rebuilt each frame.
┌──────────────┬─────────────────────────────────────────────────────────┐
│ Layer │ Technology │
├──────────────┼─────────────────────────────────────────────────────────┤
│ Platform │ Static browser app, single HTML file, zero dependencies │
├──────────────┼─────────────────────────────────────────────────────────┤
│ Language │ Vanilla JavaScript (ES6: arrow functions, class) │
├──────────────┼─────────────────────────────────────────────────────────┤
│ Graphics │ Canvas 2D API + rAF render loop │
├──────────────┼─────────────────────────────────────────────────────────┤
│ Simulation │ Particle-life w/ typed arrays + spatial-hash grid │
├──────────────┼─────────────────────────────────────────────────────────┤
│ UI │ Hand-written HTML/CSS (dark glassmorphism) │
├──────────────┼─────────────────────────────────────────────────────────┤
│ Docs tooling │ PowerShell + Word COM automation │
├──────────────┼─────────────────────────────────────────────────────────┤
│ Versioning │ Manual .zip snapshots (no VCS) │
└──────────────┴─────────────────────────────────────────────────────────┘
Because of this, you could open index.html directly in a browser and it should run, and all performance-critical work is done via typed arrays and a spatial grid rather than any external engine. Browsers these days are amazing! Included in that HTML5 file is an embedded (but downloadable) manual. It should make some sense of some of the bizarre choices I made while putting the app together using Claude.
Primordial Cosmic Soup is a simulation of emergent complexity inspired by particle physics, cellular automata, and agent-based modelling. A handful of
simple pairwise force rules between colored particle types is sufficient to produce rich, lifelike structures — orbiting clusters, crawling cells, crystalline lattices, and
chaotic flows — without any explicit instruction to form them. The key insight is that the attraction and repulsion values between types do not
need to be symmetric. Type A can strongly attract Type B while Type B mildly repels Type A, and the resulting asymmetry drives directional motion and the formation of multi-body structures.
When particles collide with sufficient energy, they spawn new daughter particles whose color is a blend of the two colliding parents. These daughter particles
belong to a named spawn class with its own randomized attraction rules, displayed in the sidebar. Over time, a rich ecology of base types and collision-born
offspring builds up — a primordial soup of emergent chemistry. The simulator uses four base particle types (Red, Green, Blue, Yellow), a spatialgrid force integrator, LHC-inspired collision effects, and a real-time side-panel UI so every rule can be adjusted while the simulation runs.
Every particle stores exactly four numbers at any given moment:
• x, y — position in the simulation world.
• vx, vy — velocity (world units per simulation step in each axis).
Additionally, every particle has a fixed type assigned at spawn time. Base particles carry one of four types (Red, Green, Blue, Yellow). Spawned (collision-born)
particles carry a spawn class index that points to their shared class record. A particle’s type determines which row of the attraction matrix, which friction value,
and which radius value apply.
Spawned particles also carry a lifetime counter (pLife) that counts down from a randomized maximum. When a spawned particle’s life reaches zero it is removed.
Setting Spawn Life to 0 in the global controls makes spawned particles immortal.
You can play with it here: https://xenius.org/PrimordialCosmicSoup/