Skip to main content

World generator

Generated land for the large world (see Large worlds). Agreed with the owner on 2026-11-12, step by step.

What was agreed​

  • 1 m spacing everywhere, as on the home island. No 2 m tiles.
  • Start smaller and add later. The first pass is one middling continent and a few islands. More whole landmasses come later from the same seed, as disk allows. A landmass is never cut off at the edge of an area.
  • The world wraps at its final width, 350 km, set now (it was 24 km), so the seam never has to move. Every noise repeats at exactly that period.
  • The continent lies north of home (north is -Z), its near coast about 25 km away.
  • Today's land stays as it is: the home island, West Isle and Orochi Isle, with open sea round them.
  • Kinds of country: temperate forest and meadow, mountains and alpine, marsh and wetland, and dry land. They are placed by climate patches made with noise, some 20-50 km across, since a wrapped world has no poles.
  • Lakes and ponds in the first pass; rivers in a second pass, carved from a world-wide water map.
  • No hand-worked places from the generator. GMs shape villages, harbours, roads and dungeon entrances in-game with the terrain tools.
  • A Python script from a fixed seed, run on the owner's PC (the R710 has no numpy). It draws a map for approval before any tiles are written.

The script​

tools/worldgen/worldgen.py holds what the landmasses share: the noise, the climate, the lakes, the map and the tile writer. Each landmass is its own file in tools/worldgen/lands/ (the owner's rule: one model per file), a LAND dict with its centre, size, turn, how ragged its coast is, its shelf, its seed, and how high its mountains and hills go. The names are working names for the owner to replace.

py -3 tools/worldgen/worldgen.py map [--cell 50] # the picture and the numbers
py -3 tools/worldgen/worldgen.py tiles --out FOLDER [--workers 10] [--skip-done]

Every height is a function of (x, z) alone, worked out in 64 bits, so the map and the 1 m tiles come from the same numbers, and land made later from the same seed carries on from land made now. The noise is gradient noise written in plain numpy (about 40 lines).

  • Coasts: a turned ellipse, its points moved by noise (bays and peninsulas) and its edge by three more scales of noise; a shelf falls to the open sea's floor (-30 m), where no tile is needed.
  • Height: a rise inland, hills at three scales (plus 1 m detail in the tiles), and mountain ranges where a range noise is high, shaped by ridged noise. Marsh is kept low and flat.
  • Kinds of country: dry where warm and dry, marsh where wet and low, alpine on high ground; temperate elsewhere. The borders are ragged at 1 m.
  • Paint (Terrain3D's control words, with today's textures): temperate uses the home island's slope shader (grass on the flat, rock on slopes); dry is rock with Withered Grass; marsh is Forest Mud through grass; alpine is rock with Sparse Grass, and Snow above about 1,000 m (820 m before 2026-11-13; the live tiles were moved up with tools/worldgen/repaint_snow.py, originals in ~/moondog-tile-backups/pre-snow-2026-11-13 on the R710); shores and sea floor are Beach Sand. The colour map is a plain tint, as on home. No grass or plant instances yet.
  • Lakes and ponds: each is a flat level over a rectangle (as water_bodies keeps them), its level set 0.3 m under the lowest ground on the rectangle's edge, worked out at 1 m, so the water never ends in mid-air. Inside a ragged circle the ground is carved below the level. Rectangles never overlap. They are written to worldgen_lakes.json.
  • Kinds of country, kept: every 16 m, in worldgen_kinds.npz, for their own textures and trees later.

The first pass (2026-11-12)​

The northern continent (about 70 x 50 km) and six isles: three on the way north (north-west, Midway, north-east), one off each side of the continent, and one past its far coast.

Landabout 2,600 km² (home: 54.5 km²)
Temperate / alpine / dry / marsh1,727 / 391 / 354 / 132 km²
Highest point1,159 m (home: 107 m)
Lakes and ponds20 lakes, 160 ponds
Tiles43,548, about 0.2 MB each, about 8.7 GB

The tiles are written to a staging folder (W:\Moondogbackend\moondog-worldgen-out\tiles on the owner's PC), not the live one. Checked with the game server's own TileFile.cs reader. The full run takes about 5 hours at low priority on 10 of the PC's 12 cores.

Before players get the new land​

  • Clients download only nearby tiles: built 2026-11-12 (see Large worlds).
  • Many lakes: built 2026-11-12. The server keeps the lakes as a WaterSet (Water.cs), each listed under every 256 m square its rectangle touches, so Water.SurfaceAt looks only at its own square's, the first that covers it answering as before; the client does the same (WaterSurfaces.by_cell, Network.water_surface_at) and draws a plane only for the lakes within 4 km of the camera, worked out again every 100 m it moves. Checked with 180 made-up lakes: the indexed lookup matched a full search at 20,180 points, and only the near lakes got planes (5 of 180, then 2 after a 36 km move). The server's part takes effect at its next restart. Still to do: put the generated lakes into water_bodies when the tiles go live.
  • The wrap at 350 km: built 2026-11-12. Sea.WorldSize and Sea.gd WORLD_SIZE are 350,000 m, pinned equal in rpc_contract.json; WorldWrap.gd reads it from Sea.gd. Everything else follows the size: world cells (1,368 a side), tile keeping, pets, GM placement, the waves' repeat (snapped to 350 km, so they shift very slightly). Weather regions are circles with a world default, and the sea mask covers only home, so neither cared. Live on the R710; check_wrap.py passes at 175 km (a schooner crosses with the GM aboard, is drawn beside the GM across the seam, and the GM swims back across).
  • Backups: checked 2026-11-12, no new scheme needed. scripts/backup_tiles.sh (03:30 nightly) already hard-links every tile unchanged since the night before, so 14 nights cost one copy (about 10 GB with the new land) plus what changed, on the system disk (78 GB free). It now refuses to run, and says so in its log, when a night could leave less than 20 GB free there (the disk also holds Docker and the database).
  • Copying the tiles: done 2026-11-13. Written on the PC in 2 h 36 min (43,548 tiles, 9.08 GB, highest point 1,162 m with the 1 m detail), copied to a staging folder on the R710 (byte totals equal on both sides, no names shared with live tiles), then moved into ~/ssdone/moondog-world/tiles (44,381 files; 35 GB left free). The 180 lakes and ponds went into water_bodies as Lake <seed> and Pond <seed> (182 rows with home's two). The generator's worldgen_lakes.json, worldgen_kinds.npz and worldgen_keys.json stay in ~/ssdone/moondog-worldgen-staging/tiles.
  • Checked in-game with scripts/check_new_land.py: a GM sent by @tele stands on the ground at the generator's height (268 m and 539 m on the continent) and swims at a lake's level. It found that the client sent no input while waiting for the ground under it to download, so a player whose tiles took over 10 s was dropped by the server as gone; Player.gd now sends a standing-still input while it waits.

Rivers (second pass, 2026-11-13: the map)​

Agreed with the owner before any trees or plants go on the land, so nothing stands in the water: 3-5 big rivers on the continent from the mountains to the sea, smaller ones on the big isles and many streams; rivers run through lakes; the current pushes swimmers and boats; steep drops are waterfalls with plunge pools, steep runs rapids boats cannot pass; big rivers 60-150 m wide and 4-8 m deep at the mouth, so small ships can sail some way up; estuaries in temperate country, deltas through marsh; today's land untouched; sound generated like the wind's.

tools/worldgen/rivers.py, drawn by worldgen.py map --rivers (with --cache FILE to keep the ground between runs). On the map's 50 m grid: a priority flood from the sea gives every cell the cell it drains into (over the ground plus a little noise, so courses wander rather than follow the grid), filling hollows to their brim; rain, more where the climate is wet and less on dry country, is added up downstream; a cell carrying 2.5 km2 of rain is a stream. Width 2.2 A^0.65 m and depth 0.5 A^0.38 m (A the rain-weighted km2 above). A main stem follows the branch with the most water at every joining. A drop of 8 m or more between neighbours, three times the stretch's usual, is a waterfall (falls within 400 m are one); a slope over 3.5% is rapids. Smoothed, and swung into meanders where the land is flat. A hollow the flood filled 2.5 m deep and 0.15 km2 wide holds a new lake (level just under its brim, a rectangle round it like water_bodies); a shallower one gets the river cut through its rim when carving.

First map: 262 courses, about 1,040 km of water; three big rivers reach the sea (505, 462 and 243 km2 drained; 126, 119 and 78 m wide and 4-5 m deep at the mouth; two deltas and an estuary); 50 waterfalls; 241 hollows deep enough for a lake or pond (149 km2 of water). The owner kept them all.

At 1 m (2026-11-13). The courses become reaches (build_reaches): eased out of the grid's zigzags (more for bigger water), corners cut, swung into meanders about fourteen widths long and up to a width or so each side on flat land, never wider than the bend allows (so they never fold back), and sampled every 8 m. The water's surface comes from the real ground at 1 m detail: 0.4 m under the ground at the course's middle, only ever stepping down, at a lake's level through it, and met by a branch at the surface of the river it joins. Waterfalls are found on the real ground (the map's were on the routing noise): at the head of a stretch falling 16 m or more over 120 m at 13% or steeper, on water 6 m wide or more, 1.5 km apart at least, the drop (60% of the stretch's, 4-25 m) is taken sheer and the river below runs in the gorge it has cut until the ground comes down to it; 50 of them. Estuaries widen to four times over their last 3 km; a delta fans two side channels out from 4.5 km before the sea. All saved in worldgen_rivers.json (each reach's points: x, z, surface, width, depth, current m/s; the lake each point is in; falls; what it joins): the carving uses it, and so will the game's river water.

Carving (carve): a rounded channel under the water, banks sloping up to the ground (1 in 2, or 1 in 4 for rivers over 40 m wide, out to 0.8 widths), a levee 0.25 m over the water where the ground beside it is lower, and a plunge pool 2 m deeper than the river under each fall. Beds are painted mud with sand. worldgen.py tiles --rivers worldgen_rivers.json --touched worldgen_keys.json writes only the tiles a river reaches: 5,913 of them, to moondog-worldgen-out/river_tiles (staging).

Deep cuts (added after the first look in game): past the near bank a cut's side rises as a rock wall at 1.4 rise over run (55 degrees) for up to 30 m, so a gorge below a fall or a river deep in a steep valley has sloping rock sides rather than sheer cliffs.

Rivers in the game (live 2026-11-13)​

  • The file: worldgen.py game-rivers writes rivers.json (4.4 MB, 1.25 MB gzipped) beside the tiles: each reach's points every 8 m as [x, z, surface, width, current m/s], its waterfalls (the surface steps sheer halfway to the next point) and its points inside a lake. The current is worked out over at least 40 m or the river's width (from the fall of the surface, waterfalls left out: 0.3 + 6 sqrt(slope) m/s, at most 4), so it is steady rather than flickering between slack and quick; 1.4 m/s or more is rapids.
  • Server (Rivers.cs): the reaches filed by 256 m square. Between two points the water covers everything within half the width of the line joining them; the stretch whose middle line is nearest answers (a wide river's point lies within half a width of stretches tens of metres up and down stream too). Water.SurfaceAt asks the lakes, then the rivers, then the sea, so swimming, creatures, fishing, boats and ships all find river water. A swimmer and a rowed boat are carried by the current (quickest mid-stream, 35% of it at the banks); a boat rides the river's sloping surface; rapids and waterfalls stop boats and ships.
  • Portal: GET api/tiles/rivers (gzipped) and api/tiles/rivers/stamp.
  • Client (Rivers.gd): downloads and caches the file by its stamp, files it on a worker thread, answers exactly as the server does, and Player.gd predicts the drift and the boat's slope the same way. RiversView.gd draws the reaches within 3 km as ribbons (river.gdshader: ripples carried downstream at the current's speed, white water on rapids, foam at the banks) and a curtain at each waterfall (waterfall.gdshader). Weather.gd adds a burble near flowing water and a roar near falls.
  • Lakes beside rivers: lakes answer before rivers, and a carved channel inside a lake's rectangle below its level would be claimed by the lake. So river points crossing a lake's hollow (ground within 1 m of its level) are the lake's, and a lake whose rectangle still holds a river's channel is split (worldgen.py split-lakes) into rectangles covering only its own connected water, down to 16 m pieces: 157 lakes became 3,249 rows (3,515 water_bodies rows in all). The client draws a lake's pieces as one mesh.
  • Checked with scripts/check_rivers.py: a GM dropped mid-stream in a 100 m river floats at its surface and drifts 6.8 m downstream in 8 s on the client and 6.9 m on the server. Screenshots: the river at noon and dusk, the 25 m waterfall at the head of its gorge.
  • Ships (Ships.cs ServiceShips, added the same day): a ship neither anchored nor beached is carried by the current at her middle, on top of her own way, unless the drift would put her bow, stern or middle where she cannot float (aground, or into rapids). Checked with scripts/check_river_ship.py: a knarr with no sail set, moved into the big river, drifted 6.7 m downstream in 10 s.
  • Not yet: a rowed boat on a river seen in game.

Disk​

Tiles take about 3.5 MB a km² at 1 m (measured: today's 832 tiles take 188 MB). They live on the R710's Kingston A400 SSD (~/ssdone, 120 GB, 43 GB free, 49 GB of it Shows and Movies); backups go to the system disk (82 GB free). The other disks are 93-99% full.