World generation lives in its own Gradle module, worldgen/ — a pure-function pipeline over data, with no Spring, no JPA, and no I/O (the one exception, viewer/, is dev tooling for inspecting a generated world, not part of the running server; a build-time check fails if anything else in the module gains a dependency or touches the filesystem). zone-server links it and owns the one thing worldgen deliberately doesn’t: a running world with a database row and a socket to serve it over.

What’s implemented

Almost all of it. 25 world-tier stages run end to end — tectonics, climate, erosion, glaciation, hydrology, volcanism, biomes, vegetation, resources, caves, mana, habitability, settlements, history, corruption, points of interest, town layout, economy, spawners, the macro navigation graph, hills and set dressing — plus chunk materialization, RLE encoding, delta tracking, baking, and streaming to zone-server. The genuine gaps, as of this pass:

  • No client-side base generation. The wire format, base hashing and version gate that would make it safe exist; nothing generates terrain client-side yet, so every chunk is sent fully merged.
  • No disk or object-store cache tier. Generated chunks are cached in memory only, so a restart generates each chunk again on first use. See Chunk Caching.
  • The catalogues are still code, not data files. BusinessCatalogue, the biome prototype table, Culture.ALL, Names.STYLES are Kotlin objects. A designer changing one needs a rebuild. (Individual stage parameters — roughly 220 of them — mostly already load from a params-text file; see Parameters.)
  • Derived structures have one real reader. WalkableTile backs zone-server’s local pathfinding. OpacityGrid and ColumnSummary are kept fresh on every edit and queried by nothing yet.
  • WorldWrap’s coordinate math has four callers (chunk streaming, spawn-point search, the sea-lane cost field, bestia spawn placement). Movement, interest management and pathing still use naive subtraction, so two players a few metres apart across the world’s wrap seam read as a world apart.
  • Sharding, a work queue, a gRPC surface for a distributed generator are deliberately not here — that’s the server’s concern, not a pure function’s.

The pipeline

Twenty-five stages, each declaring only what it reads (Stage.dependencies) and what it produces (Stage.outputs — raster layers, vector features, the history log, or the navigation graph). WorldGenPipeline topologically sorts them by that declaration and computes a version vector per stage (its own version folded with every upstream one), so retuning erosion invalidates erosion and everything downstream while leaving tectonics — the expensive part — untouched. After every stage runs, the pipeline diffs what it declared it would produce against what it actually wrote; a mismatch is a hard failure, not a silent pass-through.

graph LR
  T[tectonics] --> C[climate]
  C --> E[erosion]
  E --> G[glacial]
  G --> H[hydrology]
  H --> AL["alluvium, volcanism"]
  AL --> BP["biomes, pond"]
  BP --> CMV["caves, mana, vegetation"]
  CMV --> R[resources]
  R --> HA[habitability]
  HA --> S[settlements]
  S --> HI[history]
  HI --> COP["corruption, poi"]
  COP --> STV["spawners, towns, vegetation_stands"]
  STV --> EC[economy]
  EC --> NG[nav_graph]
  EC --> KN[knolls]
  KN --> DR[dressing]

The order stages are constructed in (StandardWorld.stages()) is cosmetic — the pipeline sorts by declared dependency regardless, and this has bitten the module for real once already: for most of its life, GlacialStage and HydrologyStage were undeclared siblings that only ran in the right order because the topological sort’s alphabetical tie-break happened to put "glacial" before "hydrology". A glacial trough carves the ground absolutely, so every stage below hydrology was quietly reading a coarse surface a finished chunk would later carve hundreds of metres out from under it. Declaring the dependency turned an alphabetical accident into a guarantee — and, as a side effect, gave the world its first lakes, because the priority-flood in hydrology had never once been handed a genuinely closed basin before the carve reached the raster.

StageEmitsWhy it sits where it does
tectonicselevation, plate id, rock hardness, faults, hotspotsroot; nothing to depend on
climatetemperature, precipitation (4 seasonal fields), distance to oceanneeds tectonic elevation for the orographic sweep
erosioneroded elevation, sediment, tectonic basinsstream-power erosion needs precipitation
glacialfinal elevation, ice thickness, troughs/fjords/cirques/morainessole producer of final ELEVATION; carves last
hydrologyflow routing, discharge, lakes, river channelsroutes over the final, ice-carved surface
volcanismvolcanism field, vents, lava poolscraters must exist before biomes read distance-to-crater
biomesbiome + secondary biome + confidence, soilclassifies on climate + hydrology + volcanism
pond, alluviummoraine-dammed lakes; alluvial fans, deltassub-kilometre shapes the raster can’t hold, fed from hydrology/erosion’s own budgets
vegetationcanopy coverkilometre summary of the same density function the chunk tier’s scatter uses
resourcesore/mineral depositsgeology-driven placement
cavescave systems, passages, entrancesreads the chunk tier’s own rock tuning directly
manamana potential (a rank over the land; the zone derives the density, see World Events)must precede history; corruption must follow it
habitabilitysettleability score, movement costneeds biomes + resources + terrain
settlementssettlement sites, roads, bridges, sea lanesplaced before history judges them
historythe chronicle; ruins, tombs, monuments, forts, mines, monasteries, lighthouses, shrines, wound sitesdates/holds/burns settlements already placed — does not place them; see History Generation
corruptioncorruption fieldsuppresses by the settlements history left standing
poipoints-of-interest landmarksreads settlements + sites + cave mouths to avoid them
spawners, towns, vegetation_standsbestia spawn points; street/building/district layout; vegetation standsread corruption; vegetation_stands specifically needs corruption, which is why it isn’t in bio/ next to vegetation
economybusinesses, roadside innsneeds the finished town layout
nav_graphthe macro navigation graphlast — reads roads, bridges, gates and cave mouths everything above finalised
knollshills: wandering clusters of low rounded knollsafter everything built, so hills go round the ways: one reaching a road is slid aside, else lowered until the road cuts it
dressingset dressing: piers, boats, wells, windmills, cemeteries, signposts, milestones, lanterns, cairnsafter the hills (a windmill wants the highest one); the dense half - fences, crops, headstones - is derived per chunk

Bestia dens

The spawners stage places one BESTIA_SPAWN marker per den. A den carries a level range, a pack size, a radius, its biome, its corruption and its temperature. The zone server turns a marker into creatures when a player comes near, and picks the species from the biome and the level range.

Levels come from a danger curve (distance from towns, remoteness, height, biome). Corrupted land is its own band, 80 to 100. Every band has its own creature density per square kilometre, so starter country is full and the endgame is sparse.

Boss dens. A den in wild country (its ordinary levels reach above midMaxLevel, 40) may roll to be a boss den instead: wildBossChance (1 %) outside corruption, corruptedBossChance (2.5 %) inside. A boss den keeps the lower end of its country’s range and raises the top by bossLevelBonus (20), capped at bossMaxLevel (120). So the wilds hold bosses from about level 33 to 100, and only the deepest corruption reaches 120. A boss den holds one creature. The home safety ring caps the ordinary levels first, so no boss den rolls near a home town. On the default world (seed 11753242, 128 km) this gives 152 boss dens: 43 in the wilds and 109 in corruption.

Living detail

The stages above decide where things are at kilometre scale. A few of the last ones exist only to make the ground between settlements look lived in.

  • Rivers start small and end wide. A headwater holds the narrowest channel the voxel grid can draw for its first three kilometres, in a tight floodplain. Every river that reaches the sea opens into its own estuary, drawn per river: most widen modestly, a few become a broad funnel. A steep run to the sea favours a wide mouth; a flat one, where a delta forms instead, favours a small one.
  • Hills go round the ways. knolls lays clusters of low rounded hills in districts of hill country, after every road, field and building exists. A hill keeps clear of anything built. One that reaches a road is slid aside, so the road runs between two rises; failing that it is lowered until the road cuts through it as a bank a player can climb. Roads are planned on kilometre cells and could never see a hill this size, which is why the hills move rather than the roads.
  • Things to pick up and break. Boulders lie on stony ground (thin soil, rocky biomes, glacial moraines) and break for quarried stone, flint and the odd rough gem. Loose stones and fallen sticks are picked up as they lie and grow back. A flint and a stick make a stone knife; two stones and a stick make a stone hatchet.
  • Set dressing. Piers with boats tied up off waterfront towns, wells on the greens, a windmill on the highest hill above a village’s fields, and a walled cemetery at the edge of every village and town. Its first headstones belong to the figures the chronicle remembers who died at home; any of them can be read. Fields are fenced in dry-stone, hedge, post-and-rail or wattle by the ground they lie on, and carry wheat, barley or cabbage with haystacks and a scarecrow. Signposts stand where a lane meets a road, and milestones line the trunk roads; both name where each way leads and how far. Cairns mark the top of a trail’s climb, and rock outcrops crown hills in dry country. Every roadside inn now has a house.
  • The everflame. The last two or three kilometres of every road into a settlement are lined with lanterns. Their pale blue-green magic flame burns brighter as the day goes and lights the road at night. Each settlement has a lamplighter who walks one line of them at dusk on most evenings.

Parameters

Roughly 220 tunables across ~20 *Params data classes, threaded through one WorldParams object so a params file is a change in one place rather than twelve constructor calls. Most stage parameter classes already load from a flat, dotted-key text format (core/ParamsText.kt — line numbers, duplicate detection, nearest-key typo suggestions); a handful of prefixes aren’t wired to a loader yet, and asking for one of those from a file says so explicitly rather than pretending the key doesn’t exist.

Four numbers are deliberately not settable independently, because two stages have to agree on them: the ocean margin (tectonics carves it, erosion has to re-apply it after 45 timesteps of uplift), the habitability terms (read by both habitability and settlement scoring), and the settlement grading limits and chunk-detail noise (read by both settlement and town layout). WorldParams.resolved forwards each from the one stage that owns it, rather than letting both default independently and silently disagree.

  // worldgen never reads a file itself (no I/O outside viewer/) - the caller reads the text and hands it
// over as a String; only the caller (here, hypothetically, zone-server) touches the filesystem.
val text = ParamsText.parse(File("mars.worldgen.txt").readText(), origin = "mars.worldgen.txt")
val params = WorldParams.load(text) // falls back to WorldParams.DEFAULT for any key the file doesn't set
val world = StandardWorld.build(
  WorldConfig(seed = 42L, widthCells = 512, heightCells = 512),
  params = params
)
  

Every tunable that reaches a version number at all is split into two kinds, and mixing them up is the module’s most-repeated caution to itself:

  • Stage.version — bump for a code change. Reaches the RNG (GenRng.derive hashes (seed, stageId, stageVersion, coordinates...)), so bumping it reseeds that stage and everything downstream — which changes which seeds expose a latent bug, not just the terrain. Reserved for real behaviour changes, never for retuning a constant.
  • Stage.paramsVersion — a fingerprint (ParamsDigest, hashed by field name, sorted) of every value the stage reads. Never reaches the RNG, so retuning a number moves the version vector and the chunk cache key but leaves the actual terrain shape alone for a fixed seed — “change one number and look at the same world.”

Every stage is currently at version 1 — reset once nothing had shipped, drifted for a few stages as real code changes landed, and was reset again in this cleanup pass for the same reason: still pre-release, still no counterparty for the compatibility promise a version bump makes.

Storage and streaming

What of a world is stored, what is regenerated, how player edits survive a regeneration, and how a chunk is materialized and streamed to the clients is on Chunk Storage & Streaming.

Biomes

The world has 21 biomes in six groups. Cold, temperate and warm biomes come from the climate classifier, see Biome motivation. Their climate is the centre of their prototype: a mean temperature and the rain per year. Edge, geological and water biomes are placed by a rule instead, in any climate where the rule holds.

BiomeGroupWhat it isClimate or rule
OCEANWaterThe open sea around the continents.Any; open salt water
LAKEWaterStanding fresh water inland.Any; water in a closed basin
ICE_SHEETColdPermanent ice, high or low. No soil, no trees, no caves.Below −7 °C with more than 150 mm of snow a year
TUNDRAColdA cold, open plain of moss, grass and low shrubs. Almost no trees.About −12 °C, 250 mm a year
TAIGAColdDense conifer forest with long, cold winters.About −4 °C, 770 mm a year
COLD_DESERTColdDry land in a cool climate: gravel, dust and few plants. Too dry for ice.About 1 °C, 40 mm a year
ALPINEColdMountains above the tree line. A few stunted trees at the edge, rock and meadow above.High, steep ground; about −8 °C
TEMPERATE_FORESTTemperateMild forest with four seasons and rich soil.About 9 °C, 1250 mm a year
TEMPERATE_RAINFORESTTemperateMild, very wet forest of tall trees, moss and ferns.About 8 °C, 2700 mm a year
GRASSLANDTemperateOpen plains of tall grass on very rich soil, with a lone tree here and there.About 9 °C, 520 mm a year
DRYLANDTemperateHalf-dry open country between grassland and desert: dry grass, scrub and scattered trees. Steppe, shrubland and savanna are all dryland.About 14 °C, 360 mm a year, strong seasons
DESERTWarmHot, dry land of sand and rock with almost no plants.About 24 °C, less than 180 mm a year
TROPICAL_SEASONAL_FORESTWarmWarm forest with a wet and a dry season.About 26 °C, 1440 mm a year in a wet season
TROPICAL_RAINFORESTWarmHot, wet jungle under the densest canopy in the world.About 30 °C, 3400 mm a year
BOGEdgeOpen, mossy peatland with a few stunted trees. Dead matter does not rot here, so bog iron and old remains are found in it.Flat, wet ground below 12 °C
SWAMPEdgeWarm forest standing in black water, like cypress or mangrove. Everything grows and rots fast.Flat, wet ground at 12 °C and above
RIPARIANEdgeThe band of trees along a river in country that has none away from it.Within 1.6 km of a river through desert, cold desert, dryland or grassland
BEACHEdgeThe low, flat shore where land meets the sea.Flat ground within 1.4 km of the ocean and below 22 m
BADLANDSEdgeBare, dry hills of soft rock, cut into gullies by erosion.Steep slopes of soft rock with less than 700 mm a year
VOLCANIC_FIELDGeologicalThe cone of a volcano and its lava fields. Fresh rock without soil or plants.Any; within about 2.75 km of a volcanic vent
GEOTHERMAL_BASINGeologicalValley floors near a volcano with hot springs, vents and sulfur crusts. Warm ground, some scrub, and good land for a town.Any; wet ground within 5 km of a vent

The table is read from data/biomes.yaml, and the Bestia Blueprint Calculator offers the same biomes as a habitat. When Biome.kt changes, change that file too.

Biome motivation

21 biomes today, classified by weighted distance to the nearest of several prototypes over seven normalised axes (temperature, precipitation, seasonality, temperature range, elevation, slope, wetness) — deliberately not a Whittaker-style lookup table, because a table partitions climate space into rectangles, and rectangles read as dead-straight biome boundaries on a map, which no real landscape has. A nearest-prototype classifier’s boundaries follow the shape of the climate instead, and the runner-up’s score doubles as a blend weight for soft transitions — once it is ranked against the world’s own distribution, which makes it a share, and applied through a coherent patch field rather than per column, which reads as a checkerboard.

Where a boundary falls on the map and how it is drawn on the ground are separate questions. The biome raster is kilometre cells, so the chunk tier looks it up through three displacements: a kilometre warp that curves an edge on the map, a 160 m warp that bends it over the distance a player sees, and a fray that lets each biome take patches of ground from the other within about 25 m of the line, from both sides. The confidence dither cannot do the last part alone: a cell’s runner-up is its nearest rival in climate, not the biome next door, so across most edges only one side would mix. Cover thresholds on smooth kilometre fields — the snow line, shingle on a cold shore, lake ice, blight — are dithered across a band in patches for the same reason: a bilinear field compared against a constant draws a contour that is straight inside every cell. ./gradlew :worldgen:probe -Pedges measures every such boundary in a world.

A few of the biome table’s shapes are worth knowing the reasoning behind, not just the result:

  • litter and canopy are deliberately uncorrelated axes. Litter feeds soil fertility (dead organic matter); canopy is per-cell tree probability. Grassland is one of the best litter producers in the table (0.7) and is nearly treeless (0.05 canopy) — conflating the two would put a forest on every prairie.
  • DRYLAND replaced three biomes that measured out as one place under three names — former STEPPE, SHRUBLAND and SAVANNA shared soil, cap, and movement-cost tables and differed only in how many trees stood on them, which is exactly what canopy already expresses continuously. Measured land shares before the merge were 0.6%, 21.2% and 1.4% — two of the three names covered almost nothing.
  • BOG and SWAMP are a temperature split of a single former WETLAND. A boreal mire and a tropical swamp are close to opposite ecosystems — one preserves organic matter because it’s cold and anoxic, the other rots it because it’s warm — so one biome for both was wrong everywhere a consumer asked what grows there. No third, intermediate biome between them by design: a temperate marsh would be the arithmetic mean of the two, owning nothing either doesn’t already.
  • A separate CLIFF biome was deleted outright, not merged. It wasn’t really a biome — a single slope threshold that capped everything under it in one grey GRAVEL regardless of what was actually there, making an ice cliff, a desert scarp and a granite crag indistinguishable. Steep ground keeps its climatic biome now; how bare it looks is a separate, voxel-scale question answered from the materialised surface gradient, which can see a fjord wall a vector feature cut and a kilometre-averaged raster cannot.
  • Volcanic biomes have no climate prototype at all — the classifier’s seven axes can’t see a lava vent, and giving one a prototype would claim volcanic ground has a characteristic climate, which is backwards: there are volcanoes under ice caps and in deserts. They’re placed by raw distance to a vent instead, sized in real metres rather than scaled to world size — a volcano is 10–30 km across on Earth and should be that size on a small world too, or a small world’s volcanoes would end up wider than its mountains are tall.
  • Beaches, badlands and riparian corridors are distance transforms, not classifier output — biomes driven by adjacency to ocean or to a river rather than by climate, which is why none of them has a table entry either.

World size, wrapping, and scale

Genesis, the server’s default world, is 128 km across. zone-server boots it, and every world size in between the smallest anything is tested at and the multi-minute 4096 km world the module’s design space allows for is supported the same way — nothing in WorldConfig requires a power of two, a multiple of the chunk edge (32), or a multiple of the climate-coarsening factor (4); detailScale, the ocean margin, and climateResolutionFor are all continuous functions of the world’s extent. A dedicated test suite (WorldSizeSanityTest) builds worlds at 96, 150, 200, 337 and 600 cells — none of them round numbers — and runs the full generation-invariant battery against each, specifically to catch anything that only breaks at an awkward size.

WorldConfig.detailScale compensates for genuinely small worlds: most interesting terrain features are gated on absolute size (a river needs on the order of a hundred square kilometres of catchment before it cuts a channel), so a 128 km world scaled 1:1 against thresholds tuned for a 512 km reference world comes out as a plain with a stream on it. detailScale divides length/area thresholds so a small world earns its features anyway — deliberately unphysical, capped at 8, where river networks start looking like a fractal mat instead of a landscape. It’s computed fresh from the config every time rather than stored, since a stored value goes stale the moment copy() changes the world’s dimensions without updating it.

What does not scale with detailScale: settlement density. Terrain wants to be denser on a small world; the number of places worth walking to does not, so cityTarget is a flat density (worldArea / areaPerCity) — measured, 512 km gives roughly 292 settlements and 1024 km roughly 1171, almost exactly 4× for 4× the area.

The world wraps on X by default (Y is off by default — temperature is a linear ramp in latitude, so a Y-wrap walks one pole into the other; Genesis turns it on anyway because the alternative is a wall a player can walk into, and the discontinuity lands inside the same ocean margin that hides the X seam, in unreachable polar sea). Both seams hide inside a 2.5 km underwater margin forced around all four edges — a flat distance rather than a share of the world, because what it has to beat is the client’s view distance, which has nothing to do with how big the world is.

How many worlds are there

The world seed is a Long — the full 64-bit range, drawn via kotlin.random.Random.nextLong() with no masking or narrowing when none is configured — so the seed space alone is 2⁶⁴, about 1.8 × 10¹⁹. Since none of a world’s other parameters (dimensions, wrap flags, detail scale, and so on) feed the random-number generator at all — only the seed does — every one of those roughly 1.8 × 10¹⁹ seeds produces a genuinely different world for a fixed configuration, and changing the configuration on top of that makes the space of distinct generatable worlds unbounded in practice (dimensions and the continuous tunables in WorldParams have no finite bound). In practice, exactly as many worlds exist as a deployment chooses to run — one, for zone-server today (Genesis).

That number matters for a reason beyond curiosity: because worldgen is open source and regenerates a whole world — every ore deposit, cave hoard, and ruin included — offline in well under a second, the seed itself is the only thing standing between a player and every secret the map holds before they’ve explored an inch of it. The seed is deliberately never transmitted to the client (WorldInfoSMSG excludes it by explicit design comment on both the Kotlin and .proto side), and no admin/REST endpoint or chat command exposes it. The one real gap found in this pass: the shipped application.yml pins a fixed, public development seed with no documented production override path — now documented next to the value itself and on WorldGenConfig.seed. A real deployment must leave it unset (which draws a fresh one at random on first boot) or supply it from a non-committed, environment-specific source, before the world’s first boot — the seed is permanent in PersistedWorld from that point on.

Benchmarks

World-tier build time, one JVM, one rep, measured serial against parallel (./gradlew :worldgen:bench -Pcells=N; 16 workers on the measuring machine). This is the world tier only — tectonics through nav-graph — not any chunk materialization, which happens per-chunk on demand and separately (a single chunk materializes in well under a millisecond).

World sizeSerialParallelSpeedup
32 km58 ms43 ms1.35×
64 km210 ms150 ms1.40×
96 km511 ms291 ms1.76×
128 km (Genesis)676 ms334 ms2.02×
192 km892 ms617 ms1.45×
256 km1.61 s1.08 s1.49×
512 km (reference)15.1 s7.4 s2.05×
700 km52.1 s27.4 s1.90×
1024 km122.9 s94.7 s1.30×

The reference 512 km world builds in a few seconds and stays comfortably under Genesis’s own boot budget; a 1024 km world is a minute and a half even in parallel, which is squarely a “behind a progress bar” size rather than a “boots with the server” one.

Parallelism helps less as the world gets bigger, not more — and one stage is why. pond (moraine-dammed lakes and oxbows) took 1.0 s at 512 km, 10.3 s at 700 km, and 50.3 s at 1024 km — for 1.9× and 4× the area respectively, that’s roughly 10× and 50× the time, and it does not parallelize at all at that size (1.00× and 1.01× speedup, against the whole pipeline’s 1.90×/1.30×). At 1024 km it alone accounts for 41% of the total build. This is reported as a measurement, not yet a diagnosis — consistent with this module’s own habit of measuring before reasoning about a constant, the cause hasn’t been isolated here and the fix, if one is needed, belongs to a change that can watch the number move. towns shows the opposite oddity: 28.1 s at both 700 km and 1024 km, essentially flat despite the larger world — plausibly a cap (settlement count, or TownParams.maxBuildingsPerSettlement) saturating rather than a bug, but likewise unconfirmed here.

For curiosity: extrapolating the 512→1024 km ratio (naively, ignoring the pond anomaly above) puts the design space’s 4096 km world at several minutes serial — which is exactly why the module treats “boots with the server” (128 km) and “generates while you watch in a viewer” (512 km) as the two sizes that matter in practice, and everything past that as backed by :worldgen:bench/:worldgen:viewerExport rather than by a live boot.

Tooling

  ./gradlew :worldgen:test                          # unit tests
./gradlew :worldgen:viewer -Pgenesis               # interactive layer/feature/voxel inspector, on the server's real world
./gradlew :worldgen:viewerExport -Pout=...         # same, rendered to PNGs (works over SSH/CI)
./gradlew :worldgen:invariants -Pseeds=200         # seed-sweep regression harness against every generation invariant
./gradlew :worldgen:probe -Pchannels=1             # inspect a small window at voxel resolution as text
./gradlew :worldgen:bench -Pcells=512 -Preps=3     # serial vs. parallel world-tier build timing, one JVM
./gradlew :worldgen:town -Pcensus                  # every settlement in the world, one table
./gradlew :worldgen:chronicle -Pquests              # the world's history, mined for unresolved threads
./gradlew :worldgen:diff -Pseed=7 -Pother=8         # two worlds (two seeds or two params files), layer by layer
  

-Pgenesis reads zone-server’s actual worldgen: configuration block rather than a demo config, so the tools inspect the real world the server would boot — including its real wrap flags and dimensions, not merely a world with the same seed.

Last updated 04 Dec 2026, 01:08 +0100 . history