Procedural Backrooms Level 0 Generator

Hello fellow developers!

I’m sharing a procedural generation system I’ve developed that creates the infamous Backrooms Level 0 environment in Roblox.

Sample:


Technical Overview

This system generates an expansive maze of interconnected rooms with:

  • Procedurally generated layout ensuring full accessibility
  • Alternating light pattern (checkerboard style) for authentic atmosphere
  • Dynamic light flickering with multiple patterns
  • Player safety systems preventing void-falling during generation

Implementation Details

The generator uses a modified maze algorithm that:

  • Creates a base grid structure (configurable, default 50x50)
  • Carves pathways while maintaining wall integrity
  • Adds additional connections to prevent dead-ends
  • Verifies total accessibility with path correction

For optimization, I implemented:

  • Batch generation to prevent server strain
  • Smart wall creation (shared walls exist only once)
  • Temporary holding area for players while generation completes
3 Likes

Looks very cool
I actually wonder how it works to create walls and check if path is accessible, would you share what you used as example of creating this (Not your actual code)

Thanks for the interest! :cowboy_hat_face:

Honestly, the Backrooms generation system isn’t that complicated. Let me explain it quickly:

For the walls and maze, I use a version of the “Growing Tree” algorithm that goes like this:

Example
-- Simplified example of how I generate the paths
function generateMaze(map, width, height)
    -- Start with all walls up
    for y = 1, height do
        for x = 1, width do
            map[y][x] = {north=true, east=true, south=true, west=true, visited=false}
        end
    end
    
    -- Choose random initial cell
    local x, y = math.random(width), math.random(height)
    map[y][x].visited = true
    
    -- Frontier of cells to visit
    local frontier = {}
    addNeighbors(map, x, y, frontier, width, height)
    
    -- While there are cells in the frontier
    while #frontier > 0 do
        -- Choose a random one and knock down the connecting wall
        local idx = math.random(#frontier)
        local cell = frontier[idx]
        table.remove(frontier, idx)
        
        if not map[cell.y][cell.x].visited then
            connectCells(map, cell.x, cell.y)
            map[cell.y][cell.x].visited = true
            addNeighbors(map, cell.x, cell.y, frontier, width, height)
        end
    end
end

-- Then I verify accessibility with a BFS
function verifyAccessibility(map, startX, startY)
    -- Reset accessibility
    for y = 1, #map do
        for x = 1, #map[1] do
            map[y][x].accessible = false
        end
    end
    
    -- BFS from starting point
    local queue = {{x=startX, y=startY}}
    map[startY][startX].accessible = true
    
    while #queue > 0 do
        local current = table.remove(queue, 1)
        local x, y = current.x, current.y
        
        -- Check connected neighbors and mark them
        if not map[y][x].north and y > 1 then
            if not map[y-1][x].accessible then
                map[y-1][x].accessible = true
                table.insert(queue, {x=x, y=y-1})
            end
        end
        -- And so on with the other 3 directions...
    end
end

I kept it super short, but the idea is:

  1. You start with walls everywhere :brick:
  2. You strategically knock down walls to create paths :motorway:
  3. Then you verify that everything connects with a BFS so nobody gets trapped :mag:

The trickiest part is optimizing how to physically build thousands of parts in Roblox without crashing the server, but that’s a whole other challenge!

1 Like

This procedural generation system is great! It’s good for these types of games! How long did it take to make this? Will this be used in a game?

1 Like

Thanks man! Took me about two weeks - had to rebuild it once when the FPS tanked :sweat_smile: It’s for a Backrooms horror game I’m working on. The procedural generation was my priority and those endless yellow rooms are finally coming together nicely!

Appreciate the kind words! Working on anything cool yourself?