Devlog · No. 1 · The map

A continent from a number

How Elderdark raises a whole country from one number: plates on a globe, mountains where they meet, the rain and the rivers, the towns and the roads between them, and the realms that share it out.

A close view of a generated map in pale ink on dark blue-grey ground ruled with fine lines: cyan rivers, wide and narrow roads, town rings with small flags, and names such as Wealrow, Halmere End and the City-State of Elmwell.
Seed 20260830 up close, at the zoom you play at: rivers that found their own way to the sea, roads that found theirs between the towns, and the flag of whoever holds each one.

Every campaign of Elderdark begins with one number. From it the game turns plates on a globe, raises mountains where they meet, lets the rain cut the land into valleys, settles towns where people would live, joins them with roads, and shares the country out among its powers. Nothing on the map is placed by hand, and no two numbers give the same country.

The map is the board the whole game is played on. You are a god with no body and a handful of mortal agents, and the Church and the Crown are looking for you. How far apart two towns are, which roads are busy and which valley a hunter has to come up to reach you are all the map's doing, and they decide as much as any rule. The size of the world is your cover.

While a world is made, the game shows a card that lights one step at a time: the plates are laid, the mountains are raised, the westerlies bring the rain in, and so on. This post follows those steps in order, with pictures from the game's own code, and then goes back over what went wrong on the way, because most of what is good about the map we learned by getting it wrong first.

Seed 20260830, in numbers

  • A grid of 601 × 401 cells, 6 km to a cell: a window 3,600 by 2,400 km across
  • Two plates meeting under the window, their seam along the continent's north coast
  • 7 great realms (two kingdoms, a jarldom, a khanate and three marches) and 6 small powers between them
  • Made in about a minute, then kept on disk

The plates are laid

The game starts with a whole globe. It is broken into twelve to sixteen plates, and each plate turns slowly about a pole of its own. One continent is put where the game is played, centred between 45 and 50 degrees north, and five to seven more are kept far enough off that none of them reaches into the window. The window is cut from the sphere by a projection that stays true to within two per cent, so a day's walk is the same length in every corner of the map.

Where the continent sits is tried sixteen times, and the try with the hardest meeting of plates under it is kept, because that is where mountains come from.

A globe drawn in two dark hemispheres with faint grid lines: on the left a small continent outlined in pale ink, on the right and below it two larger continents drawn as faint coasts filled with fine marks.
The globe of seed 20260830, as the game draws it past the whole country. The continent you play on is the small one on the left; the others are kept far off and left unnamed.
A diagram of the map window in two flat colours, one for each plate, divided by a thin pale line running from the left edge across the north of the continent to the bottom right. Land is drawn stronger than sea on each plate.
The two plates under the window, as a diagram. The pale line is where they meet, running along the continent's north coast; land is the stronger colour on each.

The mountains are raised

What happens at each edge depends on what meets there. Where two continents push into each other, a broad high range rises. Where an ocean dives under a continent, a range rises set back from the coast, with a trench offshore. Where two oceans meet, a curved arc of islands comes up, and where plates pull apart, the land sinks into a rift. A great range is laid in three to five offset pieces with passes between them. It bends, throws spurs and fades into hills at one end, and a test fails any hundred kilometres of crest that runs too straight. A world whose plates meet nowhere on land gets no great range, and its high country is scattered instead.

Then the land rises, and rivers cut it as it goes. Every cell is lifted a little, the plate edges a lot, and each cell is held above the cell its water drains to by the uplift divided by how much water passes through it. Ground that drains a large basin is cut low into a valley; ground near a divide stays high. The whole land is shaped this way, with no random noise laid on it. That is why every valley runs on down to the sea and none ends in a pit.

Last, the sea is raised until a third of the window is land. It floods the broad valleys first, so they become bays and inlets, while the ridges between them are left standing as headlands. A rule keeps the world to one continent: a second large landmass is either joined to the first by a strait or drowned.

A diagram of the continent's heights in flat colours: low ground dark blue-green, hills olive, mountains tan to pale. Branching valleys run from the high ground down to every coast.
The heights, as a diagram, not as the map draws them: lowland dark, hills olive, high ground pale. Every valley branches back from the sea, because the rivers cut them all.

The rain comes in

The winds blow in belts by latitude, and the continent sits in the westerlies. Air crosses the window one column at a time. It picks up water over the sea and drops it as the ground rises, more of it the steeper the climb. So a range's windward side is wet, and the country past it lies in a rain shadow. Warmth comes from latitude, less six and a half degrees for every kilometre of height.

Rain and warmth decide the cover. Woods grow where the land is wet enough and above freezing, marsh lies on low wet ground beside water, and the cold and dry corners turn to steppe and tundra. Then each world may be given its landmarks, at most one of each family and never closer than 150 km apart: a high valley with a lake on its floor, a gorge, a lone peak, a spined peninsula, a high moor, an inner sea, a fjord coast, a deep wood whose heart is slow going, or a great marsh crossed on causeways.

The rivers find the sea

Water runs downhill from every cell to its lowest neighbour, with a small lean that makes the rivers meander. Where 340 cells drain through one cell, there is a river. Hollows are first filled to the brim, so water always has a way on. Those still full become lakes; the rest get a channel cut through their rim, so that no river ends in a dip in the ground.

Water run across a grid comes out as straight runs and sharp corners, so each reach is then laid again as a winding course of its own that never climbs. The rivers are drawn on a copy of the ground with their beds burned in, so no river on the map runs uphill. The great rivers lay down floodplains: long flat floors up to six cells wide in their lower reaches.

A diagram of the continent in dark blue with a dense branching network of cyan lines, brighter where more water flows, reaching every coast.
Where the water goes, as a diagram: every channel on the continent, brighter where more water drains through it. The map draws only those that drain at least 340 cells.

Towns, and the roads between them

Every cell has a price: the days it takes to cross. Slope and height cost the most. Woods, marsh, the deep wood's heart and tundra add to it, and fording a river costs more again. The prices are set so that crossing the whole country takes about two months, and walking from one town to the next about a week.

Towns are sited where people would live, on good ground and by water, at least 148 km apart. If the world has a high valley, its floor is settled first. Then one flood spreads out from every town at once over the priced ground, and each cell remembers how the flood reached it. Where two towns' floods meet, the road between them is the two ways back joined at the seam. The roads are smoothed by cutting their corners, and any town left stranded is joined to the nearest road. Each island gets a sea lane.

How wide a road is drawn depends on its traffic: the more journeys between towns that are forced along it, the wider it is. The busiest become great roads, named after the bigger town they serve, and the quietest stay tracks.

A regional view of the map: dark blue-grey ground ruled with fine lines, cyan rivers, roads of different widths in pale gold and violet, town rings with small flags, and realm names such as the Marches of Bradford and the Jarldom of Gristhorpe spaced across the land.
The home country of seed 20260830: the roads the flood found, wider where more journeys run along them, the rivers in their widths, and the flags of whoever holds each town.

The realms draw their borders

Each world draws how many towns a realm should hold, and from that how many great realms it has: four to twelve. Their seats are picked among the towns as far apart from each other as they can be. Then each seat's country is read for what kind of realm it should be: a kingdom, a duchy, a jarldom, a league of ports, a khanate on open plain, a see, a march on the borders, or a free city.

Each realm then spreads out from its seat across the priced ground. Its kind sets how freely it spreads: a khanate covers open country easily, and a free city barely leaves its walls. What none of them reaches is not left empty. Every pocket with a town becomes a small power of its own (a city-state, a league, a petty kingdom and so on), a large pocket with no town gets a seat raised in it, and slivers go to whichever neighbour they border most. No land on the map belongs to nobody.

The whole continent of seed 20260830 washed in muted colours by realm, each with a border strip of its own ink, rivers in cyan, town rings, and names such as the Kingdom of Bellcrag, the Bradmere Khanate and the Marches of Deephollow.
The whole country: seven great realms read from their own ground, among them the Kingdom of Bellcrag in the south, the Bradmere Khanate in the east and the Marches of Deephollow between.
The same continent in the small powers view: the great realms in grey, and the small powers between them picked out in colours by kind.
The small powers, in their own view: the great realms greyed, and the pockets between them held by city-states, leagues and petty lords, coloured by kind.

Drawing it

The ground is drawn by a shader that reads one value per cell: height, wood, marsh, lake. Land is one blue-grey family, blended smoothly from the lowland band to the high. Slopes are shown by fine ruled lines rather than shading, woods by small firs, cliffs by ticks and beaches by stipple. The sea is near-black, with soundings.

Rivers are cyan, in eleven widths by how much water they carry. Each realm is a wash of its own colour with a strip of the same ink inside its border, wider for a great realm than a small power, and the wash fades as you zoom in so the ground comes through. Every town ring carries its holder's flag. Pressing the realms key again turns the map to paper: the realms flat, with no ground under them.

Zoom out past the whole country and the map becomes a globe in two hemispheres. The continent you play on is drawn as the map draws it, and the others as a faint coast with marks for their kind of ground, unnamed and unexplored.

What went wrong on the way

The map in this post is the second generator. The first raised its land from a chain of round swells, and most of what the second does right, the first taught us by getting it wrong.

The flat slab. A dozen swells overlap three or four deep in the middle of a continent, and the first version simply clamped the sum. The result was a flat slab with a coastline round it: no relief, so no slopes, so no passes, and no reason for a road ever to bend.

Four times the grid, the same coast. While the coasts still looked too smooth, we quadrupled the grid. The build went from 2.9 seconds to 13.5, and the coastline came out exactly as smooth, because a smooth shape sampled more finely is still smooth. What fixed it was bending the shape, not sampling it harder. Today's coasts get their bays another way, from valleys the sea has drowned, which is the same lesson again: the detail has to come from somewhere.

The worlds with no rivers. For weeks, two of the three worlds we tested against had no rivers at all, and the third had two. Nobody noticed across a dozen screenshots, because a continent with no rivers does not look broken. It looks like dry country. The old code followed a few rivers down from sample springs, let water step up over a little rubble, and nudged it on flat ground so it would wander. Each choice made sense alone; together they let water step back and forth between two cells until it gave up on dry ground. Now water runs from every cell, and the tests count the rivers of every world they build, because a picture cannot show you what is missing.

Half a texel. For a whole round of work every colour on the map sat a few pixels off the lines drawn from the same data, and we kept adjusting the colour and the sharpness of its edge. Neither moves anything sideways. The cause was half a texel: a texture stretched over the map puts its pixel centres half a step in from the points the lines are cut from. After the fix the error went from about two pixels to a fifth of one, and the game gained a tool that measures it.

Four towns called Pikescar. Town names are built from parts, a stem and a tail. One bug walked the pool of parts with the wrong stride, so a whole world drew from fourteen names: four towns called Pikescar and three called Deepcrag.

More than half the defects the first map turned up were found by looking at a picture, and showed in none of the numbers. The rivers taught the opposite. So we use both: every world the tests build is counted, and every change is looked at.

Every number is a world

Six seeds run for this post gave anywhere from four great realms to twelve, and from one small power to eleven. A world is made once, in about a minute, and kept on disk, so after that its ground is read back in about a second. The ground and the map draw from their own dice, apart from the game's, so nothing that happens in a campaign can move a coastline, and the same number always gives the same world.

A continent like a broken ring around a wide inner bay, with islands to the north-east, washed in many small realms.
Seed 4242: twelve great realms
A rounded continent with a tail of islands to the south-east, washed in four large realms.
Seed 1848: four
A broad continent with a long peninsula reaching south-west and a scatter of islands, washed in five realms.
Seed 777001: five
Three more numbers, three more countries. The same steps, three other numbers.

Playing on it

The map is the game's main screen, and every other screen opens over it. A journey takes the days its road costs, and an agent with no reason to be away pays for the absence, so where things are on the map is what a plan is made of. Nine views sit on the number keys: the realms, the ground, where you are suspected, where your traces lie, how far an agent can reach, what is in each place, the small powers, what people are saying, and the markets. Click a town and it opens: the same world eleven times closer, sharing the map's coast, rivers and roads. Devlog No. 2 is about how those towns are laid out.

The form below or the RSS feed will tell you when a new post is up.

Methods we read and learned from, never code: Guillaume Cordonnier and colleagues (2016) for land raised against the rivers that cut it; Richard Barnes, Clarence Lehman and David Mulla (2014) for the priority flood; John Lindsay (2016) for breaching hollows; and George Chaikin for corner cutting.