Watch a glowing runic core carve out a 31x31 labyrinth in seconds as towering stone brick walls erupt from the floor with cyan sparks and debris.
Self-building StructuresMedievalMysticTechnologyCyanWhiteBuilding ToolMini-gameLearningItem displaysBlock building (fill/setblock/clone)Rotation math21+ commands
The Colossal Algorithmic Maze Builder uses a live depth-first search algorithm with backtracking right inside command blocks to generate a unique 31x31 stone brick labyrinth every time it runs. Starting from a glowing central monolith, an enchanted sea lantern cursor dashes across a dark deepslate grid, carving corridors while massive 5-block-tall walls and chiseled pillars erupt around it.
Each newly carved passage bursts with soul fire flames, cyan dust, and block debris. When the cursor hits a dead end, it automatically retraces its steps along invisible bread-crumb markers until it finds a fresh direction to excavate, completing a playable maze in seconds.
/scoreboard objectives add c9_id dummy/fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 deepslate_tiles/fill ~-16 ~ ~-16 ~16 ~5 ~16 air/fill ~-15 ~ ~-15 ~15 ~4 ~15 stone_bricks/fill ~-1 ~ ~-1 ~1 ~4 ~1 air/setblock ~ ~-1 ~ sea_lantern/summon item_display ~ ~1.5 ~ {Tags:["c9_cursor","c9_ent"],Glowing:1b,glow_color_override:65535,item:{id:"minecraft:sea_lantern"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1.4f,2.8f,1.4f]}}/summon marker ~ ~ ~ {Tags:["c9_node","c9_ent"]}/scoreboard players add #tick c9_id 1/execute as @e[tag=c9_cursor] at @s run particle soul_fire_flame ~ ~0.5 ~ 0.4 0.8 0.4 0.05 12 force/execute as @e[tag=c9_cursor] at @s run summon area_effect_cloud ~ ~ ~ {Duration:2,Tags:["c9_ scanner","c9_ent"]}/execute at @e[tag=c9_cursor] positioned ~4 ~ ~ if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}/execute at @e[tag=c9_cursor] positioned ~-4 ~ ~ if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}/execute at @e[tag=c9_cursor] positioned ~ ~ ~4 if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}/execute at @e[tag=c9_cursor] positioned ~ ~ ~-4 if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}/execute as @e[tag=c9_cand,sort=random,limit=1] at @s run tag @s add c9_pick/execute at @e[tag=c9_pick] run execute as @e[tag=c9_cursor] at @s facing entity @e[tag=c9_pick,limit=1] feet positioned ^ ^ ^2 run fill ~-1 ~ ~-1 ~1 ~4 ~1 air/execute at @e[tag=c9_pick] run fill ~-1 ~ ~-1 ~1 ~4 ~1 air/execute at @e[tag=c9_pick] run particle block{block_state:{Name:"minecraft:stone_bricks"}} ~ ~2 ~ 1 1.5 1 0.3 60 force/execute at @e[tag=c9_pick] run summon marker ~ ~ ~ {Tags:["c9_node","c9_ent"]}/execute at @e[tag=c9_cursor] unless entity @e[tag=c9_pick] run kill @e[tag=c9_node,distance=..0.5]/execute as @e[tag=c9_cursor] at @s run tp @s @e[tag=c9_ent,tag=!c9_cursor,tag=!c9_cand,sort=nearest,limit=1]setup #4 Fills the entire 31x31x5 arena with solid <code>stone_bricks</code> so the cursor can carve corridors directly out of the stone mass while leaving solid walls behind.setup #7 Summons the glowing cyan <code>item_display</code> cursor at the center of the maze, which acts as the excavating head for the depth-first search algorithm.loop #4 Together with the next three commands, checks 4 blocks away in all four cardinal directions. Any unvisited cell still filled with <code>stone_bricks</code> gets a temporary <code>c9_cand</code> candidate marker.loop #8 Uses <code>sort=random,limit=1</code> to pick one random valid neighbor from the candidates, driving the unpredictable branching of the labyrinth.loop #9 Faces the chosen target cell from the cursor's current spot and clears a 3x5x3 tunnel halfway between them at <code>^ ^ ^2</code>, knocking down the dividing wall.loop #12 Drops a <code>c9_node</code> breadcrumb marker at the newly carved cell and kills any leftover candidate markers when the cursor moves or backtracks.


Recorded on our own test server: 57 frames at about 9.4 fps. Our image check saw: A large stone brick block structure sits by the water with a glowing cyan pillar in the center that has begun carving out several deep pits with breaking block particles.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
To let a player trigger a fresh maze with a magic wand instead of starting automatically, run the setup commands inside a chain triggered when holding a blaze_rod[custom_name='{"text":"Maze Architect","color":"aqua"}']. You can also teleport the player to ~ ~ ~ once all c9_node markers are gone so they are immediately dropped into the center of the newly generated labyrinth.
/kill @e[tag=c9_ent]/scoreboard objectives remove c9_id/fill ~-16 ~ ~-16 ~16 ~5 ~16 air/fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 grass_blockYes. Because the target direction is selected using Minecraft's @e[tag=c9_cand,sort=random,limit=1] selector every tick, it executes a true randomized depth-first search with no two mazes alike.
Simply re-run the last five Setup commands to refill the stone bricks and spawn a new cursor and starting node at the center.
/execute/fill/kill/particle/scoreboard/setblock/summon/tag/tp
▶Automated Spire ConstructorSelf-building StructuresMedium19 cmds
▶Autonomous Dungeon ArchitectSelf-building StructuresExpert24 cmds
▶Automated Procedural Maze BuilderSelf-building StructuresHard24 cmds
▶Da Vinci Flying Machine AssemblySelf-building StructuresHard24 cmds
▶High-Speed Multi-Shape Maze GeneratorSelf-building StructuresHard24 cmds
▶Instant Village GeneratorSelf-building StructuresHard24 cmds