How Computers Draw Maps
Fantasy kingdoms, sprawling cities, whole coastlines. A computer can invent them all from a handful of dots.
Fantasy kingdoms, sprawling cities, whole coastlines. A computer can invent them all from a handful of dots.
A map generator does not begin with mountains or cities. It begins with random dots scattered across an empty space. Press scatter a few times. Each dot is a seed the whole world will grow from.
Random dots give the map its irregular, natural feel. If the seeds were on a perfect grid, every kingdom would be a boring square. Randomness is what makes it look hand-drawn.
Here is the magic. Color every point on the map by whichever dot is closest to it. Suddenly the blank space breaks into organic regions, like provinces or biomes. Click the map to drop a new dot and watch the regions rearrange.
These nearest-point regions are named after mathematician Georgy Voronoy. The Fantasy Map Generator builds its entire world on them: every province, forest, and county is a Voronoi cell.
Give every region a height, then raise the sea. Regions below the waterline turn to ocean; the rest stay land. A ragged, believable coastline appears, and nobody drew a single line of it. Slide the sea up and down.
Because regions are irregular Voronoi cells, the coastline is jagged and natural, full of bays and peninsulas. A simple grid would give you ugly staircase coasts.
Last, bring it to life with rules. Cities like to sit on land near the water, so drop towns there. Then link each city to its nearest neighbor with a road. Build it up step by step.
The City Map Generator uses a related idea for streets: it grows roads along invisible flow lines, then fills the blocks with buildings, the same way real cities sprawl outward from a center.
You watched a map build itself: dots became regions, regions split into land and sea, and cities linked up by roads. This is procedural map generation, the trick behind endless fantasy worlds and city maps. Now go generate your own.
Scatter random points across a blank space. Those seeds are the skeleton of the whole map.
Give every spot to its closest dot and organic regions appear. This is a Voronoi diagram, the backbone of fantasy maps.
Give each region a height and flood the low ones. A coastline emerges without anyone drawing it.
Place towns where the rules say (on land, near water), then connect the nearest ones with roads. A living map.
Put your new knowledge into practice!