An autonomous glowing beacon carves and backtracks through a solid deepslate grid using live depth-first search until a complete labyrinth stands lit.
Self-building StructuresTechnologyMysticOrangeBlueCyanBuilding ToolLearningMini-gameItem displaysSmooth animation (interpolation)Block building (fill/setblock/clone)Rotation math21+ commands
A solid 19x19 block of deepslate_bricks capped with deepslate_tile_slab sits on the platform while a glowing beacon display entity autonomously tunnels through it. As the beacon explores, it leaves an active path of warm shroomlight along its recursion stack.
Whenever the carver reaches a dead end, it reverses course and follows the shroomlight trail back toward open branches, converting finished corridors into cool sea_lantern blocks until every cell is connected into a complete, solvable labyrinth.
/scoreboard objectives add c9_state dummy/fill ~-10 ~-1 ~-10 ~10 ~-1 ~10 polished_deepslate/fill ~-9 ~ ~-9 ~9 ~1 ~9 deepslate_bricks/fill ~-9 ~2 ~-9 ~9 ~2 ~9 deepslate_tile_slab/fill ~ ~ ~ ~ ~2 ~ air/setblock ~ ~-1 ~ shroomlight/fill ~ ~ ~-9 ~ ~2 ~-9 air/fill ~ ~ ~9 ~ ~2 ~9 air/execute align xz positioned ~0.5 ~ ~0.5 run summon item_display ~ ~ ~ {Tags:["c9_head"],item:{id:"minecraft:beacon",count:1},Glowing:1b,glow_color_override:16755200,teleport_duration:2,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,1.6f,0f],scale:[1.3f,1.3f,1.3f]}}/scoreboard players set @e[type=item_display,tag=c9_head] c9_state 0/execute as @e[tag=c9_head,scores={c9_state=2},distance=..0.8] run scoreboard players set @s c9_state 3/execute as @e[tag=c9_head,scores={c9_state=2}] at @s unless block ^ ^-1 ^1 shroomlight run tp @s ~ ~ ~ ~90 0/execute as @e[tag=c9_head,scores={c9_state=2}] at @s if block ^ ^-1 ^1 shroomlight run scoreboard players set @s c9_state 1/execute as @e[tag=c9_head,scores={c9_state=0}] store result entity @s Rotation[0] float 90 run random value 0..3/execute as @e[tag=c9_head,scores={c9_state=0}] at @s unless block ^ ^ ^2 deepslate_bricks run tp @s ~ ~ ~ ~90 0/execute as @e[tag=c9_head,scores={c9_state=0}] at @s unless block ^ ^ ^2 deepslate_bricks run tp @s ~ ~ ~ ~90 0/execute as @e[tag=c9_head,scores={c9_state=0}] at @s unless block ^ ^ ^2 deepslate_bricks run tp @s ~ ~ ~ ~90 0/execute as @e[tag=c9_head,scores={c9_state=0}] at @s unless block ^ ^ ^2 deepslate_bricks run scoreboard players set @s c9_state 2/execute as @e[tag=c9_head,scores={c9_state=0..1}] at @s run tp @s ^ ^ ^2/execute at @e[tag=c9_head,scores={c9_state=0}] run fill ^ ^-1 ^-1 ^ ^-1 ^ shroomlight/execute at @e[tag=c9_head,scores={c9_state=0}] run fill ^ ^ ^-1 ^ ^2 ^ air/execute at @e[tag=c9_head,scores={c9_state=1}] run fill ^ ^-1 ^-2 ^ ^-1 ^-1 sea_lantern/scoreboard players set @e[tag=c9_head,scores={c9_state=1}] c9_state 0/execute at @e[tag=c9_head] run particle dust{color:[0.2,0.95,1.0],scale:1.8} ~ ~1.8 ~ 0.6 0.8 0.6 0 12setup #9 Summons the <code>c9_head</code> beacon <code>item_display</code> centered at <code>~0.5 ~ ~0.5</code> with <code>teleport_duration:2</code> for smooth interpolation and a golden glow outline.loop #4 Picks a random cardinal yaw (0, 90, 180, or 270 degrees) by storing <code>/random value 0..3</code> multiplied by 90 directly into <code>Rotation[0]</code>.loop #5 Checks two blocks ahead in local coordinates (<code>^ ^ ^2</code>). Repeated three times, this guarantees the carver finds any unvisited <code>deepslate_bricks</code> neighbor or detects a dead end.loop #10 Marks the carved bridge and new cell floor with <code>shroomlight</code>. Because depth-first search forms a tree, the active <code>shroomlight</code> trail always points straight back to the parent cell.loop #12 When backtracking (<code>c9_state=1</code>), turns the completed dead-end cell and bridge into <code>sea_lantern</code> before resuming exploration from the parent.loop #1 Stops the algorithm (<code>c9_state=3</code>) the moment the carver enters backtracking mode back at the center origin, meaning every cell has been visited.


Recorded on our own test server: 69 frames at about 9.8 fps. Our image check saw: A glowing beacon entity moves through a carved deepslate brick maze, converting paths of orange shroomlight into blue sea lanterns while emitting cyan particles.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
/kill @e[tag=c9_head]/scoreboard objectives remove c9_state/fill ~-10 ~ ~-10 ~10 ~3 ~10 air/fill ~-10 ~-1 ~-10 ~10 ~-1 ~10 grass_blockThe <code>shroomlight</code> floor blocks act as the stack in the world itself. Since a depth-first maze has no loops, each cell being backtracked out of has only one adjacent <code>shroomlight</code> bridge leading back to its parent.
Yes. Depth-first search creates a spanning tree across all 81 interior cells, so there is exactly one valid path connecting every cell—including the north and south openings.
▶Automated Spire ConstructorSelf-building StructuresMedium19 cmds
▶Colossal Algorithmic Maze BuilderSelf-building StructuresHard22 cmds
▶High-Speed Multi-Shape Maze GeneratorSelf-building StructuresHard24 cmds
▶Glitching Farlands Wall GeneratorSelf-building StructuresMedium24 cmds
▶Automated Orbital Dome BuilderSelf-building StructuresMedium23 cmds
▶Autonomous Colossus Orb BuilderSelf-building StructuresHard23 cmds