Game Component: Radial Base Layout

In science fiction, space bases usually have some combination of circular and straight components to make it look “futuristic”. I wanted an algorithm to generate a layout for a space base or space station. Initially I had sketched out something that combined the circular and straight components in various ways but I decided to start with just the circular ones, because they’d look cooler.

The basic algorithm is:

  1. Generate locations for “nodes”. In the straight layout algorithm, the nodes would be along a cartesian x,y grid. In the circular layout algorithm, the nodes are along a radial r,φ grid.
  2. Choose which locations are “active”. At each active location we place a node object.
  3. Fill in edges to make sure all the node objects are connected. In the radial layout, there are arc edges (along the circular levels) and radial edges (from level to level).
    • Each node has a radial edge to the previous level.
    • Each node has an arc extending from it, of random length.
    • Some arc edges will be expanded to ensure that the radial edges to the next level are connected to something.

After sketching out the idea and algorithm on paper, I implemented it in Flash, then added a simple Flash MX UI to tweak the parameters:

(example radial space base layout)
(This is an example layout produced by the Flash demo)

For a busier layout, try decreasing the “radial spacing”, increasing the “levels”, increasing “node density”, and decreasing “node radius”. In general, try experimenting with “levels” and “node density”.


I’m a programmer and I’ve needed art for my games. I prefer to have procedural art (most of the graphics for Blob City[1] were procedurally generated). I look for small, simple code that can generate something decent looking. Having lots of variety is nice; that’s one of the advantages of procedural art. It’s even better if the art can match the game objects and the player’s actions. The space base demo’s layout and drawing code compiles to under 5k (probably under 3k in a real game, because you won’t need as much setup code and generality), but when you add the MX UI, it ends up being around 180k. (Ugh, I’d use MX more if it wasn’t so big!) It’s only a few hundred lines of Actionscript, and I’m sure much of that could be simplified for use in a real game.


Initially I was thinking this would be used in a 2D space battle game to generate random space stations. Your ship would have to destroy each of the energy nodes in order to destroy the station. However, it’s somewhat generic, and it could also be used for lunar factories on the surface of a moon, or for a security pad a door panel.

Some ideas of how to extend this:


The code is released under the MIT license, so you can use it for free and commercial games.


I’d love to hear what you think. Leave comments on my blog.[2]

Email me , or tweet @redblobgames, or comment: