Coding Ye Olde London
How clever code helped to build Blockworks’ historic London
Blockworks are a pretty handy buildcrew, there’s no doubt, capable of bashing together even the most ambitious commissions to order. But hand-crafting forty thousand medieval houses? That’s a task which would stretch pretty much any builders’ manpower.
This was the problem presented them by The Great Fire of London map, which the team was asked to put together for the Museum of London earlier this year. Astonishingly, a huge amount that map was indeed handcrafted - but much of the city lying outside the City’s old Roman walls, beyond the main game area, needed a quicker fix. The solution? Create code to do the heavy-lifting instead!
“Clicking blocks is a luxury. As an adult, sometimes you’ve just got to get on with your work, so the only way to do it is to write a program.”
Or, more specifically, bring on Aussie coding wizard Adrian Brightmoore to deploy a technique called procedural generation. You may have heard of it - it’s the way Minecraft’s worlds are generated, along with most of the structures in them. They aren’t randomly splashed across the map: the code places them in line with rules it’s been given. You can do it with individual buildings, too, instructing the code in the sorts of basic rules that buildings normally follow and letting it fill in the gaps.
Adrian’s got a long list of Minecraft projects that are worth exploring, many of which use procedural generation - a fascination that grew out of trying to efficiently apply a very limited amount of free time to the hobby.
“Sitting for a week clicking blocks is a luxury,” he says, “As a grown adult, sometimes you’ve just got to get on with your work, so the only way to do it is to write a program and let it run for however long in the background.”
His first experiment in this area was the recreation of a Jawa Sandcrawler from Star Wars. At first glance, you wouldn’t think it’d be that hard to recreate in Minecraft: it’s a big boxy structure after all, and Minecraft is typically good at big boxes. But the way the sides angle and taper - like a trapezoid that’s been pinched in the middle - makes it surprisingly tricky.
“I had to write a program to draw the funky surfaces of those triangles on the front, because I just could not work this thing out!” says Adrian. “Then I got hooked. Once you write a program to solve a problem, you start looking for other problems to solve. There are so many different things where I’ve said, ‘Gee, I wonder if I can do this?’ And I’ve found that - you know what? - I can! And it’s actually quite easy.”
“I got hooked. Once you write a program to solve a problem, you start looking for other problems to solve.”
With a project like the Great Fire, Adrian first looked at the examples of buildings he was required to make and “deconstructing” them: working out what essential elements need to be slotted together to make something qualify as a building:
“Rooms are made of walls, floor and ceiling,” Adrian lists. “It has to have some sort of support to look vaguely realistic; it’s got to have doors and windows – houses tend to want those luxuries.”
Procedural generation experts often refer to this sort of construction ruleset as a grammar - just like language has a grammar which tell us how words need fit together in a sentence for us to be able to understand the meaning. But qualifying as a building wasn’t enough. While technically 1666 was no longer the medieval period, the City of London was still, in terms of the streetplan and structures, largely a medieval city, with a very identifiable (and, it turned out, flammable) style of architecture.
“In Old London, they used to build the second and third stories overhanging the street - that’s how you got more space in your house. A few other key things popped out; the first was the wood panelling - different styles of wood with braces. And the roofs are these really interesting, almost haphazard, slate roofs and thatched roofs.”
With these rules established, Adrian was able to write code which would generate each element in order.
“To begin with, I’d just do really broad brush strokes,” says Adrian. “A room is just a cubey thing, right? Let’s build some rooms, stack the rooms on top of each other, and then let’s get the roof right. Then I’d worry about the fact that the walls actually have to have panelling. And I’d incrementally add bits and pieces until it looked good enough. But the basic grammar was: Walls, Floors, Ceilings, Roof, Chimneys, Windows, Doors and Stairs.”
“To begin with, I’d just do really broad brush strokes. A room is just a cubey thing, right? Let’s build rooms, then stack them.”
Stairs proved particularly difficult to deal with: “Stairs are really hard with Minecraft because they go in different directions. You can’t get the metadata out of the game to write code that is clean. You’ve got to end up using all these ‘IF THEN ELSE’ statements.”
Adrian doesn't believe the results come up to the standard set by Blockworks in the city centre, but produced structures which were more than convincing enough for the outlying regions of the map, never to be explored by players up close.
The final challenge was positioning the buildings: London, unlike many modern cities, sprawled out organically. There is no grid of roads to fit buildings alongside at neat right-angles, as convenient as that would be to build in Minecraft. London is a higgledy-piggledy place. To get this looking right, Adrian copied some of buildings by the Blockworks team and pasted them against the snaking roadways using code which off-set each block-wide slice of the building to align with the edge of the plot. This created a convincing facade for his procedural generation and allowed him to produce buildings at “weird angles” without completely mangling their architecture. You can read more about this technique in this imgur gallery Adrian kindly put together.
None of this is to say that Adrian just pressed a button and the map popped out: developing these techniques is challenging in itself, and, even then, Blockworks’ builders still sculpted a vast amount of the city by hand. It’s an incredible feat - but one that would have been even more formidable without a canny use of code.
If you’re interested in finding out more about the power of procedural generation, Adrian has a lot of other experiments available to view either on his site or his YouTube channel, where he provides really clear commentary of everything he’s doing. (I particularly enjoyed his efforts to procedurally generate an Armada!) You can also tootle about Old London yourself via the links on the Museum of London’s site.
Bloc bloc bloc ...