All Over the Map

See Maps of Fantasy Worlds Created by Bots

A fantasy-novel-inspired Twitter bot generates a new map of fictional lands every hour.

View Images

This map of a fantasy world was made by the automated map generator @unchartedatlas on Twitter. The striking fjords are reminiscent of Norway.

As you travel northeast along the shore of southern Nimrathutkam, the first town you’ll encounter is Ak Tuh, followed by Nunrat and Nrik Mah before you reach the coastal city of Tuhuk, the largest urban area in the region of Mum Huttak.

If these sound like places out of a fantasy novel you read as a teenager, you’re not far off. Nimrathutkan is the result of an automated map generator that was inspired by those novels. The map bot, created by glaciologist Martin O’Leary of Swansea University in Wales, combines imaginary place names with fake terrain to produce fantasy worlds, tweeting a new one every hour from the Twitter account @unchartedatlas.

O’Leary came up with the idea in November when he participated in NaNoGenMo, or National Novel Generating Month. It’s a twist on National Novel Writing Month, which since 1999 has challenged writers to complete a 50,000-word novel in the month of November. Instead of writing words, NaNoGenMo participants write code that generates a 50,000-word “novel.”

“You're trying to make a computer write a novel, so you're looking for the most formulaic novel you can think of. And so I was thinking about these fantasy novels, and they always had these maps inside the cover,” O’Leary says, “So I started thinking, well could I make one of those maps?”

Illustration of a map made by an automated map generator
View Images

O’Leary likes how the island names on this map are coherent: Mon-Shuumsam and Din-Shuumsam. Perhaps “mon” and “din” mean big and small or south and north in their imaginary language.

Most automated terrain generators used to create virtual worlds are based on a technique called fractal noise, a standard 3D graphics approach that’s been around since the 60s, O’Leary says. This method starts with some smooth bumps on the landscape and then adds more bumps at smaller and smaller scales. The result is something that has the same sort of texture as a real landscape. But this process has some major limitations.

“It works well on the small scale, and if you’re not paying attention,” O’Leary says. “If you look at it as someone who understands where valleys come from, it doesn’t make any sense. Valleys just start and disappear, and you have no sense of how the landscape connects to itself.”

O’Leary wanted to make something more realistic. By day, he studies the effect of meltwater that collects on the Larsen C Ice Shelf in Antarctica. And as a glaciologist, he is very familiar with how landscapes form and evolve, so he started adding some real-world physics into his code.

Here’s how it works. The generator starts off by sketching out a rough outline of a terrain. In the real world, landscapes evolve from previous landscapes, which in turn evolved from previous landscapes, and so on. But it’s really difficult to write code to make something out of nothing, so O’Leary’s code first produces a scattering of random points (as shown on the left below), and then uses a standard algorithm to keep them from being too clumpy (right).

View Images

Next, the bot turns the points into a grid, adds some random blobs, generates a random slope, and maybe adds a shoreline, as shown in the images below. (The yellow areas are higher, purple is the lowest, and the black line represents the coastline.)

View Images

Then comes the rain. Most landscapes in nature have been eroded, and flowing water plays the biggest role in this. Water flows downhill, so for each point on the grid, rain will flow to a lower point, and the water will erode the landscape. Repeating this simulation multiple times makes for a more deeply eroded terrain.

After one erosion phase (below left) the terrain starts to show some drainage channels, and after three erosion phases, two of the blobs have turned into islands as the coastline is eroded away.

View Images

At this point, O’Leary’s code tweaks things a bit further and turns the terrain into a map with rivers and hillside shading in a hand-drawn style. Voila, a plausible landscape for a fantasy world.

View Images

All the map needs now is some places and political boundaries. The code uses some rules to decide the best spots for cities (below left), such as proximity to flowing water and distance from other cities. After each city is added, the algorithm recalculates where the best spots for cities are, so that you get a reasonable looking distribution. Regional borders, shown as dotted lines (below right), extend outward from cities and take into account the topography by stopping at ridges and avoiding crossing rivers.

View Images

The label placement, as cartographers will tell you, can be one of the trickiest parts about making a map. O’Leary’s code uses a hierarchy of importance, and attempts to place names in a way that will avoid overlap and confusion. As he describes it in a post on the process, “I have a few hundred lines of spaghetti code which seems to get the right answer most of the time, but which is packed full of magic numbers.”

O’Leary also built the place name generator, which is meant to label maps with words that seem like they’re from the same language. The map above has towns that sound like they could have come from the same region: Lommen, Kemen, Menenkum, Mennum and Imemim. But not everybody likes this style.

“The place names are very polarizing,” O’Leary says. “Some people love them and some people absolutely hate them. I think some people want a more traditional Dungeons & Dragons style, Dark Cove or whatever. Old English style.”

You can try building your own fantasy map using O’Leary’s code on his website. Because the map generator was part of O’Leary’s NaNoGenMo project, the deadline at the end of November forced him to leave a few things out. But, the code is available for anyone who’d like to add some more terrain rules—perhaps introducing variation in the underlying geology or the possibility of lakes, forests and fields. At the top of O’Leary’s wish list: “I really wanted to get some volcanism in there,” he says. “I wanted to produce volcanoes and craters and lava flows and things.”

Coders have already begun adding their own styling details, such as those below by Scott Turner.

View Images

And O’Leary added his own twist by using the same code, except with emoji for the final rendering of the map, so that instead of topography, rivers and hillshading, you get emoji for mountains, trees and water (below). There’s even a dedicated Twitter account for these maps.

Next on O’Leary’s mapbot agenda? Cities. But, this could be an even bigger challenge than the fantasy map generator. “Landscapes I feel pretty comfortable with, architecture I’m less at home,” he says.

View Images

Comment on This Story