Sep 17, 2026

Energy Conserving Particle Life

Run ECP-Life in your browser — needs WebGPU, so Chrome or Edge. The code is at aprowe/ecp-life.

Particle Life

I find particle life to be a mesmerising example of emergent behaviour. If you haven't seen it, play with it at particle-life.com, or watch Tom Mohr's video that got a lot of people (me included) into it.

Classic particle life: thousands of coloured particles on black, gathered into rings, cells with a nucleus, and loose chains
Fig. 1 — Classic particle life. A handful of colours and a small matrix of who attracts whom, and that's all the rules there are.

It's a fairly simple set of rules. Particles come in multiple hues, and each colour either attracts or repels each other colour. The interesting behaviour comes when particles disagree: A repels B, while B attracts A. This creates a chasing mechanic where pairs will propel themselves across the area.

A 5×5 attraction matrix next to the tent-shaped force curve
Fig. 2 — Left: the matrix. Entry (i, j) is how colour i responds to colour j; blue attracts, red repels. It isn't symmetric, and that asymmetry is where all the chasing comes from. Right: the force against distance, a hard repulsive core and a tent that falls to zero at the cutoff.

It looks like little life forms, but that's about it. After playing with it for a while, it can be hard to find new behaviours.

A Continuous Hue

My first thought was: what if, instead of N hues, hue were a continuous interaction spectrum? The hope was that this spectrum could be tweaked at a higher level of detail and bring in more complexity than a discrete matrix. It allows for a wider range of interactions. Hues can have stronger or weaker forms of the same interaction: A attracts B, but a slightly different A attracts B slightly more.

A 5×5 lookup table painted on the hue wheel, next to a smooth noise field over the same axes
Fig. 3 — The same idea at two resolutions. Both axes are hue. Left is a species matrix painted onto the hue wheel; right is a noise field over the pair of hues, which wraps at every edge because hue is an angle.

Then, what if we generated that continuous spectrum with a CPPN? Could we run a genetic algorithm to find interesting landscapes?

I do think this experiment revealed some structures of higher complexity, but nothing too novel.

Energy Conserving

The thing that always nagged at me about particle life was the fact that it's not energy conserving. The chase mechanic means free energy for particles, and the sim explodes unless you give it a large amount of damping. This also hurts the search for self-propagating forms. If you have infinite energy, what's driving the selection? If a self-propagating pattern emerges from a simulation where energy is limited, then it's doing something to sustain itself, and we are closer to something life-like.

That free energy comes from the chase mechanic: the asymmetric interactions. Any interaction matrix can be split into a symmetric half and an antisymmetric half. The symmetric half is ordinary physics, an equal and opposite force on the pair. The antisymmetric half pushes both particles the same way, and it's the only thing in the system that does net work.

Two particles with the bond force drawn as equal and opposite arrows, and the chase force drawn as two arrows pointing the same way
Fig. 4 — Both halves of a particle-life matrix, as forces on a pair. The left half is physics. The right half is the reason particle life needs friction.

How can we limit this? This is where the continuous hue comes in. We can consider an asymmetric pair to be high in colour-based potential energy, and a symmetric pair low. Two attractive particles next to each other is the lowest potential energy it could be. All we need to do is change the particles' colour as they accelerate, to pay for the energy put into the system.

This means a chaser in classic particle life will accelerate while slowly changing colour, until it becomes an inert blob of a single colour. Since energy is conserved, we can turn the damping way down and get more nuanced interactions. A simple chaser will die; one that can keep finding ways to replenish its colour energy will sustain itself.

Two particles of the same colour after a chase, with a strip below showing the battery draining into kinetic energy while total energy stays flat
Fig. 5 — A chase pair, burned out. The battery (red) drains into kinetic energy (blue) and the total (thick) stays flat. This is a still from a live version you can poke at.

This mechanism also needs to work the other way around. Some of the kinetic energy that would be imparted onto a pair of particles can instead be transferred into its colour energy, which gives it a way to recharge particles. Think of it like regenerative brakes: as an inert pair comes to a stop via an external force, some of that energy goes to the colour store.

The Bonding Well

The last part of this is how we can get larger structures to form in particle life. Classic particle life has a triangle-shaped radial force. This works for interesting movement, but doesn't allow for crystal structures or larger-scale rigidity. By giving our radial force between particles a deep well, we can introduce bonding between particles.

The tent potential and the well potential side by side, with the force curve each implies
Fig. 6 — Grey is the particle-life tent, drawn as the potential it implies (left) and the force it is (right). Blue is the well. The tent's energy has no minimum except the hard core, so a bonded pair has nowhere to rest. The well has a floor, where the force crosses zero: pushing apart inside it and pulling together outside.

This synergises especially well with the energy conservation, because of the energy that can be stored and transferred in bonds. Repelling pairs can be caught in a bond, storing potential energy; chasing pairs can be small units that spin, or be part of a larger unit.

Current Status

With all these changes, the input space is MASSIVE. I'm still trying to find a decent set of physics that produces consistently interesting interactions. Once I've gotten a handle on that, I would love to start digging into the interaction matrix and find sets of rules that create interesting behaviour. I'm convinced there's a set of interactions out there that will produce something more life-like than we have seen in particle life: something that has a metabolism, using high-energy colours to propel itself in just the right way so it can find more energy to stay alive.

I've built a GPU version using my crate fathom, which runs natively and in the browser from the same code. You can try it now:

The code is on GitHub at aprowe/ecp-life.

All writing