Skip to content
all posts

Tutorials, Personal · December 2023

Going Bare Metal: What Stellar Cartography Taught Me

Terminal showing an ASCII sector map

The Setup

At the end of my computer architecture course in fall 2023, the final assignment arrived dressed up as a space mining competition called Stellar Cartography. The story: we are rock miners boldly going where no rock miner has gone before, and there is map data that needs mapping. The reality: fetch map specs from a central server, process them on a Raspberry Pi Pico in C, and upload the finished maps back. Only maps that were both uploaded and correct earned the vaunted rock dollars.

What Bare Metal Even Means

Bare metal means your program runs directly on the microcontroller with no operating system underneath it. There is no OS handing you memory, scheduling your work, or catching you when you misstep. Your C code and the hardware are the whole story. It is the closest I have come to feeling exactly what my code asks a machine to do.

The Game Itself

Every map was defined by three numbers: a sector height, a sector width, and a topology score, which is the percent chance that any given cell holds a feature. From that you generate a base map with a few fixed rules, then smooth it into believable terrain.

  • All outer edges are always features, drawn as hash marks
  • The very middle of the map is never a feature
  • Every other cell has a chance of being a feature equal to the topology score
  • Then three adjacency rules resolve the noise: a feature surrounded by at least four features stays, a feature with fewer than two neighbors becomes ground, and any cell with five or more features in a one-block radius becomes a feature

Those three rules look almost interchangeable when you first read them, and they are absolutely not. Getting them right meant reading the spec the way you read a contract.

What Was Hard

In C on a Pico, the data structures are yours to manage. The suggested approach was a struct pointer to hold the map measurements and a 2D array for the generated map, and the course nudged us to store tiles as numbers rather than characters: 0 for natural ground, 1 for a topological feature. The stated reason stuck with me. New symbols might be added later, and picking an index from an array is easier than juggling absolute characters. Representation is a design decision, not an afterthought.

The adjacency rules were the other teacher. Checking a one-block radius means looking at up to eight neighbors for every cell, and the edges of a 2D array do not forgive sloppy bounds. A grid problem that would be a casual afternoon in Python becomes very honest work in C.

What It Taught Me

The competition structure was clever: everyone had to decode at least one map successfully, so the floor was understanding, but the ceiling was speed, volume, and even style points for flashy extras like extremely minified source code. That framing turned optimization from a chore into a game, because there are a lot of tricks you can use to make your mapping process faster than anyone else's.

Mostly, bare metal demystified the machine for me. When there is nothing between your C and the silicon, you stop treating the computer like a magic box and start treating it like a very fast, very literal coworker. I recommend the experience to anyone who writes software far above the hardware, which these days is most of us.