name: lenia-core
description: Core Lenia engine API, stable parameters, multi-species presets, and growth functions. Use when working on the simulation engine, configuring organisms, or debugging parameter issues.
Lenia Core Engine
Key Parameters (Stable Lenia)
kernelRadius: 13;
growthCenter: 0.12; // μ - center of growth function
growthWidth: 0.04; // σ - width (NOT 0.015, too narrow)
dt: 0.1;
- Blob radius: 25 (not 15)
- FFT auto-activates when
kernelRadius >= 16
Engine API
import { createEngine } from "./core/engine";
const engine = await createEngine({ canvas });
// Lifecycle
engine.start();
engine.stop();
engine.reset(pattern);
engine.stepOnce();
// Paradigm
engine.setParadigm("discrete" | "continuous");
// Multi-channel
engine.enableMultiChannel(config);
engine.disableMultiChannel();
// Sensorimotor
engine.enableSensorimotor();
engine.disableSensorimotor();
// Mass conservation
engine.setConservationConfig({ enabled: true });
engine.getMass(): Promise<number>;
// Boundary conditions
engine.setBoundaryMode("periodic" | "clamped" | "reflected" | "zero");
engine.getBoundaryMode();
Boundary Modes
| Mode |
Description |
periodic |
Toroidal wrap (default) |
clamped |
Edge values repeat |
reflected |
Mirror at boundaries |
zero |
Absorbing (values go to 0 at edges) |
Seeded Random Number Generator
import { createSeededRandom, globalRandom, setGlobalSeed } from "./core/random";
// Create independent seeded RNG
const rng = createSeededRandom(12345);
rng.next(); // 0-1 float
rng.nextInt(0, 100); // Integer in range [0, 100)
rng.nextGaussian(); // Normal distribution
rng.shuffle(array); // In-place shuffle
rng.choice(array); // Random element
// Global RNG for convenience
setGlobalSeed(42);
globalRandom.next();
Multi-Species Presets
| Preset |
Species |
Dynamics |
single |
1 |
Standard Lenia |
two-species |
2 |
Competitive inhibition |
predator-prey |
2 |
Predator hunts prey |
food-chain |
3 |
Plants → Herbivores → Predators |
symbiosis |
2 |
Mutual benefit |
creature-food |
2 |
Creature consumes food |
pheromone |
3 |
Chemical trail signaling |
Loading Presets
import { MULTI_SPECIES_PRESETS } from "./core/channels";
const config = MULTI_SPECIES_PRESETS["predator-prey"];
engine.enableMultiChannel(config);
Mass Conservation
// Enable mass conservation with auto-normalization
engine.setConservationConfig({ enabled: true });
// Conservation pipeline (internal)
pipeline.computeAndNormalize(device, stateTexture, outputTexture);
pipeline.setTargetMass(mass); // Lock target mass
pipeline.getCachedMass(); // Non-blocking mass read
Core Files
| File |
Purpose |
core/engine.ts |
Main orchestrator |
core/channels.ts |
Multi-species preset configs |
core/kernels.ts |
Kernel generation functions |
core/growth.ts |
Growth function implementations |
core/random.ts |
Seeded RNG (xorshift128+) |
core/types.ts |
TypeScript type definitions |