README
¶
Particule Life Go
An interactive Particle Life simulation written in Go with Ebitengine. Colored particles follow a table of type-dependent forces, forming changing clusters and moving networks. The interaction from one type to another can differ from the reverse interaction.
The project is inspired by Lisyarus's explanation of Particle Life, with a selectable classic particle renderer, particle connections, motion trails, a density heatmap, and a spatially varying environment.
Preview
Watch the 30-second classic-mode MP4 · Local MP4
The video and GIF are silent; the application has no soundtrack. They show the selectable classic renderer from the first runnable revision, with opaque, fixed-size points on black. The recording uses 5,000 particles, four types and seed 59500, after 240 warm-up updates, at the normal 60 simulation updates per second. The current force rules and Perlin-noise environment remain active.
| Classic particles | Moving clusters | Later in the same simulation |
|---|---|---|
![]() |
![]() |
![]() |
The modern particle, trail and heatmap views remain available through H.
The classic particle style comes from commit 53cc939, the first revision with
runnable Go code. The initial repository commit contains no renderer.
All three screenshots are native 800×600 frames captured from the simulation.
Run
Use Go 1.24.5 or newer, as specified in go.mod, and a desktop graphics session. Dependencies are pinned to Ebitengine 2.8.8 and go-perlin 1.1.0; Go downloads them when needed.
git clone https://github.com/olivierh59500/particle-life-go.git
cd particle-life-go
go run .
Start directly with the classic appearance from the first runnable revision:
go run . -view classic
Press V to switch between classic and modern particles, or H to cycle all four views. The classic mode draws opaque, fixed-size colored points on black, without connection lines or the selected-type label. It uses the current simulation rules and environment; changing the view does not reset the particles.
To reproduce a scene or adjust the initial population:
go run . -view classic -particles 5000 -types 4 -seed 59500
-view accepts particles, heatmap, trails, or classic. Defaults remain
5,000 particles, four types, a fresh random seed and the modern particle view.
The selected seed determines the initial rules, environmental grid and particle
positions; interactive changes naturally alter the subsequent sequence.
To build an executable:
go build -o particle-life-go .
./particle-life-go
On Windows, build with go build -o particle-life-go.exe . and run particle-life-go.exe. The macOS build needs the Xcode Command Line Tools. Linux needs a C compiler, X11 development libraries, and a working graphics driver for this Ebitengine version; see its versioned Linux backend.
The font at assets/font.ttf is already included and embedded in the executable. No separate font download or runtime asset directory is needed. If you replace the font, rebuild the application; removing the file prevents the Go embed directive from compiling.
Explore the simulation
Start by watching the particles, then press R to randomize the interaction rules. The existing particles keep their positions and continue moving under the new matrix. Press H to compare the four visualization modes, Space to pause, and use the mouse wheel and left drag to inspect a region.
- Classic: the opaque circles and original type palette from commit
53cc939, with a fixed radius of two world units. Camera movement, zoom and periodic tiling remain available. - Particles: colored circles change size with speed and become more transparent in crowded areas. Lines connect nearby particles with sufficiently strong interaction coefficients.
- Heatmap: a red-and-blue approximation of local particle density, sampled every 10 world units. It uses a fixed sampling coefficient rather than the current force matrix.
- Trails: colored lines follow each particle's last ten update positions. Trails can span the screen when a particle wraps across a world edge.
Controls
| Input | Action |
|---|---|
Space |
Pause or resume |
R |
Randomize the force matrix |
H |
Cycle particles → heatmap → trails → classic |
V |
Switch between modern and classic particles |
E |
Toggle periodic rule mutation |
B |
Toggle experimental particle birth/death |
M |
Show or hide the experimental rule editor |
P |
Show or hide FPS, particle count, and occupied-bin count |
| Right click | Add one particle of the selected type at the pointer |
| Left drag | Pan the camera while the rule editor is closed |
| Mouse wheel | Zoom in or out, with a minimum zoom of 0.1 |
S |
Save the force matrix to config.json |
L |
Load the force matrix from config.json |
config.json is written in the working directory. It contains the interaction matrix, not particle positions or a complete simulation snapshot. Use a matrix saved with the same type count: the loader does not validate its dimensions.
Current interface limitations
The source's type selector currently interprets key codes as B / C / D / E for types 0 / 1 / 2 / 3, rather than the previously documented number keys. B and E also toggle their simulation modes. Newly injected particles use type 0 unless the selection is changed.
The rule editor currently draws an opaque white rectangle over its colored cells. Its input code adjusts a cell while the left button is held and the wheel moves, but the same wheel movement also zooms the camera. The particle, trail, and heatmap views shown above work independently of this editor.
Simulation settings
The launch options are defined in main.go; the simulation, existing views and input are in simulation.go. The classic renderer is in visualization.go.
| Setting | Default |
|---|---|
| World and window | 800×600 |
| Particle count | 5,000 |
| Particle types | 4 |
| Target update rate | 60 per second |
| Interaction radius | 50 world units |
| Short-range collision radius | 5 world units |
| Collision strength | 2.0 |
| Base friction | 0.1 |
| Base force scale | 1.0 |
| Integration step | 0.1 |
| Initial force coefficients | Random values in [−1, 1] |
Particle coordinates wrap at the world edges. A Perlin-noise grid varies friction and force strength across the world. With rule mutation enabled, every 1,000 updates each matrix entry receives a small random change and is clamped to [−1, 1]. The optional lifecycle removes isolated particles and creates particles in dense bins.
Use -particles and -types to choose the initial population and type count, and -seed for reproducible initial conditions. The editor defines MaxTypes = 16; its current display and input limitations are described above.
Implementation and performance
Particles are grouped into spatial bins so force calculations inspect nearby cells. A goroutine processes each occupied bin, then the simulation applies the calculated velocities, friction, and position updates. Ebitengine renders the result.
Performance depends on particle count, clustering, and the visualization mode. Dense clusters increase the number of neighboring pairs, and the heatmap samples particles across the visible world. The 60 Hz update setting is a target rather than a benchmark. The classic renderer draws only the particles and does not perform the neighborhood queries or connection drawing used by the modern view.
For more detail, see ALGORITHMS.md and SIMULATION.md. The README's interface notes describe the current implementation where those design documents differ.
Credits and license
- Go implementation: Olivier Houte.
- Inspiration: Lisyarus — Particle Life simulation in browser using WebGPU.
- Rendering and input: Ebitengine.
- Environmental noise: go-perlin.
The repository includes the GNU GPL v3 license.
Documentation
¶
There is no documentation for this package.



