Member-only story
Building a Better Dungeon Level
How I updated an algorithm to better match the graphics

For the past seven months, I’ve been building a dungeon game in JavaScript and HTML5 Canvas. The game resembles what is known as a Roguelike, as rather than build the levels myself, I use an algorithm — a sequence of instructions that I translate into code.
Different algorithms produce different types of dungeons. For instance, when I implemented an algorithm called random walk, it produces a dungeon like the one below.

As the name suggests, a “digger” stumbles randomly from the center outward and digs through the solid rock to create tunnels. It then returns to the center and keeps going until a certain amount of space is created.
After implementing random walk, I wrote some logic that drops rooms at random places on the map and then connects them with narrow corridors. While I also wrote this in JavaScript for the same game, it was based on a different algorithm.