Blog

Building “Infinite Dread” — How Our Procedural Horror Works

How The Keyhole generates rooms and uses player behavior to guide anomaly spawning.

game design · level design · procedural generation

How the maze finds a route

  1. Pick a neighbor

    Choose an unvisited cell next to the current one.

  2. Carve the route

    Remove walls between visited cells until the route reaches a dead end.

  3. Backtrack

    Return to a cell that still has an unvisited neighbor and continue from there.

Illustration of the recursive backtracking described in The Keyhole devlog.

Ever wondered how horror games keep you on edge every single playthrough?

Here's how we built it for The Keyhole 👇

The Cell Generator

Imagine a maze that never repeats.

Our system uses a recursive backtracking algorithm to carve paths through a grid:

  • Start at cell 0
  • Pick a random unvisited neighbor
  • Knock down the wall between them
  • Repeat until trapped, then backtrack

Result? Every run = unique layout. Same game, different nightmares.

Smart Anomaly Spawning

Here's where it gets creepy.

Our anomalies don't just spawn randomly. They watch you.

The system tracks:

  • 💡 Light levels (dark room? Perfect for shadows)
  • ⏱️ How long you've been idle (standing still too long?)
  • 🚶 Your movement patterns (running = panic = vulnerability)
  • 📍 Room type (corridor vs open space)

When conditions align, something spawns behind you.

Why This Matters?

Static scares work once. Dynamic scares work forever.

Players can't predict what's coming because the game literally adapts to how they play.

What systems do YOU think make horror games truly scary? 👇