Visualizations
364 / 500

364 · Retro

Roguelike Explorer

An amber-terminal dungeon crawl that explores itself, cat in tow, by rolling down a Dijkstra map.

Each floor is cut by binary space partitioning: the map splits recursively, every leaf gets a plain, pillared, round or cross-shaped room, sibling subtrees are joined by corridors, and a few extra links add loops. Sight is recursive shadowcasting, which scans eight octants row by row and narrows the visible slope window behind every wall, so light pools in rooms and spills down corridors. The explorer runs on a Dijkstra map: every known item and every remembered floor tile that borders the unknown is a goal, a multi-source bucket-queue pass floods distances outward, and each turn it just steps downhill, then heads for the stairs once nothing is left. The ripples rolling across remembered floor are that distance field flowing toward its next goal, drawn on a phosphor screen with bloom, scanlines and a curved tube.

Try it. Take over any time with the arrow keys, WASD or hjkl (yubn for diagonals); after a few idle seconds the autoexplore resumes. Click or tap a remembered tile to travel there. Press M to see the Dijkstra map as numbers, > on the stairs to descend, and R for a new dungeon.

  • BSP dungeon generation
  • Recursive shadowcasting
  • Dijkstra maps
  • Glyph atlas rendering
  • CRT bloom and barrel distortion

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a tiny roguelike that explores itself, with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window and stays sharp on high-DPI screens (scale by devicePixelRatio). Use a grid of square tiles about 16 pixels wide and draw each tile as a monospace character: # for walls, a centered dot for floor, @ for the player.
- Generate the dungeon with binary space partitioning: split the map rectangle in two at a random position, recurse until the pieces are small, carve a room inside each leaf, then join the two halves of every split with an L-shaped corridor. Turn any rock touching a floor tile into wall.
- Keep a "known" flag per tile. Each turn, reveal the tiles within 8 steps of the player using recursive shadowcasting (scan the eight octants row by row and narrow the visible slope range behind walls).
- Autoexplore with a Dijkstra map: mark every known floor tile that touches an unknown tile as a goal with distance 0, flood distances outward with a breadth-first search over known floor, and step to the neighbor with the smallest distance. Take about ten turns per second.

Once that works, make it beautiful:
- Go amber monochrome: draw visible tiles bright, remembered tiles dim, unknown tiles black.
- Pre-render every glyph at several brightness levels into an offscreen atlas canvas and draw tiles with drawImage, so a full screen redraw is cheap.
- Add scanlines and a soft glow by drawing a quarter-size copy of the frame back on top with "lighter" blending.
- Let the arrow keys take over, and hand control back to the explorer after a few idle seconds.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as treasure that the Dijkstra map weighs above unexplored space, doors that block sight until opened, or a key that shows the distance field as numbers.
PreviousTransit HunterPlanets dim a spotted star; a box-least-squares search and RV fit find them. NextSiteswap JugglerJuggling notation made physical: true parabolas, a ladder diagram and the state graph.

Related visualizations

  • RaycasterRetro A Wolfenstein-style 3D maze drawn one column at a time.
  • Route PlannerAlgorithms Dijkstra, A*, bidirectional search and contraction hierarchies race on a printed atlas.
  • Gyroid Caves3D Fly through glassy minimal surface labyrinths, with a second maze behind every wall.
  • Impossible Rooms3D A house that cannot exist: a ballroom in a wardrobe, a corridor longer inside than out.
  • Marble LabyrinthGames A wooden tilt maze where a careful AI steers a steel ball between the holes.
  • CRT MonitorRetro An emulated electron beam, decaying phosphors and a shadow mask, under a 7x loupe.
  • Sector EngineRetro A 2.5D portal engine in the mid-90s style: a slow walk round a castle at golden hour.
  • Impossible ArchitectureIllusions Walkers climb Penrose stairs forever on a pastel tower whose paths only meet on screen.
  • Wobbly PolygonsRetro A 1990s console renderer that builds every famous glitch on purpose, toggle by toggle.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs