Augustin Grudet

Specimens: a procedural fingerprint for every post

Every post gets a unique, reproducible ASCII drawing made by a real scientific simulation. Seed, generator families, determinism and rendering.

This post was machine-translated from the original version.

Contents

At the top of every post on this site sits a band of characters: a “specimen”. None of it is drawn by hand. The band is the final state of a simulation (a chemical reaction, a chaotic orbit, a bundle of stock prices) rendered in ASCII. Below it, a label like the ones on laboratory slides sums up its genome. This post’s label reads:

specimen 0xf734 · gray-scott · f=0.030 k=0.0615

That is: seed 0xf734, the Gray-Scott family, and the two parameters that set its regime. The same text will always produce the same drawing, on the server and in any browser.

specimen 0xe2b9 · gray-scott · f=0.0466 k=0.0635
An interactive Gray-Scott specimen. The sliders change f and k; the drawing is recomputed in the browser by the same engine as the banners.

Why

A stock illustration teaches the reader nothing. A specimen shows the output of a real model, and its label leads to the post that explains its generator. The system follows three constraints. No two posts share a drawing, barring a rare collision. The drawing depends only on the post’s address, its tags and an optional explicit setting, never on the build date or on chance. And it stays plain: monochrome text, two intensities at most, no image to download.

From address to seed

Hashing: cyrb53

The starting point is the slug, the name of the post’s folder (specimens here). It does not change when the text is edited. It is hashed with cyrb53, a non-cryptographic hash function that bryc released into the public domain. It advances two 32-bit accumulators with Math.imul (integer multiplication modulo 2322^{32}) by odd constants, then mixes them one last time so that every input bit affects every output bit. The result fits in 53 bits, the largest range of integers a JavaScript number represents exactly.

Only the 16 low bits are used as the displayed seed:

From slug to label, for this post.
StepValue
slugspecimens
cyrb534,219,924,838,151,988 (0xefdffd0f4f734)
seed (16 low bits)0xf734
familygray-scott (forced in the frontmatter)
preset drawnsolitons, f = 0.030, k = 0.062
after a small jitterf = 0.0300, k = 0.0615

Sixteen bits make 65,536 seeds. By the birthday paradox, the probability that at least two posts out of a hundred share a seed is about 1−e−100⋅99/(2⋅65 536)≈7%1 - e^{-100 \cdot 99 / (2 \cdot 65\,536)} \approx 7\%. Even then, they only share a specimen if they also fall in the same family, and their secondary tags can still tell them apart.

Pseudorandom generator: sfc32

The seed feeds sfc32 (Small Fast Counting), a generator written by Chris Doty-Humphrey and shipped with PractRand, his statistical test suite. Its state is four 32-bit words, one of them a counter that guarantees a minimum period of 2322^{32} (the average period is around 21272^{127}); PractRand lists it as the fastest of its recommended 32-bit generators. The engine seeds it with a splitmix-style mixer1 and discards the first twelve outputs:

export function createRng(seed: number, stream = 0): Rng {
  let s = (seed ^ Math.imul(stream + 1, 0x9e3779b9)) | 0;
  // ... four calls to a splitmix32 mixer fill a, b, c, d
  for (let i = 0; i < 12; i++) next();
  return next;
}

The stream argument gives independent sequences for the same seed: stream 11 draws the parameters, stream 12 the modulations, stream 1 the Gray-Scott initial condition, streams 100 and up the Brownian paths. Adding a draw to one stream therefore never shifts the others.

From tag to generator

The post’s first tag that appears in the family table picks the generator; with no match, it is Gray-Scott. The parameters are then drawn in two steps:

export function deriveParams(generator: GeneratorId, seed: string, modulators: readonly string[]) {
  const g = GENERATORS[generator];
  const s = seedToInt(seed);
  const key = [...new Set(modulators)].sort().join(',');
  return { ...g.params(createRng(s, 11)), ...g.nudges(createRng(hash32(key, s), 12)) };
}

The identity (params) depends on the seed alone: for Gray-Scott, one preset out of eight known regimes and a small jitter on (F,k)(F, k). The modulations (nudges) depend on the seed and on the sorted set of the other tags: initial density, mirror symmetry, choice of character ramp. Sorting the tags makes the result independent of their order; adding a secondary tag retouches the drawing without changing its nature.

Freezing or forcing a specimen

The frontmatter’s specimen field overrides everything else:

specimen:
  generator: attractor   # forces the family
  seed: "0x3fa9"         # or any string, which gets hashed
  params: { a: -1.4 }    # overrides one parameter

A hexadecimal seed is read as is; any other string is hashed, so seed: "spring" works too. An unknown generator triggers a warning at build time and the family falls back to the one from the tags.

The same drawing everywhere

The drawing is computed twice: at build time by Node, then replayed in the reader’s browser. Both must end on exactly the same characters. For integers this is easy: Math.imul, shifts and XOR are defined exactly. For floating point, IEEE 754 requires ++, −-, ×\times, ÷\div and the square root to be correctly rounded: same input, same output, bit for bit, on any machine.

The trouble with Math.sin

Transcendental functions get no such guarantee. The ECMAScript specification states that sin, cos, log, exp and a few others are “not precisely specified” and leaves “latitude in the choice of approximation algorithms”. V8, SpiderMonkey and JavaScriptCore may therefore disagree on the last bit. For a strange attractor that rules them out: sensitivity to initial conditions blows a one-bit difference up into an entirely different orbit in under a hundred iterations.

dmath

So the engine ships its own sin, cos, log and exp, written with the basic operations and Math.floor only. For the sine, the argument is brought close to zero by a Cody-Waite reduction: π/2\pi/2 is split into a 33-bit high part and a remainder, so that k⋅π/2k \cdot \pi/2 is subtracted without rounding error for the arguments that come up; a Taylor polynomial evaluated with Horner’s scheme does the rest.

export function sin(x: number): number {
  const k = Math.floor(x * INV_PIO2 + 0.5);
  const r = x - k * PIO2_HI - k * PIO2_LO;
  switch (k & 3) {
    case 0: return sinPoly(r);
    case 1: return cosPoly(r);
    case 2: return -sinPoly(r);
    default: return -cosPoly(r);
  }
}

The logarithm brings the mantissa into [2/2,2)[\sqrt2/2, \sqrt2) by multiplying by 2, then sums the series ln⁡m=2 artanh m−1m+1\ln m = 2\,\mathrm{artanh}\,\frac{m-1}{m+1}. The accuracy, around 10−1510^{-15}, is more than enough; what matters is that the result is the same everywhere.

From field to text

Each generator produces a scalar field normalised to [0,1][0, 1], one value per cell of the character grid: 120 columns by 14 rows for a banner, 96 by 3 for the strips in the list of posts. A ramp, from sparse to dense, turns each value into a character. For Gray-Scott, for instance:

 .:-=+*#%@

The value vv becomes the character at index ⌊10 v⌋\lfloor 10\,v \rfloor (capped at 9). The first levels of the ramp (45%, rounded) print in a light tone, the rest in full blue: the drawing never uses more than two intensities. The ramps stick to punctuation and Latin-1 symbols, so that the self-hosted monospace font covers every glyph. A character cell being about 0.6 times as wide as it is tall, the spatial generators (all but the Brownian one) correct for that ratio so that shapes stay round on screen.

Replaying the growth

At build time the simulation runs to the end and its final state is written as static HTML: nothing to load, no layout shift, and the page reads fine without JavaScript. In the browser, when the specimen scrolls into view, the same simulation starts over and replays its growth in about 2.4 seconds.

The guarantee of landing back on the build’s image rests on a contract: all of a generator’s work is a fixed sequence of total units (Gray-Scott steps, attractor points, Brownian columns). Doing it in one call at build time or in a thousand pieces spread over animation frames runs exactly the same operations in the same order. A slow device takes longer without skipping a step. At the end, as a safety net, the script puts back the exact text of the original HTML and, in development, reports any difference. With prefers-reduced-motion, only the final state is shown. The pointer can then stir the field locally, and it settles back to its final state on its own.

The home page specimen goes further: once it reaches its final image, it keeps going. Each generator has an endless regime (the Brownian paths scroll by, the DLA cluster melts and grows back), computed in a worker so the page stays responsive.

The seven generators

Specimen families, the tag that selects each one, and its explainer.
GeneratorTagIn one sentence
gray-scottdefaultTwo chemical species that diffuse and react draw spots, mazes and corals.
attractormathsThe density histogram of a chaotic Clifford or Peter de Jong orbit.
brownianfinanceA bundle of geometric Brownian motion paths, the Black-Scholes model.
leniaaiA continuous cellular automaton in which artificial creatures emerge.
automatoncodeA cellular automaton, elementary or Life-like: a local rule that is enough to compute.
isolinesmapsThe contour lines of a terrain drawn from fractal noise.
dlaprojectsDiffusion-limited aggregation, a cluster that grows one particle at a time.

Notes

  1. Steele, Lea and Flood (2014) introduced SplitMix; the 32-bit variant used here adds the golden ratio constant ⌊232/φ⌋\lfloor 2^{32}/\varphi \rfloor (0x9e3779b9) on every call and applies the MurmurHash3 finalizer. ↩

Sources

  1. bryc, cyrb53 (source code, public domain) (Nov 25, 2026)
  2. bryc, Pseudorandom number generators in JavaScript (sfc32, splitmix32) (Nov 25, 2026)
  3. C. Doty-Humphrey, PractRand: RNG engines (quality and period of sfc32) (Nov 25, 2026)
  4. G. L. Steele, D. Lea, C. H. Flood, Fast splittable pseudorandom number generators, OOPSLA 2014 (Nov 25, 2026)
  5. ECMAScript Language Specification, 21.3.2 Function Properties of the Math Object (Nov 25, 2026)