Mathematical Methodology

Four Equations.
One World.

A dissection of the mathematical frameworks underlying a generative world-building system — from classical thermodynamics to modern complexity theory.

Physics∇²T · FBM
ChemistryGray-Scott
BiologyLorenz ODE
SociologySocial Force
Scroll to explore
01 · Physics

Thermodynamic Noise

Fourier Heat Equation · Simplex FBM · XORshift PRNG

The terrain is not sculpted — it is diffused. Raw height values are seeded by Fractional Brownian Motion, a multi-scale superposition of Simplex noise octaves. But the novelty lies in what happens next: the height field is treated as a thermal field, and the Fourier heat equation is applied.

Fourier 1822
$$\frac{\partial T}{\partial t} = \alpha \nabla^2 T$$
The heat equation. \(T\) is temperature (here, terrain height), \(\alpha\) is thermal diffusivity, and \(\nabla^2\) is the Laplace operator measuring local curvature of the field.

Discretised on the pixel grid, the Laplacian becomes a five-point stencil — the spatial finite-difference approximation most used in computational physics:

Discrete Laplacian
$$\nabla^2 T \approx T_{i+1,j} + T_{i-1,j} + T_{i,j+1} + T_{i,j-1} - 4T_{i,j}$$
Each cell's "curvature" is the sum of its four neighbours minus four times its own value. Positive means a local valley (heat flows in); negative means a peak (heat flows out).

After eight diffusion passes, the heat field is used to suppress the original height — mountains thermodynamically carve their own valleys:

Novel Fusion
$$H_\text{final}(x,y) = H_\text{raw}(x,y) \cdot \bigl(1 - \beta \cdot \min(1,\, T_\text{diffused}(x,y))\bigr)$$
\(\beta = 0.5\). High peaks emit heat, which spreads and suppresses neighbouring height — no artist placed those valleys.

The underlying noise itself is Fractional Brownian Motion — a sum of Simplex noise octaves at geometrically increasing frequency and decreasing amplitude:

FBM · Mandelbrot 1968
$\text{FBM}(x,y) = \sum_{k=0}^{N-1} a_0 \cdot g^{\,k}\, \eta\!\left(x \cdot \lambda^k,\; y \cdot \lambda^k\right)$
\(\eta\) is Simplex noise, \(a_0 = 0.5\) is initial amplitude, \(g = 0.52\) is gain (persistence), \(\lambda = 2.05\) is lacunarity. Five octaves (\(N=5\)) produce fractal self-similarity of natural coastlines.
§

The mathematical value here is the coupling of two unrelated physical laws — noise generation and heat diffusion — into a feedback loop. The FBM produces the initial condition; the PDE shapes the outcome. Neither alone produces geologically credible terrain.

ParameterSymbolValueMeaning
Octaves\(N\)5Frequency scales of terrain detail
Lacunarity\(\lambda\)2.05Frequency multiplier per octave
Init amplitude\(a_0\)0.50First octave contribution
Gain\(g\)0.52Amplitude decay per octave
Diffusion steps8Heat equation integration depth
Diffusivity\(\alpha\)0.10Rate of heat spread per step
Suppression\(\beta\)0.50Valley carving strength
02 · Chemistry

Reaction-Diffusion

Gray-Scott System · Turing Morphogenesis 1952

Alan Turing's 1952 paper proposed that patterns in living systems — leopard spots, zebra stripes, coral structures — arise from the interaction of two chemicals diffusing at different rates. The Gray-Scott formulation makes this computable:

Gray-Scott System
$$\frac{\partial A}{\partial t} = D_A \nabla^2 A - AB^2 + f(1 - A)$$
$$\frac{\partial B}{\partial t} = D_B \nabla^2 B + AB^2 - (f + k)B$$
\(A\) is the activator, \(B\) the inhibitor. The nonlinear term \(AB^2\) is the autocatalytic reaction: \(A + 2B \to 3B\). \(f\) is the feed rate, \(k\) the kill rate.

The system's richness comes from the diffusion ratio. When \(D_A / D_B = 2\), the activator spreads slower than the inhibitor — this asymmetry breaks symmetry and spontaneously generates spatial pattern:

Critical Parameters
$$D_A = 0.18 \qquad D_B = 0.09 \qquad f = 0.037 \qquad k = 0.060$$
These values sit precisely in the labyrinthine region of the Gray-Scott phase diagram. Change \(f\) by 0.005 and you get spots; change \(k\) and the pattern dissolves.
§

The mathematical coup is initial condition seeding: the terrain height from Phase 1 sets \(A = 1 - 0.8h\) and \(B = 0.7h\). Tall land starts inhibitor-rich (exposed rock). Low land starts activator-rich (soil). The PDE evolves these into meadows, forests, and clearings — biome boundaries emerge from chemistry, not lookup tables.

Euler Integration
$$A_{t+1} = A_t + D_A \nabla^2 A_t - A_t B_t^2 + f(1 - A_t)$$
$$B_{t+1} = B_t + D_B \nabla^2 B_t + A_t B_t^2 - (f + k)B_t$$
60 iterations (30 visual frames × 2 sub-steps) across 147,456 cells (384×384). Cost is \(\mathcal{O}(N)\) per step — real-time animated reveals are viable.
Early — Step 5
Activator-inhibitor gradient mirrors terrain.
Mid — Step 25
Labyrinthine filaments emerging.
Late — Step 50
Stable Turing pattern crystallised.
03 · Biology

Strange Attractor Trees

Lorenz System · Deterministic Chaos · 1963

Each tree is not drawn — it is integrated. The Lorenz system, three coupled ODEs, produces a trajectory in phase space. That trajectory, projected onto the canvas, forms the tree's canopy.

Lorenz 1963
$$\frac{dx}{dt} = \sigma(y - x) \qquad \frac{dy}{dt} = x(\rho - z) - y \qquad \frac{dz}{dt} = xy - \beta z$$
Classical parameters: \(\sigma = 10\), \(\rho = 28\), \(\beta = 8/3\). These place the system in its chaotic regime.

The crucial decision: initial conditions derive from world position. Each tree at \((w_x, w_y)\) initialises at:

World → Phase Space
$$x_0 = \frac{2w_x}{W} - 1 + \varepsilon_x \qquad y_0 = \frac{2w_y}{H} - 1 + \varepsilon_y \qquad z_0 = 10 + \varepsilon_z$$
\(\varepsilon\) terms are small seeded perturbations from the XORshift PRNG. 25-step burn-in discards the transient before rendering.
§

This exploits sensitive dependence on initial conditions as a feature. Two trees 1 pixel apart diverge exponentially — their canopies look nothing alike, yet both trace the same butterfly manifold. Same species, different individual. Chaos becomes biological individuality.

Phase → Canvas
$$p_x = w_x + x_\text{Lorenz} \cdot s \qquad p_y = (w_y - 4) - (z_\text{Lorenz} - 10) \cdot s$$
Scale \(s\) varies by species (0.07–0.11). Euler integration with \(\Delta t = 0.005\), 75 steps per tree.
SpeciesScaleStepsCharacter
Oak0.1075Broad, dense, spreading
Pine0.0762Compact, vertical, tight
Mystic0.1175Wide, sparse, ethereal
Autumn0.0955Moderate, warm-toned
04 · Sociology

Social Force Cities

Helbing Model 1995 · Gaussian Potential Fields · Inverted

Dirk Helbing's Social Force Model was conceived for pedestrian dynamics. Here it is inverted and scaled to urban morphogenesis. Zones, not people, are the agents. Each emits a Gaussian potential field:

Potential Field · Helbing 1995
$$V(x,y) = \sum_i \sum_{j \neq i} w_{ij} \cdot s_i \cdot \exp\!\left(-\frac{(x-x_i)^2 + (y-y_i)^2}{2\sigma^2}\right)$$
\(w_{ij}\) is the interaction weight between zone types. \(s_i\) is zone strength \(\in [0.7, 1.0]\). \(\sigma = 0.11W\) (~42 pixels at 384px).

The interaction matrix \(W\) encodes sociological logic as signed numbers:

Interaction Matrix
$$W = \begin{pmatrix} 0.0 & +0.8 & -0.9 & +0.5 \\ +0.8 & 0.0 & -0.5 & +0.3 \\ -0.9 & -0.5 & 0.0 & -0.3 \\ +0.5 & +0.3 & -0.3 & 0.0 \end{pmatrix}$$
Rows/cols: Residential · Commercial · Industrial · Civic. \(w_{02} = -0.9\): residential strongly repels industrial. \(w_{01} = +0.8\): residential and commercial attract.
§

Roads are not drawn. They are extracted as gradient magnitude ridges — the fault lines between competing zone influences where \(\|\nabla V\|\) exceeds a threshold. District boundaries in real cities emerge for the same reason.

Road Extraction
$$\text{road}(x,y) = \begin{cases} 1 & \text{if } \|\nabla V(x,y)\| > \tau \text{ and } h(x,y) \geq h_\text{water} \\ 0 & \text{otherwise} \end{cases}$$
Threshold \(\tau = 0.006\). Water-line condition \(h \geq 0.22\) prevents ocean roads — physics handles it, no special case.
05 · Synthesis

The Complete Pipeline

Cross-Layer Information Flow · Emergent Complexity

The system's deepest value is not in any single algorithm but in how they are composed. Each layer consumes the output of the previous as its initial condition. Information flows in one direction — like physical causality — and nowhere is a lookup table, asset, or hand-placed element used.

Physics → Chemistry

Height map \(H(x,y)\) initialises Gray-Scott: \(A_0 = 1 - 0.8H\), \(B_0 = 0.7H\). Geology dictates where chemistry begins.

Chemistry → Colour

Evolved concentrations \((A, B)\) modulate per-pixel colour within each height band. The RD pattern is the biome texture.

Physics → Biology

Water line \(h \geq 0.22\) gates tree placement. Height ceiling \(h \leq 0.74\) prevents forests at altitude. Terrain controls ecology.

Physics → Sociology

Zone seeds rejected if \(h < 0.22\) (water) or \(h > 0.72\) (mountains). Settlement follows topography via a single inequality.

The result is emergent complexity from composed simplicity. Each algorithm is a solved problem from 19th or 20th century mathematics. The contribution is the deliberate chaining — a pipeline where the output space of each equation is the input manifold of the next.

Composition
$$\text{World} = \mathcal{S}\!\bigl(\mathcal{B}\!\bigl(\mathcal{R}\!\bigl(\mathcal{T}(\text{seed})\bigr)\bigr)\bigr)$$
\(\mathcal{T}\) = thermodynamic terrain, \(\mathcal{R}\) = reaction-diffusion, \(\mathcal{B}\) = biological placement, \(\mathcal{S}\) = sociological urban field. Every world is a deterministic function of a single integer seed.
Mathematical Foundations
Joseph Fourier — Heat Equation1822
Fisher & Yates — Shuffle Algorithm1938
Alan Turing — Morphogenesis1952
Edward Lorenz — Strange Attractor1963
Mandelbrot & Carpenter — FBM1968 / 80
Dirk Helbing — Social Force Model1995
Ken Perlin — Simplex Noise2001
George Marsaglia — XORshift PRNG2003
System Properties
Resolution384 × 384 px
RD Cells147,456
RD Iterations60 (30 × 2)
Max Trees130
Lorenz steps / tree75 + 25 burn-in
Zone count6 – 14
Seed space0 – 9,999,999
World authorOmry Damari