Real-Time GPU-Accelerated
Artificial Life Simulator
A desktop-native implementation of Lenia, the continuous cellular automaton system discovered by Bert Chan. Built from the ground up in C++20 with OpenGL 4.5+ compute shaders, this simulator achieves real-time performance on grids up to 2048×2048 cells while maintaining smooth 60+ FPS interaction.
The engine supports classic single-channel Lenia, multichannel RGB dynamics with up to 16 simultaneous interaction rules, and includes an extensive library of 548 pre-catalogued species ready for exploration.
Core Capabilities
GPU Compute Pipeline
The entire simulation state resides in VRAM using double-buffered textures. Convolution, growth function evaluation, and state integration execute as parallel compute shader dispatches, achieving throughput exceeding 10 billion cell updates per second on modern hardware.
548 Catalogued Species
An extensive preset library spanning single-channel creatures like Orbium, Scutium, and Hydrogeminium, through to complex multichannel organisms exhibiting predator-prey relationships. Each species includes tuned parameters for stable locomotion and pattern preservation.
Multichannel Dynamics
Support for 1-3 independent channels visualized as RGB, with up to 16 simultaneous interaction rules. Cross-channel growth enables complex emergent behaviors: symbiosis, competition, and predation patterns that single-channel systems cannot produce.
Real-Time Analysis
Live pattern tracking computes mass, centroid, velocity, and periodic behavior detection. Auto-pause triggers when patterns stabilize or go extinct. Professional graphing with labeled axes provides temporal visualization of all tracked metrics.
Rendering Pipeline
Compute shader generates normalized kernel texture from parameters (R, β, α). Supports 10 kernel types including Gaussian shell, polynomial bump, and multi-ring configurations.
kernel_gen.compSpatial convolution computes neighborhood potential for each cell. Workgroup-local caching minimizes global memory bandwidth. Output stored in intermediate texture.
sim_spatial.compGrowth function maps neighborhood potential to state delta. 11 function types available. Euler integration with configurable Δt updates state, clamped to [0,1].
sim_multichannel.compFragment shader applies selected colormap to state texture. Supports multiple display modes: world view, kernel overlay, growth field, delta visualization.
display.fragTheory & Mechanics
Lenia is a continuous generalization of cellular automata discovered by Bert Wang-Chak Chan in 2018. Unlike discrete systems like Conway's Game of Life, Lenia operates in continuous space, time, and state, producing remarkably life-like emergent behaviors. The name "Lenia" derives from the Latin word lenis, meaning "smooth" or "gentle", a fitting description for the fluid, organic patterns that emerge from its rules.
What makes Lenia remarkable is its capacity for open-ended evolution. By adjusting just a handful of parameters, researchers have discovered thousands of distinct "species", stable, self-organizing patterns that move, pulse, and interact in ways reminiscent of microscopic organisms. Some glide smoothly across the grid, others spin or oscillate, and some even split or merge. This richness emerges from the interplay of local interactions governed by mathematical functions.
Historical Context
The journey from discrete to continuous cellular automata spans several decades of mathematical and computational exploration, building on foundations laid by pioneers in computing and mathematics.
Von Neumann, working with Ulam at Los Alamos, formalized the concept of cellular automata while attempting to design self-replicating systems. His goal was to create a mathematical model that could reproduce itself and perform universal computation, proving that machines could theoretically build copies of themselves. This laid the groundwork for all future research in artificial life and computational biology.
British mathematician John Conway created the Game of Life, demonstrating that incredibly simple rules could produce complex, seemingly purposeful behavior. With just two states (alive/dead) and four rules based on neighbor counts, Conway's automaton could generate gliders, oscillators, and even universal computers. This captured public imagination and inspired generations of researchers to explore emergent complexity.
Try Game of Life →Stephan Rafler introduced SmoothLife, a crucial stepping stone toward Lenia. By allowing continuous states (values between 0 and 1) while keeping discrete time steps, SmoothLife created smoother, more organic-looking patterns than the Game of Life. This demonstrated that continuity in state space alone could dramatically change the character of emergent patterns.
Read Paper →Bert Chan completed the transition to full continuity by making space, time, and state all continuous. The result was Lenia, a system where sharp boundaries dissolve into gradients, discrete steps become smooth flows, and rigid grids give way to circular, radially-symmetric neighborhoods. Chan discovered that this continuous parameter space contains thousands of stable, self-organizing "species" with remarkably life-like behaviors.
Read Original Paper →Research expanded into multichannel systems, asymmetric kernels, and integration with machine learning. Evolutionary algorithms were applied to automatically discover new species, while Neural Cellular Automata combined Lenia principles with differentiable programming. The community has now catalogued over 500 distinct species across multiple variants.
Lenia and Expanded Universe →From Discrete to Continuous
Understanding Lenia requires grasping three fundamental transitions from classical cellular automata. Each transition introduces new mathematical richness and dramatically expands the space of possible behaviors.
Continuous States
Instead of binary alive/dead states, each cell holds a continuous value in the range $[0, 1]$. This allows for smooth gradients and more organic-looking patterns.
Why it matters: Continuous states enable gradual transitions rather than abrupt on/off switching. A cell can be "partially alive", think of it as cell density or concentration rather than presence/absence. This creates smooth boundaries between patterns and their surroundings, producing the organic, fluid appearance characteristic of Lenia creatures.
Physical intuition: Imagine each cell as a container holding some amount of a substance (between empty=0 and full=1). The simulation describes how this substance flows and transforms based on local conditions.
Continuous Neighborhoods
The neighborhood is defined by a kernel function $K(r)$ that smoothly weights contributions from nearby cells based on distance, rather than using a fixed Moore or von Neumann neighborhood.
Why it matters: Instead of counting neighbors in a fixed square or cross pattern, the kernel defines a smooth influence profile. Cells at distance $r$ contribute proportionally to $K(r)$. The Gaussian shell kernel creates a ring of maximum influence at distance $\beta R$, with the ring's thickness controlled by $\alpha$.
Physical intuition: Think of dropping a pebble in water, the ripples have maximum amplitude at a certain distance from the center, then decay. The kernel describes this influence pattern mathematically.
Continuous Time
Updates occur with a configurable time step $\Delta t$, allowing for smooth temporal evolution rather than discrete jumps.
Why it matters: Discrete automata update all cells simultaneously in a single "tick." Continuous time means we can take arbitrarily small steps, making the evolution smoother and more predictable. Smaller $\Delta t$ values give finer temporal resolution but slower real-time evolution.
Mathematical connection: As $\Delta t \rightarrow 0$, the discrete update approaches a differential equation: $\frac{\partial A}{\partial t} = G(K * A)$. Lenia is thus a discretization of a PDE (partial differential equation).
The Lenia Update Rule
The simulation follows a three-step process each frame: Kernel Convolution, Growth Function Application, and State Integration.
Kernel Generation
Generate the convolution kernel based on radius R and kernel parameters.
Convolution
Compute neighborhood potential via convolution with the kernel.
Growth Function
Apply the growth function to determine state change.
Integration
Update the state with clamping to valid range.
Key Parameters
| Parameter | Symbol | Range | Description |
|---|---|---|---|
| Kernel Radius | $R$ | 1 - 50 | Size of the neighborhood in cells. Larger values create smoother, larger-scale patterns. |
| Growth Center | $\mu$ | 0.0 - 1.0 | The optimal neighborhood potential for growth. Determines which density promotes life. |
| Growth Width | $\sigma$ | 0.001 - 0.3 | Tolerance around the optimal value. Smaller values create sharper growth responses. |
| Time Step | $\Delta t$ | 0.01 - 1.0 | Integration step size. Smaller values give smoother evolution but slower simulation. |
| Kernel Peak | $\beta$ | 0.0 - 1.0 | Relative position of the kernel's peak within the radius. Controls ring vs. disk behavior. |
| Kernel Width | $\alpha$ | 0.001 - 1.0 | Spread of the kernel bell curve. Smaller values create sharper, more ring-like kernels. |
Kernel Types
The kernel defines how neighboring cells contribute to the neighborhood potential. This implementation provides 10 distinct kernel types, each creating different spatial interaction patterns. The kernel is always normalized so that its integral equals 1.
Gaussian Shell
Ring-shaped kernel with Gaussian cross-section. The standard Lenia kernel.
Polynomial Bump
Smooth bump function with compact support and C∞ continuity.
Multi-Ring
Multiple concentric rings specified by an array of peak positions.
Rectangular
Step function with sharp boundaries, creates discrete-like behavior.
The choice of kernel fundamentally affects the character of emergent patterns. Gaussian shells tend to produce smooth, organic creatures, while rectangular kernels can create more crystalline or geometric forms. Multi-ring kernels enable complex behaviors where different distance scales interact.
Growth Functions
The growth function $G(n)$ maps the neighborhood potential $n$ to a state change rate. It determines whether a cell grows (positive), shrinks (negative), or stays stable (zero). This implementation provides 11 different growth functions, each producing distinct dynamics:
The Gaussian growth function is the most commonly used because it provides a smooth, bell-shaped response that promotes stability. The peak at μ represents the "ideal" neighborhood density, too sparse or too crowded causes decay.
Multichannel Lenia
Multichannel Lenia extends the basic model by introducing multiple interacting channels (visualized as RGB). Each channel can have independent kernels and growth functions, with cross-channel interactions enabling complex predator-prey dynamics and symbiotic relationships. This implementation supports up to 3 channels with 16 simultaneous interaction rules.
Where $c$ is the target channel, $r$ indexes the rules, $h_r$ is the rule weight, and $w_{r,c'}$ are the cross-channel weights.
Channel Interactions
Cross-channel weights allow one channel to influence another's growth. For example, channel A might grow where channel B is present (attraction/symbiosis) or decay where B is present (competition/predation). This creates an ecosystem-like dynamic where different "species" can coexist, compete, or cooperate.
Simulation Variants
This implementation supports multiple cellular automaton variants beyond classic Lenia, allowing comparison and exploration of different rule systems. Click on any variant to learn more:
Classic Lenia
The original continuous cellular automaton with Gaussian kernel shells and growth functions. State, space, and time are all continuous, producing smooth, organic patterns.
Best for: Discovering classic Lenia species like Orbium, Scutium, and Hydrogeminium. The continuous nature allows for smooth morphology transitions and stable locomotion.
Key insight: Most species exist in very narrow parameter bands, small changes of 0.01 in growth center (μ) can mean the difference between stable life and extinction.
Multi-channel Lenia
Extends classic Lenia with 2-3 interacting channels visualized as RGB colors. Each channel can sense and influence others through weighted connections.
Best for: Creating ecosystems with predator-prey dynamics, symbiotic relationships, and competitive interactions between different "species" coexisting in the same space.
Key insight: Cross-channel weights determine relationships, positive weights create attraction/symbiosis, negative weights create competition/predation.
SmoothLife
Stephan Rafler's continuous-state variant uses separate inner and outer ring neighborhoods with sigmoid transition functions.
Best for: Patterns that benefit from the dual-neighborhood structure, creating different behaviors for "interior" vs "exterior" interactions.
Key insight: The discrete time step preserved from Game of Life creates distinctly different dynamics than Lenia's continuous time, patterns tend to be more crystalline.
Conway's Game of Life
The classic discrete cellular automaton included for comparison. Binary states, Moore neighborhood, and the B3/S23 rule.
Best for: Classic patterns like gliders, oscillators, spaceships, and Turing-complete constructions. A great baseline for understanding discrete vs. continuous dynamics.
Key insight: Despite its simplicity, Game of Life is Turing-complete, it can compute anything a computer can, given enough space and time.
Larger-Than-Life
Extended neighborhood ranges (up to radius 50) with threshold-based birth/survival rules. Creates smooth, blob-like patterns.
Best for: The famous "Bugs" rule produces active, amoeba-like organisms that move, eat, and reproduce, some of the most life-like behavior in discrete automata.
Key insight: Large neighborhoods smooth out small-scale noise and create more coherent, blob-like structures compared to small-neighborhood rules.
Primordia / Genesis
Asymmetric kernel configurations that break rotational symmetry. This enables directional movement and more complex morphologies.
Best for: Creating patterns with inherent directionality, creatures that "know" which way is forward without needing environmental cues.
Key insight: Symmetry breaking is essential for certain biological behaviors. Asymmetric kernels can create flows and directed movement patterns.
Pattern Taxonomy
Lenia creatures are classified by their morphology and behavior. The naming convention uses Latin-style genus and species names based on observable characteristics:
Orbium
Circular, ring-shaped creatures that glide smoothly. The simplest stable locomoting patterns and often the first species discovered in parameter searches.
Scutium
Shield-shaped organisms with distinct head/tail orientation. Often feature trailing appendages and exhibit directional movement.
Hydrogeminium
Fluid, water-like patterns that flow and deform while maintaining coherent structure. Named for their liquid-like appearance.
Species Discovery Methods
Discovering new Lenia species is a fascinating challenge that combines systematic exploration with serendipity. The parameter space is vast and high-dimensional, even tiny changes to kernel radius, growth center, or time step can transform a stable creature into chaos or extinction. The community has developed several sophisticated approaches:
Stochastic Sampling
Random parameter sampling across the vast search space, followed by manual screening. Typically uses Latin hypercube sampling or quasi-random sequences (Sobol, Halton) for better coverage. Most combinations (~99.9%) produce either extinction or chaotic growth, viable species are rare.
Evolutionary Algorithms
Genetic algorithms and evolution strategies that "breed" parameters by selecting for fitness metrics like pattern coherence, movement, and longevity. CMA-ES (Covariance Matrix Adaptation) is particularly effective for navigating the rugged fitness landscape of Lenia parameters.
Parameter Interpolation
Starting from known species and gradually varying parameters to find related creatures in nearby parameter space regions. This "morphing" approach often reveals continuous families of species with gradually changing characteristics.
Advanced Machine Learning Approaches
Recent research has explored more sophisticated computational approaches to automate and accelerate species discovery:
Neural Network Fitness Prediction
Convolutional neural networks (CNNs) trained on simulation snapshots can predict whether a parameter set will produce interesting patterns, dramatically reducing the need for expensive full simulations. The network learns visual features that correlate with "lifelikeness", coherent boundaries, movement patterns, and structural stability.
Quality-Diversity Algorithms
Algorithms like MAP-Elites maintain a diverse archive of high-quality solutions, indexed by behavioral descriptors (e.g., speed, size, symmetry). This encourages exploration of the entire behavior space rather than converging to a single optimum, discovering more morphologically diverse species.
Differentiable Simulation (Neural CA)
By implementing the Lenia update rule as a differentiable computation graph, gradients can be backpropagated through time to directly optimize for target behaviors. This enables "growing" patterns toward specific goals, movement, morphology, or response to stimuli, using standard deep learning optimization.
Hierarchical Parameter Trees
Organizing the parameter space as a tree structure where branches represent families of related species. Machine learning models can learn to navigate this tree efficiently, pruning unpromising branches early and focusing exploration on fertile regions.
Boundary Conditions
The simulation supports multiple boundary handling modes that affect how patterns interact with the edges of the computational domain:
- Toroidal (Wrap-around): Patterns exiting one edge reappear on the opposite side, creating an infinite periodic space.
- Reflective: Boundaries act as mirrors, reflecting patterns back into the domain.
- Fixed (Zero): Cells outside the boundary are treated as zero, creating hard walls.
- Infinite World: Chunk-based system allows unlimited exploration with dynamic loading.
Application Features
GPU Acceleration
The entire simulation runs on the GPU using OpenGL 4.5+ Compute Shaders, achieving massive parallelism with minimal CPU overhead. The simulation state lives entirely in VRAM, eliminating costly CPU-GPU data transfers during normal operation.
Performance Characteristics
Throughput scales with GPU compute capability. Modern graphics cards can process billions of cell updates per second, enabling real-time interaction with large grids.
Compute Pipeline
Each frame executes a sequence of compute shader dispatches, with workgroup-local caching minimizing global memory bandwidth.
Input → Kernel Gen → Convolution → Growth → Update →
Render
Simulation Variants
Classic Lenia
Original continuous cellular automaton with Gaussian kernels and growth functions.
Multi-channel Lenia
Up to 3 interacting channels (RGB) with 16 simultaneous interaction rules.
SmoothLife
Continuous variant with separate inner/outer ring neighborhoods.
Game of Life
Conway's classic rules in discrete mode for comparison.
Larger-Than-Life
Extended neighborhood ranges with threshold-based rules.
Visualization Options
Scientific Colormaps
16+ built-in colormaps optimized for scientific visualization, plus support for custom colormap files. Each colormap is designed to represent continuous data with perceptual uniformity.
Display Modes
Multiple visualization modes reveal different aspects of the simulation dynamics, from raw state values to computed fields and analysis overlays.
- World View: Standard simulation display with colormap
- Kernel Overlay: Visualize the convolution kernel shape
- Growth Field: Show growth function output values
- Neighbor Sums: Display neighborhood potential
- Delta View: Highlight areas of active change
- Vector Field: Movement direction visualization
Real-time Adjustment Controls
Color Manipulation
Hue shift, saturation, range/power curves, and offset controls for fine-tuning appearance.
Blend Modes
7 multichannel blend modes for combining RGB channel data in different ways.
Boundary Styles
5 boundary visualization styles including fade, highlight, and contour options.
User Interface
Built with Dear ImGui, the interface provides a professional, desktop-native experience with detachable and resizable windows.
Preset Browser
Searchable browser with category filtering across 548+ species. Live preview with current colormap.
Grid Tools
Flip, rotate, clear. Multiple placement modes: center, corners, scatter, grid, random.
Brush System
Configurable brush size, strength, and stroke settings for manual editing.
Wall Editor
Create boundaries and obstacles with various wall types.
Infinite World
Chunk-based navigation for exploring unlimited space.
Keyboard Navigation
Full Tab/Shift+Tab traversal with visible focus indicators.
Analysis & Monitoring
Live Metrics
- Mass (total cell value)
- Alive cell count
- Centroid position
- Speed and direction
Pattern Detection
- Periodic behavior detection
- Stability monitoring
- Auto-pause on extinction
- Auto-pause on stability
Performance Stats
- FPS counter
- Frame time statistics
- Throughput (Gcells/s)
- Efficiency rating
Professional Graphs
- Labeled axes
- Tick marks
- Grid lines
- Real-time updates
Supported Grid Sizes
Multiple resolution presets optimized for different GPU capabilities and performance requirements.
Keyboard Shortcuts
Full keyboard control for efficient workflow and accessibility.
Accessibility
Installation & Usage
Requirements
Build Requirements
- Compiler: MinGW-w64 (MSYS2 UCRT64) with GCC 13+ or GCC 15 recommended
- Graphics: OpenGL 4.5 compatible GPU (4.6 preferred)
- OS: Windows 10/11
Runtime Requirements
- OpenGL 4.5+ capable graphics card
- GPU with compute shader support
Building from Source
Quick Build (Recommended)
.\build_windows.bat
The build script automatically detects MSYS2/MinGW-w64 installation, downloads required libraries (GLFW, GLAD, GLM, Dear ImGui), compiles with optimizations (-O3, LTO), and links statically.
Build Options
.\build_windows.bat --clean # Clean rebuild
.\build_windows.bat --no-pause # No pause at end (for scripts)
.\build_windows.bat --help # Show options
Manual Build with Make
mingw32-make -j8
Running the Application
bin\lenia.exe
Getting Started
- 1 Launch bin/lenia.exe
- 2 Browse presets in the Presets section
- 3 Select a category (e.g., "Multichannel") and choose a species
- 4 Press Space to start the simulation
- 5 Adjust parameters in real-time using the UI panels
About & Origins
Credits & Acknowledgments
Bert Wang-Chak Chan
Creator and discoverer of Lenia. His groundbreaking research into continuous cellular automata opened new frontiers in artificial life research, demonstrating how remarkably life-like behaviors can emerge from simple mathematical rules.
Original Paper (arXiv)Inspiration
This project was inspired by the fascinating YouTube video by David Louapre on his channel Science Étonnante, which explored Conway's Game of Life and its extensions into continuous domains. That video sparked a journey from discrete cellular automata to the continuous, fluid world of Lenia.
"The transition from discrete to continuous opens up an infinite parameter space where countless life-like creatures await discovery."
Development History
First Attempt: Lenia-Simulation
A Python notebook created to explore and understand different Lenia species. This initial exploration helped build intuition for the parameter space and the behavior of various creatures.
View Repository →Second Attempt: Lenia-Web
A web-based interactive version that made Lenia accessible through the browser. While highly interactive and accessible, performance limitations of the browser environment prevented achieving the desired simulation speeds for larger grids.
View Repository →Current: Lenia C++
This C++ implementation was built to achieve maximum performance through hardware acceleration with OpenGL compute shaders. It serves dual purposes: providing a desktop-native experience with direct GPU interaction, and as a personal project to master C++ optimization, memory management, and graphics programming.
The result is a high-performance simulator capable of running complex multichannel simulations at 60+ FPS with real-time parameter adjustment, something not achievable with interpreted languages or browser-based implementations.
Author
Libraries Used
License
This project is released under the MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.
View Full License →