gizmobench

Particle Life Sandbox

A particle life simulator: up to 2,000 particles of 1 to 8 species move in a flat world, and every pair closer than the interaction radius pulls or pushes according to an attraction matrix you edit cell by cell, from -1 to 1, with a short-range push that keeps particles from piling onto one point. Force scale, interaction radius, friction, timestep and wrapping or repelling edges apply the moment you change them, and brushes add or erase particles at any time and attract or repel them while it runs or steps. Layouts are scattered from a seed and stepping uses no randomness, so the same project steps the same way every time. The numerical limits are on the page: the timestep, the kinetic energy and the largest move of the last step are shown under the canvas, and a step that would move any particle farther than the interaction radius stops the run with a message naming the particle and the distance instead of letting the numbers run away. Download project saves the whole sandbox as a JSON file that Open project restores.

Your input

Layout, from a seed
Rules, applied at once
Edges
Steps per frame

Result

Add as
Brush radius
The particle canvas needs a browser that can draw on a canvas. The summary and tables below describe the same simulation.

600 particles of 3 species, world 800 by 600 with wrapped edges, step 0, paused. Teal 200, amber 200, plum 200. Kinetic energy 0.0 (model units, mass 1 per particle). Most crowded ninth of the world: bottom center, 82 particles; emptiest: top center, 56.

Attraction matrix: each row is the species that moves, each column the species it reacts to. Positive pulls, negative pushes, from -1 to 1.
moves / totealamberplum
teal
amber
plum
Particles
600
Species
3
Kinetic energy (model units)
0.0
Timestep
0.01
Largest move last step
0.00 of 80 allowed
Step
0, paused

The canvas in numbers

These tables follow the simulation: they refresh a few times a second while it runs and after every step or edit.

Particles by species
SpeciesParticlesMean speedKinetic energy
1, teal2000.00.0
2, amber2000.00.0
3, plum2000.00.0
Particles in each ninth of the world
rowsLeftCenterRight
Top585661
Middle766268
Bottom668271

Worked cases

  • At restforce scale 0, zero velocity, 100 steps
    no particle moves (max displacement 0)
  • Wrap boundaryx 803 and y -5 in a world 800 by 600
    maps to x 3, y 595
  • Energy readoutvelocities (3, 4) and (0, 1), mass 1
    kinetic energy 13

Click, drag or touch the canvas to use the brush. With a keyboard, Tab to the canvas, move the cursor with the arrow keys (hold Shift for 50 units a press instead of 10) and press Enter or Space: Add places 12 particles of the chosen species inside the brush radius, Erase removes every particle inside it, and Attractor or Repeller switches on at the cursor, follows the arrow keys, and goes off with Enter, Space or Escape. A held attractor or repeller acts only while the sandbox runs or steps. On a device that asks for reduced motion the sandbox opens paused.

How it moves. Every pair of particles closer than the interaction radius pulls or pushes along the line between them. Inside the core, the first 30% of the radius, they always push apart, hardest at contact. Beyond it the matrix value for the moving species and the other one takes over, rising from 0 at the core edge to its full value at 65% of the radius and falling back to 0 at the radius. The sum is scaled by the force scale times the radius. Each step keeps 1 minus the friction of every velocity, adds acceleration times the timestep, then moves each particle by velocity times the timestep. Wrapped edges bring a leaving particle in on the other side and measure distances the short way round; repelling edges push particles out of the core distance of each wall and bounce any that cross. The matrix need not be symmetric, so one species can chase another that flees.
Limits. Up to 2,000 particles and 8 species; matrix values from -1 to 1; force scale 0 to 50; interaction radius 10 to 200 units and at most half the shorter side of the world; friction 0 to 1 per step; timestep 0.001 to 0.1; world 100 to 2,000 units a side. A step that would move any particle farther than the interaction radius, or produce a value that is not a finite number, is refused: the run stops at the last good step, and the message names the particle and, for a runaway, how far it would have moved.

Common questions

What is particle life?
An artificial-life toy in which particles of a few species follow one simple pair rule: each pair closer than a set distance pulls together or pushes apart by an amount that depends only on the two species. Here the rule is a matrix you edit. Inside the core, the first 30% of the interaction radius, every pair pushes apart, hardest at contact; beyond it the matrix value takes over, rising from 0 to its full value at 65% of the radius and back to 0 at the radius. From those local rules the particles can settle into clumps or keep chasing one another in moving groups that nobody drew.
How do I read the attraction matrix?
Each row is the species that moves and each column is the species it reacts to. A positive value pulls the row species toward the column species, a negative value pushes it away, and the range is -1 to 1. The matrix does not have to be symmetric: if teal is drawn to amber while amber flees teal, teal chases amber. The Chase ring preset sets that up for every species at once: with three or more species, each gets 0.6 toward the next species, -0.6 from the previous one and 0.3 toward its own kind; with two species, teal gets 0.6 toward amber, amber gets -0.6 from teal and each gets 0.3 toward its own kind.
What do friction and timestep change?
Friction is the share of each particle's velocity removed on every step, from 0 (none) to 1 (all of it). The timestep, from 0.001 to 0.1, sets how far one step moves the simulation on: each step adds acceleration times the timestep to the velocity, then moves each particle by velocity times the timestep. A larger timestep runs faster but is coarser, and with low friction and a strong force it can make particles overshoot.
Why did the simulation stop with an error?
Because a step would have moved a particle farther than the interaction radius, or produced a value that is not a finite number. At that point the model can no longer follow the pulls and pushes it is meant to show, so the step is refused, the run pauses at the last good step, and the message names the particle, the timestep and the force scale, and for a runaway how far the particle would have moved. Lower the timestep or the force scale, or raise friction, then press Step or Play.
Does the same seed give the same result?
Yes for everything the page decides. A layout's positions come from its seed, the Seeded random preset draws its matrix from the seed, and stepping itself uses no randomness, so the same project steps to the same positions every time. Particles you add with the brush are placed by a generator whose state is saved in the project. What the seed cannot repeat is your own hand: a stroke or a held attractor acts at whichever step you make it.
Can I save a setup or copy the matrix?
Download project saves a JSON file with the matrix, the rules, the seed, the brush generator's state, the step count and every particle's species, position and velocity, and Open project loads it back paused at that step. A file that is not a valid project is refused with the reason and your current sandbox stays as it was. Copy matrix copies the matrix as tab-separated rows with species names. Once you change something, this browser also keeps your latest sandbox and reopens it paused on your next visit.
Can I use it with a keyboard or a screen reader?
Yes. Every setting and matrix cell is a labelled field. Tab to the canvas, move the brush cursor with the arrow keys (10 units a press, 50 with Shift) and press Enter or Space: Add places 12 particles of the chosen species inside the brush radius, Erase removes every particle inside it, and Attractor or Repeller switches on at the cursor and off again with Enter, Space or Escape. Below the canvas a text summary and two tables give the particle count per species, their mean speed and energy, and how many particles sit in each ninth of the world.
Is this a physics or chemistry simulation?
No. The units are made up, the pulls in a pair need not be equal and opposite, and any friction above 0 drains energy on every step, so it models no real molecule, cell or material and predicts nothing about one. It is a sandbox for seeing how simple local rules can produce patterns.

An illustrative artificial-life model; no molecular, biological or physical prediction claim. Numerical limits and timestep are visible.