Devlog · No. 2 · The cities

The roads come first

How Elderdark lays out every town on its map from the roads that reach it: the square where they meet, the wall it can afford, the blocks and plots, and in a capital some fifteen thousand houses, each standing where it stands for a reason.

A small open town drawn in muted violet on a dark ground, astride a river: the market and chapter house by the bridge, the inn and the burial yard to the south-west, the granary and a lazar house out along the eastern road, a post mill up the stream, and clumps of trees in the fields.
Skarsand Landing, an open town of 211 households, astride its river. The market and the chapter house stand at the bridge, the granary and the lazar house out along the road, and a post mill up the stream.

Last month's post ended with a click: a town on the map opening into a city. This one is about what opens. Every place on the map of Elderdark, from a hamlet to a capital of three and a half thousand households, is laid out street by street and house by house, just before you first look at it. Nobody drew any of them, and no two are alike.

A town matters to a hidden god for the same reason a map does: it is cover, and it is a place where things can be found. Your people rent rooms in its houses, rob its houses and meet in its courts, and what kind of house a room is in sets what it costs and how many eyes are on it. A room in a slum court can hide a bigger congregation than an ordinary house, and the rich quarter stays a walled mass until somebody of yours gets inside.

So the plan has to be right in a particular way. It doesn't need to be pretty first. It needs to be a town where every street can say why it is there. This post goes through how the generator builds one, in the order it builds it, starting with the first version, which got it backwards.

A capital, in numbers

  • About 15,500 to 16,500 houses, 2,000 streets and 130 parish churches
  • Five kinds of house, from a hovel in a court to a mansion round its own courtyard
  • Every place on the map laid out: 81 of 82 in one world, the last a lost site with no building to lay out
  • A market town laid in under two seconds, a capital in under a minute, on a worker thread while you play
  • One metre to a plan unit, and the same zoom for every town, so you can see at a glance how much bigger one is than another

The first town got it backwards

The first version of the generator, in September, worked the way most town generators do. It cut the town into a mesh of Voronoi cells spiralling out from the middle, made the wall the outer edge of the cells, ran the main streets along cell edges from the gates to the square, and shrank each cell into a block. Streets came in three widths, fixed by what they were called. It was quick, and it looked like a town.

It took a morning to see what was wrong: no street could say why it was there. A street ran where two cells happened to meet, and it was wide because it had been labelled a main street. So the next version, the same morning, turned the order round and laid the roads first. That is the generator this post describes, and "a street says why it is there" became a test it has to pass.

It wasn't right first time either. The first roads-first towns grew their streets as spokes from the square, until two prices were added: walking through a street's row of houses costs three times the open ground, and opening a new way onto a street costs as much as 48 metres of walking. With those, the spokes turned into back lanes. Then a count the next day found a third of every town's ground held by nothing, and streets that grew like a tree, every junction a T and no loop anywhere. Three ways of growing streets were tried side by side, and splitting blocks gave the cleanest. That is where the rule below comes from: a street, two rows of plots, then the next street.

The roads come in

Nothing is laid out first and then given streets. The streets are laid, and everything else follows them.

A town's plan is the world map read eleven times closer. Its coast is the terrain's own waterline, its rivers are the rivers the map draws, and the roads that reach it are the map's roads, arriving from wherever they really arrive. Near the water the waterline is nudged by a fine noise of its own, so a harbour town gets coves and points the map's cells are too coarse to hold. A town too close to the water steps back inland, so the harbour is at its edge and not through its middle.

The size comes from the world, not the screen. Every town knows its households, and it gets about 25 houses a hectare inside a wall, 23 in an open town. A bigger town is not given more of the map. The plan zooms further into it instead, so a capital fills its piece of the country rather than spilling over its neighbours. Here is the one place we cheat. The world's greatest town is about the size of a real late-medieval city such as Nuremberg, and a real capital was three to six times that. So a realm's seat is laid three and a half times larger than its household count. Every household, income and recruit stays the world's; the plan just draws more houses than the seat has families, so a capital looks like a capital, and one factor for every seat keeps them in their order of size.

The square is where they meet

Every road the map brings in carries on inside, busiest first, each by the cheapest way over the ground. The ground is priced the way the continent's roads price it, and a street already laid is cheaper to walk, so a second road joins the first where the land brings them together. A fork is wherever it was cheapest to fork. Where too few roads arrive, the town makes its own ways out to the fields, one for every 550 metres round its edge, between two and eight of them, and one running right through. Every road's own street is a main street at least twelve metres wide from the gate to the middle.

Where those streets meet is the square. In a port it is the waterfront. Where roads come in on both banks of a river it is the bridge head, and where two roads fork it is the fork. The square's ground is taken before anything else, so nothing can ever build over it: a widened street where one road runs through, a triangle where two split, a broad place where several cross.

A wall is paid for

Walls cost money, so in the game they do too. A town earning 20 or more has stone with towers. From 15 it has a bank and ditch, with bars across the roads. Below that it has nothing, and you can walk in from any field. Cities are walled whatever they earn. The wall is six metres thick, the ditch eight, and towers stand about a hundred metres apart.

The ring sits on the brow of the ground where there is one, and it keeps to dry land. A walled town of over two thousand households also keeps what is left of an older, smaller ring about six-tenths the size, broken wherever a street crosses it, because big towns grew out of their first walls.

A town with no wall

The smallest towns earn too little for a bank and ditch, let alone stone, and they are where the generator is at its best. An open town is laid by the same steps as a capital, and comes out looking nothing like one. With no ring to stop at, it follows its roads out: it reaches about 1.6 times as far along them as a walled town of its size would, so it straggles along the way to the next town and down the lanes to the water, thinning into closes, orchards and fields. It is laid a little looser, at 23 houses a hectare.

Everything a capital has is there at a smaller scale. The square is still where the roads meet, with a market on its quiet side. The chapter house, the inn and the shambles stand where a capital's would, the granary and the lazar house sit out along the roads, and a post mill stands by its stream. The quarters' grain does most of the work. A few slithering lanes and a tangle by the river make a village look like a village, and the same rules across a capital make a city.

A small open town on a spit of land in dark water: lanes branching from a market and a chapter house, an inn, a shambles, clumps of trees, and fields behind.
Coldstead, 211 households
A small open town beside a bay: a knot of lanes round the market and chapter house, the granary and the shambles to the west, the inn and a lazar house out along the road.
Rushham Fields, 211 households
A small open town spread round the head of a bay, its lanes running out in every direction from the market and chapter house.
Haldstrand Hook, 394 households
Three open towns of one world. Each follows its own roads and its own shore.
The middle of a small open town: coloured market booths on a square beside a church in its yard, the chapter house marked, a clump of trees, the shambles with its pens on the road out, and houses with ridged roofs along winding streets.
The middle of Coldstead. The market's booths on the square, a church in its yard, a clump of trees, and the shambles with its pens on the road out of town.

A named place is its building

The places the game is played in, such as the guildhall, the chapter house, the magistrate's court, the tavern, the shambles and the docks, are put down before a single house. The biggest go first, so the biggest find room. A cathedral close or a stronghold takes its ground out of the housing, and the lanes go round it, not through it.

A seat of power has a palace on ten times a manor's ground. It is laid out range by range: a gate range with the gatehouse over its gate, an outer court with stables down one side and kitchens down the other, the great hall across the end, and an inner court beyond it, with the chapel set against whichever range lets it run east and west. The castle stands in the palace's plot with a tower at each corner, and the garrison shares its curtain wall, with a door between them. Off a citadel's port, a star fort stands on its own islet.

A palace drawn from above: a large rectangle of ranges round two courts, inside a walled ward with a tower at each corner, set among estates and trees.
The palace and its castle ward
The garrison: a walled compound of barracks and a yard, sharing a stretch of curtain wall with the castle ward beside it, with gardens and estates beyond.
The garrison, sharing the castle's wall
Vensmarch's palace, laid out range by range, and the garrison built against the castle's curtain with a door between them.

Not every church is a named place. Small parish churches with their churchyards are scattered through every town as part of its fabric, and they do much of the work of breaking a city into neighbourhoods and giving it small open spaces. A capital holds about 130 of them, in five forms, from a west tower to an apse.

Two rows of plots, then the next street

After the main streets, the square, the wall and the named places, what is left is ground between streets, and it has to become blocks. The generator lays them the way planned medieval towns were laid: a street, two rows of plots back to back, then the next street.

A block is split, biggest first, until it is two plots deep and short enough for cross streets to come often. Every block that ends up cut off gets a way in, over a bridge if need be, so no ground in a town is out of reach.

The city of Vensmarch drawn in muted violet on a dark ground: a river winds through hundreds of small irregular blocks, with marked places such as the Cathedral Close, the Guildhall, the market at the bridge head, the chancery, the Magistrate's Office and Aurelard House.
Vensmarch, capital of the Kingdom of Marmere. Blocks two plots deep, quarters of different grain, the main streets running in to the market at the bridge head, and the fields beyond the wall.

Quarters with their own grain

A town split that way everywhere would look like graph paper, so the ground is cut into patches, and each is split one of five ways. Tidy quarters have nearly square blocks. Slither quarters have waving streets. Arcs bow away from the middle and nest inside each other. Steps take one square jog, and tangle quarters kink twice, get cut more often and let their lanes end blind. A smooth noise field picks the kind, so neighbouring quarters shade into each other rather than switching at a line.

One rule keeps the streets from running in rings. A long block that curves round the middle of town would, split along its length, grow a street that curves round too, then another inside it, and so on. So a block that runs round the town is cut across first, and its streets run in towards the middle.

Width is traffic

The map's rule for roads carries over: a street is wide because of what it carries, never because it was declared important. Every road brings in its traffic, every named place draws its own, and every house sends its people out by whichever street is nearest. All of it is carried down the streets to the square, and a street's width follows what it carries. Every street keeps a note of why it is there: that one is the Salt Road going to the market, that one is the way down to the quay, that one is where the houses behind get out. Then the clean-up passes run, which come next.

Fifteen faults, each with a pass named after it

Laying streets first and fitting everything round them leaves its own kind of mess, and each mess got a pass of its own, named after the fault it prevents. A few of them:

  • A tower standing in the street. Wall towers were set out to clear the street inside the wall, and then stood on whatever ran outside it. Now a tower slides along the wall to a clear spot, or isn't built.
  • Lanes at fault. In one world, 29 of 16,221 lanes doubled back on themselves, ended on nothing, or met their street at a knife's angle. Now such a lane isn't laid and its block stays whole, and the pass repeats until no chain of lanes ends on nothing.
  • A street through a building's front. Named places are put down before streets get their widths from traffic, so a busy street could widen straight into the guildhall. Now the building is carried back out of the street.
  • Slivers by the noble quarter's wall. Strips too thin to build on were left bare along the wall. The first fix stepped the wall out and back round each one, and one quarter went from 59 towers to 127. Now the wall slants out over the sliver.
  • A stub off a junction. A street ran one cell past its crossing and stopped in the open, two points long.

Some faults are about where a thing stands rather than how it is drawn. A lazar house belongs out of town, and so does a shambles, but for a while a port could put both among its houses.

A walled port on a headland, its blocks packed inside the wall, with the lazar house and the shambles marked among the houses in the middle of town.
Before
The same port after the fix: the lazar house out in the fields by the burial yard, and the shambles at the edge of town.
After
Hollowwell Cross in October, in the game's older look. Before the fix its lazar house stood in the middle of town; after it, out in the fields by the burial yard, with the shambles moved to the edge.

A map of money

Before a house goes up, every point of ground in the town gets a worth between nothing and one. It is highest round the market and the cathedral close and falls going outward, lowest outside the walls, downstream, and beside the tanneries and the shambles. Any town of fifteen hundred households or more has slums.

The worth picks the house. There are five kinds, poorest first: hovel, cottage, townhouse, merchant's house and mansion. On rich ground the great houses get wider, not deeper, as a rich man bought up the plots on either side and built one house across them. A house sits at the street end of its plot, square to the street, and the rest of the plot is yard or garden. Where a street curves, the plots fan out behind the houses, and odd shapes read as gardens.

The kind of house matters in play. When your people take a room, its house sets the rent, from 300 for a hovel to 1,500 for a mansion, and how closely anything done there is noticed: a crowded hovel has more eyes on it than a mansion behind its wall. It also sets what a burglar finds. A hovel has no lock and holds money and goods; a mansion has a high wall, a strong lock and a watchman, and holds valuables, papers and books. A town that raised no mansion has no mansion to rob.

Every footprint is a rectangle, or rectangles joined into an L, a T, a U or a courtyard. Every roof is pitched the same and starts from the same height, so a roof's height at any point inside it is simply how far that point is from the nearest wall that isn't a gable. That one rule gives every roof. It is the same answer a straight skeleton gives, the standard geometry for roofs, worked out to a millimetre. Houses that share walls along a street are joined into one outline, so from afar a row reads as a ribbon.

Street level in a small open town: houses with ridged roofs and small yards along winding lanes of different widths, a church in its yard, and a bay at the edge.
Street level in Rushham Fields. Houses at the street end of their plots, yards behind, and lanes that are as wide as the traffic they carry.

The castle, the slums and the market

The noble quarter

In a capital the castle's gate opens onto a walled noble quarter, about a tenth of the town, with a wide street running out from it. The quarter is laid as estates, each with a way in, a forecourt, a lawn, a garden and outbuildings. Two to five of the greatest houses are built in rings round their own courts. There is a wood round a pond, and the streets wind so that no stretch runs straight for long. Nothing behind its wall can be rented or robbed, and until somebody of yours is a servant in one of its houses or a member of a noble house, the city map shows it shut.

The noble quarter: large houses standing apart in wooded grounds, with ponds, winding drives and a round place where five streets meet.
The noble quarter, opened. Estates in their grounds, woods round ponds, winding drives, and a round place where five streets meet. Most players will see it shut, as a walled mass, until someone of theirs gets inside.

The slums, as a mesh

Slum ground is split differently from the rest of town: into a mesh of small blocks, each two rows of hovels back to back, with narrow lanes on every side. Every deep slum plot is a court of hovels round a yard. One whole small block in every two thousand households is left as a park.

The slums are where a cult hides best. A room in a slum court passes a congregation of fifteen without anyone counting, where an ordinary house passes eight, and the grand rite of rebirth can only be worked in a large city's slums.

The shambles and the market

The shambles, the butchers' yard, is a slaughterhouse, a range, and pens with beasts in them, as in Coldstead above. The market is set out from the shape of its square. The booths crowd its quiet side, the frontage farthest from where the streets come in, in rows back to back with aisles between, and a cart's way is kept along every street's line. The side by the market cross stays open, so the market reads as a crowd with a square in front of it.

A market square by a river: small booths in many colours packed in rows along one side of the square, the rest of it open, with the Guildhall, the chancery and the Cathedral Close round it.
The market at Vensmarch's bridge head. The booths crowd the square's quiet side and leave the rest open.

Beyond the gates

A town doesn't stop at its wall. Five percent of a walled town's households live outside it, along the roads. Past them the fields are laid in furlongs cut into long strips, the direction turning from one furlong to the next. A river keeps a meadow along its banks. Close to the town the ground is cut into hedged closes, long rather than square, and one close in every ten to twenty is an orchard. The fields are laid last, and they throw only the plan's own dice, so laying them cannot move a single plot inside the town.

The plan draws nothing from the game's dice at all. A layout is a function of its town, seeded by hashing it, so the same world always gives the same city, and nothing that happens in a campaign can move a street. Plans aren't saved with your game either. They are worked out again when needed and kept on disk, so a capital that took a minute to lay opens the second time in under a second.

A small open town seen from far out, a knot of streets by a wide bay, its names crowded together.
Haldstrand Hook, 394 households
A small town behind a bank and ditch seen from far out, a knot of houses in its fields.
Castelchester, 800 households
A walled capital seen from far out, a large irregular shape filling most of the view, with its palace and garrison at the south-west.
Venshead, a realm's seat
A walled port seen from far out, its bay cutting into the south side, its palace and garrison to the east.
Herrstrand, a port
Four towns of one world, all at the same zoom. A market town is a knot of houses in its fields, and a capital fills the view.

Drawing it

The city is drawn in the map's palette: a night-dark ground, blocks in a muted violet, and landmarks a step brighter, so the town's structure reads through its texture at every distance. Every town opens at the same scale, with a scale bar. A market town is a knot of houses in its fields, a capital runs off the window, and how much bigger one is than the other reads at a glance.

From afar the blocks are hatched, and main streets are drawn a little wider so the shape of the town shows. Closer in, roof ridges appear, then chimneys, buttresses and the sheds in the yards. The detail is worked out a slice at a time, a few milliseconds of every frame, so zooming never stalls. A mark on the city says who holds a place, never what trade it is. There is no little anvil for the forge. You learn the town by reading it. Towns are drawn flat: the ground's height shows in where the streets go and where the wall stands.

What comes next

The market squares are about to shrink, each scaled to its town, so that a capital's market is about a third of its present size with about fifty stalls. That work is built and being tested, but it isn't in the pictures above. Towns standing on hills, with terraces and streets that follow the slope, come after the rest of the city.

Next month: the character generator, and how the game makes the people who live in all these houses. Until then, the form below or the RSS feed will tell you when it is up.

Methods we read and learned from, never code: the long tradition of Voronoi town generators, which we tried first and set aside; the straight skeleton, for roofs worked out from a footprint; and the town plans of medieval England and Europe, where the street with two rows of plots behind it comes from.