Automated Procedural Maze Builder

Watch four glowing builder drones automatically generate a stone brick dungeon maze on a four-block grid using pure vanilla Minecraft commands.

Java EditionComplex Contraptions & CinematicsHard24 commandsTested on a real 26.2 & 26.3 server
Glowing cyan drones construct a procedural stone brick maze around a golden core in Minecraft. Download the GIF Video & GIF © www.9minecraft.net

Self-building StructuresMedievalTechnologyCyanGoldBlackBuilding ToolMini-gameAdventure MapBlock displaysSmooth animation (interpolation)Summoned mobsBlock building (fill/setblock/clone)21+ commands

Watch an intricate dungeon labyrinth construct itself before your eyes. Starting from a central golden core, four glowing cyan drones branch outward across a polished deepslate arena, building walls and carving out rooms and corridors on a four-block grid.

Each builder drone checks adjacent cells using block detection, building new stone brick enclosures into unvisited territory and backtracking through finished halls when it hits a dead end.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /scoreboard players set #tick c9_t 0
  3. /fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 minecraft:polished_deepslate
  4. /fill ~-16 ~ ~-16 ~16 ~5 ~16 minecraft:air
  5. /fill ~-2 ~ ~-2 ~2 ~2 ~2 minecraft:stone_bricks hollow
  6. /fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 minecraft:gold_block
  7. /summon minecraft:block_display ~ ~2 ~ {Tags:["c9_b"],Glowing:1b,glow_color_override:65535,teleport_duration:3,block_state:{Name:"minecraft:sea_lantern"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.9f,0.9f,0.9f],translation:[-0.45f,-0.45f,-0.45f]}}
  8. /summon minecraft:block_display ~ ~2 ~ {Tags:["c9_b"],Glowing:1b,glow_color_override:16753920,teleport_duration:3,block_state:{Name:"minecraft:shroomlight"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,0.8f,0.8f],translation:[-0.4f,-0.4f,-0.4f]}}
  9. /summon minecraft:block_display ~ ~2 ~ {Tags:["c9_b"],Glowing:1b,glow_color_override:65535,teleport_duration:3,block_state:{Name:"minecraft:beacon"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,0.8f,0.8f],translation:[-0.4f,-0.4f,-0.4f]}}
  10. /summon minecraft:block_display ~ ~2 ~ {Tags:["c9_b"],Glowing:1b,glow_color_override:16753920,teleport_duration:3,block_state:{Name:"minecraft:ochre_froglight"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,0.8f,0.8f],translation:[-0.4f,-0.4f,-0.4f]}}

2. Loop - one repeating command block each (Always Active) 14 commands

  1. /scoreboard players add #tick c9_t 1
  2. /execute as @e[tag=c9_b] at @s run particle minecraft:dust{color:[0.1,0.95,1.0],scale:1.6} ~ ~0.4 ~ 0.3 0.3 0.3 0 4 force
  3. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b] store result score @s c9_t run random value 0..3
  4. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=0}] at @s if block ~4 ~-3 ~ minecraft:polished_deepslate run fill ~1 ~-2 ~-1 ~3 ~ ~1 minecraft:air
  5. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=0}] at @s unless block ~4 ~-3 ~ minecraft:grass_block if block ~4 ~-3 ~ minecraft:polished_deepslate run tp @s ~4 ~ ~
  6. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=1}] at @s if block ~-4 ~-3 ~ minecraft:polished_deepslate run fill ~-3 ~-2 ~-1 ~-1 ~ ~1 minecraft:air
  7. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=1}] at @s unless block ~-4 ~-3 ~ minecraft:grass_block if block ~-4 ~-3 ~ minecraft:polished_deepslate run tp @s ~-4 ~ ~
  8. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=2}] at @s if block ~ ~-3 ~4 minecraft:polished_deepslate run fill ~-1 ~-2 ~1 ~1 ~ ~3 minecraft:air
  9. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=2}] at @s unless block ~ ~-3 ~4 minecraft:grass_block if block ~ ~-3 ~4 minecraft:polished_deepslate run tp @s ~ ~ ~4
  10. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=3}] at @s if block ~ ~-3 ~-4 minecraft:polished_deepslate run fill ~-1 ~-2 ~-3 ~1 ~ ~-1 minecraft:air
  11. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b,scores={c9_t=3}] at @s unless block ~ ~-3 ~-4 minecraft:grass_block if block ~ ~-3 ~-4 minecraft:polished_deepslate run tp @s ~ ~ ~-4
  12. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b] at @s if block ~ ~-3 ~ minecraft:polished_deepslate run fill ~-2 ~-2 ~-2 ~2 ~ ~2 minecraft:stone_bricks replace minecraft:air
  13. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b] at @s if block ~ ~-3 ~ minecraft:polished_deepslate run fill ~-1 ~-3 ~-1 ~1 ~-1 ~1 minecraft:deepslate_tiles
  14. /execute if score #tick c9_t matches 3.. as @e[tag=c9_b] at @s if block ~ ~-3 ~ minecraft:deepslate_tiles if block ~2 ~-2 ~ minecraft:air if score @s c9_t matches 0 run tp @s ~4 ~ ~

How it works

Frames from the test run

Automated Procedural Maze Builder - frame 1Automated Procedural Maze Builder - frame 2Automated Procedural Maze Builder - frame 3

Recorded on our own test server: 70 frames at about 9.9 fps. Our image check saw: An aerial view of a large stone brick labyrinth with a golden center being built on a deepslate grid by glowing cyan marker entities.

Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.

Build it in your world

  1. Find a flat area and stand where you want the center of the 33x33 maze arena to be.
  2. Run each of the 10 setup commands in order to lay the deepslate canvas, build the starting golden chamber, and summon the 4 builder drones.
  3. Place a repeating command block set to Always Active for the first loop command, and chain 13 chain command blocks (Always Active, Unconditional) after it for the rest of the loop commands.
  4. Note that in the last loop command, you can reset #tick to 0 or let it run continuously above 3 ticks for fast 20-step-per-second generation.
  5. Watch From above as the glowing drones branch out, carving rooms and hallways until the entire grid is explored.

Use it with real players

To let a player guide or spawn new maze branches manually, give yourself a spawn item or run /execute at @p align xyz run summon minecraft:block_display ~0.5 ~2 ~0.5 {Tags:["c9_b"],Glowing:1b,teleport_duration:3,block_state:{Name:"minecraft:sea_lantern"}} while standing on the center of any unvisited 4-block grid cell.

Remove it again 4 commands

  1. /kill @e[tag=c9_b]
  2. /scoreboard objectives remove c9_t
  3. /fill ~-16 ~ ~-16 ~16 ~5 ~16 minecraft:air
  4. /fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 minecraft:grass_block

FAQ

How do the drones know which cells have already been built?

Unvisited cells have a Polished Deepslate floor. When a drone enters a cell, it replaces the 3x3 center floor with Deepslate Tiles, so future checks see that the cell is already visited.

Can I make the maze larger than 33x33 blocks?

Yes! Increase the size of the initial Polished Deepslate floor fill command in the setup using any multiple of 4 (such as ~-24 to ~24), and the drones will automatically expand to the edges of the floor.

Commands used

/execute/fill/particle/random/scoreboard/summon/tp

Similar creations

Join 9Minecraft News & Guides