Sector - adventures in procedural mapping

23 May 2017

Back in 1988 I was studying for my computer science A-level. At the time, this meant writing relatively simple apps in BBC Basic on the BBC model B computer. Things weren’t going so well, because we were quite distracted in class by a game someone had copied - Elite.1

Elite screenshot - Wikipedia

In Elite you played a space ship captain, flying between space stations in different star systems, trading to make a profit and fighting off pirates - all rendered in groundbreaking 3D line graphics. But what was really amazing to me wasn’t the graphics or the gameplay, it was the sheer amount of game that had been some how squeezed onto an 880KB floppy disk.

There were eight galaxies of 256 different worlds you could fly between. Each had descriptions and names, and active trading markets. You couldn’t fit that much content onto a disk that small. How did it do it? Was it using some kind of compression? No.

The secret to this magic of course was procedural generation. Instead of storing the details for every world, the game stored rules about how these details could be generated on the fly. When the game run, the galaxy was created in memory there and then. When you visited a star system, the worlds and stations, names and commodities were generated on the fly as you hyperspaced in. And although based on random generation, computers will, given the same started ‘seed’, generate exactly the same details every time.

The idea that entire, complex structures could be generated from a simple set of rules fascinated me. It turns out it wasn’t exactly a new idea. Another space game was already using this technique to generate entire galaxies of stars and worlds. This game, however, used dice and paper : Traveller.

Inside this collection of ‘little black books’ you could, with the help of nothing more than a sheet of paper a pencil and a couple of regular 6-sided dice, roll up vast ‘sectors’ of space and populate them with worlds and cultures of your own creation. The only drawback was the time it took - but I remember spending hours rolling up subsectors of worlds just for the fun of it.

The results were plotted onto a hexagonal grid map that ended up looking something like this:

traditional Traveller map

Several years ago I started playing around with a web app to generate sector maps automatically, using the rules encoded in the various editions of Traveller. The script I build in Ruby used ImageMagick to draw the maps, and running on a G5 Mac Pro took several minutes per subsector (a maximum of 80 worlds). Nevertheless, the images it produced were pretty attractive:

Ruby generator output

I embellished the standard maps with colour - using the colour of the world to indicate the surface type, and the border of it to indicate it’s atmosphere. I also added icons for various bases and travel codes (additional details you generate for a world, a kind of short hand saying if the place his rich or a desert or a garden world, etc).

Although the project languished after that, I still retained a fascination with procedural generation and mapping. Years later I decided to revisit this idea, and see what I could do with current technology.

Introducing Sector

Sector on the iPad

Sector is my Ruby Traveller mapping app brought up to date and build for iOS. It’s been completely re-written in Swift 3, and running on the latest devices it will generate an entire sector (that’s 16 subsectors of 80 hexes) in an instant.

In the years since I wrote the original Ruby code, Traveller has been published in an open source ‘System Reference Document’ - and this is the basis of the rules that Sector uses.

In addition to the basic mapping and colour coding, Sector also draws in ‘trade routes’ - lines of communication or commerce between the worlds. This gives more context to the map, and you can get some idea of the relationships between the worlds. It also generates names for everything - the worlds themselves, and also the clusters and voids that exist on the map are named. Names are created based on a dictionary of real English worlds as well as place names from around the world, so the generated worlds have names that at least sound familiar and pronounceable.

There are still things I’d like to add - printing out the map or sharing it as an image are top of the list. But, as it stands I’m very pleased with the result, and it was a fun project to work on - even if I never want to see a hexagon again!

You can download it on the App Store

  1. Elite is still going strong - and I’m still playing it! The latest version models the entire galaxy, including detailed world surfaces. You should check it out