Colossal Algorithmic Maze Builder

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.

Java EditionComplex Contraptions & CinematicsHard22 commandsTested on a real 26.2 & 26.3 server
A glowing cyan cursor carves corridors into a large stone brick cube to build a maze. Download the GIF Video & GIF © www.9minecraft.net

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.

1. Setup - type these once 8 commands

  1. /scoreboard objectives add c9_id dummy
  2. /fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 deepslate_tiles
  3. /fill ~-16 ~ ~-16 ~16 ~5 ~16 air
  4. /fill ~-15 ~ ~-15 ~15 ~4 ~15 stone_bricks
  5. /fill ~-1 ~ ~-1 ~1 ~4 ~1 air
  6. /setblock ~ ~-1 ~ sea_lantern
  7. /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]}}
  8. /summon marker ~ ~ ~ {Tags:["c9_node","c9_ent"]}

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

  1. /scoreboard players add #tick c9_id 1
  2. /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
  3. /execute as @e[tag=c9_cursor] at @s run summon area_effect_cloud ~ ~ ~ {Duration:2,Tags:["c9_ scanner","c9_ent"]}
  4. /execute at @e[tag=c9_cursor] positioned ~4 ~ ~ if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}
  5. /execute at @e[tag=c9_cursor] positioned ~-4 ~ ~ if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}
  6. /execute at @e[tag=c9_cursor] positioned ~ ~ ~4 if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}
  7. /execute at @e[tag=c9_cursor] positioned ~ ~ ~-4 if block ~ ~ ~ stone_bricks run summon marker ~ ~ ~ {Tags:["c9_cand","c9_ent"]}
  8. /execute as @e[tag=c9_cand,sort=random,limit=1] at @s run tag @s add c9_pick
  9. /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
  10. /execute at @e[tag=c9_pick] run fill ~-1 ~ ~-1 ~1 ~4 ~1 air
  11. /execute at @e[tag=c9_pick] run particle block{block_state:{Name:"minecraft:stone_bricks"}} ~ ~2 ~ 1 1.5 1 0.3 60 force
  12. /execute at @e[tag=c9_pick] run summon marker ~ ~ ~ {Tags:["c9_node","c9_ent"]}
  13. /execute at @e[tag=c9_cursor] unless entity @e[tag=c9_pick] run kill @e[tag=c9_node,distance=..0.5]
  14. /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]

How it works

Frames from the test run

Colossal Algorithmic Maze Builder - frame 1Colossal Algorithmic Maze Builder - frame 2Colossal Algorithmic Maze Builder - frame 3

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.

Build it in your world

  1. Stand at the center of a flat 41x41 grass area with at least 18 blocks of clear space in every direction.
  2. Run each command from the Setup list in chat one by one to lay the deepslate foundation, build the solid stone brick block, and spawn the glowing central cursor.
  3. Place a line or stack of 13 Repeating Command Blocks set to Always Active nearby (or outside the 31x31 maze border).
  4. Paste the Loop commands in exact numerical order from 1 to 13 into the command blocks.
  5. Note: replace the last two loop commands' target logic or run a cleanup chain block <code>/kill @e[tag=c9_cand]</code> right after moving so candidate markers clear every tick.
  6. Watch from above as the glowing cyan cursor carves out the entire 31x31 labyrinth and backtracks to the center when complete.

Use it with real players

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.

Remove it again 4 commands

  1. /kill @e[tag=c9_ent]
  2. /scoreboard objectives remove c9_id
  3. /fill ~-16 ~ ~-16 ~16 ~5 ~16 air
  4. /fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 grass_block

FAQ

Is the maze layout actually different every single time?

Yes. 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.

How do I generate a brand new maze after it finishes?

Simply re-run the last five Setup commands to refill the stone bricks and spawn a new cursor and starting node at the center.

Commands used

/execute/fill/kill/particle/scoreboard/setblock/summon/tag/tp

Similar creations

Join 9Minecraft News & Guides