Watch a glowing soul-fire cursor carve a randomized labyrinth out of a solid deepslate monolith right before your eyes using depth-first search.
Self-building StructuresMysticDarkTechnologyCyanBlackBuilding ToolMini-gameLearningArmor standsBlock building (fill/setblock/clone)Rotation math21+ commands
The Self-Carving Labyrinth Generator creates a working maze from scratch right before your eyes. First, a massive 23x23 monolith of deepslate bricks and glowing sea lantern trim rises from a dark prismarine foundation. Then, an automated glowing soul-fire cursor spawns at the center and begins carving out connected corridors.
It uses a physical randomized depth-first search algorithm with marker entities: the cursor probes four directions, tunnels through the wall toward an unvisited cell, lays a sea lantern trail, and backtracks along its path whenever it hits a dead end until the entire labyrinth is hollow.
/scoreboard objectives add c9_t dummy/fill ~-12 ~-1 ~-12 ~12 ~-1 ~12 dark_prismarine/fill ~-11 ~ ~-11 ~11 ~3 ~11 deepslate_bricks/fill ~-11 ~3 ~-11 ~11 ~3 ~11 sea_lantern/fill ~-10 ~ ~-10 ~10 ~3 ~10 deepslate_tiles/fill ~-1 ~ ~-1 ~1 ~3 ~1 air/setblock ~ ~-1 ~ sea_lantern/summon armor_stand ~ ~ ~ {Tags:["c9_gen"],NoGravity:1b,Invisible:1b,Glowing:1b,equipment:{head:{id:"minecraft:soul_lantern",count:1}}}/summon marker ~ ~ ~ {Tags:["c9_node"]}/scoreboard players add #tick c9_t 1/execute if score #tick c9_t matches 3.. run scoreboard players set #tick c9_t 0/execute at @e[tag=c9_gen] run particle soul_fire_flame ~ ~1.8 ~ 0.3 0.6 0.3 0.04 12 force/execute at @e[tag=c9_gen] run particle sonic_boom ~ ~1.5 ~ 0 0 0 1 1 force/execute if score #tick c9_t matches 1 at @e[tag=c9_gen] run summon marker ~3 ~ ~ {Tags:["c9_dir"]}/execute if score #tick c9_t matches 1 at @e[tag=c9_gen] run summon marker ~-3 ~ ~ {Tags:["c9_dir"]}/execute if score #tick c9_t matches 1 at @e[tag=c9_gen] run summon marker ~ ~ ~3 {Tags:["c9_dir"]}/execute if score #tick c9_t matches 1 at @e[tag=c9_gen] run summon marker ~ ~ ~-3 {Tags:["c9_dir"]}/execute if score #tick c9_t matches 1 as @e[tag=c9_dir] at @s unless block ~ ~ ~ deepslate_tiles run kill @s/execute if score #tick c9_t matches 2 as @e[tag=c9_dir,sort=random,limit=1] at @s facing entity @e[tag=c9_gen,limit=1] feet positioned ^ ^ ^1.5 run fill ~-1 ~ ~-1 ~1 ~3 ~1 air/execute if score #tick c9_t matches 2 as @e[tag=c9_dir,sort=random,limit=1] at @s run tp @e[tag=c9_gen,limit=1] ~ ~ ~/execute if score #tick c9_t matches 2 at @e[tag=c9_gen] unless entity @e[tag=c9_node,distance=..1] run setblock ~ ~-1 ~ sea_lantern/execute if score #tick c9_t matches 2 at @e[tag=c9_gen] unless entity @e[tag=c9_node,distance=..1] run summon marker ~ ~ ~ {Tags:["c9_node"]}/execute if score #tick c9_t matches 2 run execute unless entity @e[tag=c9_dir] at @e[tag=c9_gen] run kill @e[tag=c9_node,distance=..1]/execute if score #tick c9_t matches 2 run execute unless entity @e[tag=c9_dir] as @e[tag=c9_node,sort=random,limit=1] at @s run tp @e[tag=c9_gen,limit=1] ~ ~ ~/execute if score #tick c9_t matches 2 run kill @e[tag=c9_dir]setup #4 Fills the outer border with deepslate bricks and a sea lantern top rim, while command 4 fills the carvable interior with <code>deepslate_tiles</code> so the cursor never tunnels outside the arena walls.loop #9 Probes 3 blocks away in all four cardinal directions and immediately deletes any <code>c9_dir</code> marker that does not land inside solid uncarved <code>deepslate_tiles</code>.loop #10 Picks one valid direction marker at random, faces back toward the generator cursor, steps halfway between them (<code>^ ^ ^1.5</code>), and carves a 3x4x3 tunnel connecting the two cells before teleporting the cursor there.loop #14 If no unvisited neighbors remain around the cursor, it removes the current cell's <code>c9_node</code> marker and teleports to another stored node to continue branching.


Recorded on our own test server: 59 frames at about 9.8 fps. Our image check saw: A deepslate brick labyrinth with sea lantern borders and prismarine flooring is actively being carved out by a glowing soul-fire cursor.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
The maze generator runs automatically on its own once spawned. To trigger a brand-new maze around yourself on demand, execute the setup commands /execute at @p run ... from a button or trigger command block, and walk into the labyrinth once the cursor finishes backtracking and stops moving.
/kill @e[tag=c9_gen]/kill @e[tag=c9_node]/kill @e[tag=c9_dir]/scoreboard objectives remove c9_t/fill ~-12 ~ ~-12 ~12 ~4 ~12 air/fill ~-12 ~-1 ~-12 ~12 ~-1 ~12 grass_blockPreviously the cursor jumped 4 blocks and only carved a 3x3 room at its destination without clearing the wall in between, and old probe markers were never cleared on tick 2. Using a 3-block stride and filling halfway between the cursor and target carves continuous corridors.
Yes! Increase the fill coordinates of the outer deepslate brick border and inner deepslate tiles by multiples of 3 (for example, from 10 to 13 or 16) so the 3-block step size aligns cleanly with the outer walls.
▶Glitching Farlands Wall GeneratorSelf-building StructuresMedium24 cmds
▶Autonomous Labyrinth WeaverSelf-building StructuresHard24 cmds
▶Automated Spire ConstructorSelf-building StructuresMedium19 cmds
▶Colossal Algorithmic Maze BuilderSelf-building StructuresHard22 cmds
▶Glitched Far Lands Terrain GeneratorSelf-building StructuresExpert22 cmds
▶High-Speed Multi-Shape Maze GeneratorSelf-building StructuresHard24 cmds