Autonomous Maze-Solving Grid

Build a self-solving BFS maze grid in vanilla Minecraft where glowing yellow search waves expand around crying obsidian barriers to reach a redstone goal.

Java EditionComplex Contraptions & CinematicsExpert24 commandsTested on a real 26.2 & 26.3 server
A pathfinding algorithm expands in yellow and cyan waves around obsidian walls across a gray Minecraft arena. Download the GIF Video & GIF © www.9minecraft.net

SimulationsTechnologyYellowCyanGreenLearningMini-gameMap MakingBlock building (fill/setblock/clone)21+ commands

Watch a computer science pathfinding algorithm come to life right on your world floor. Starting from an emerald origin tile, a breadth-first search (BFS) frontier expands outward in glowing yellow waves across a gray concrete arena, turning visited tiles cyan as it navigates around crying obsidian walls.

Each step of the search spawns bright particle bursts and plays crisp chime notes until the frontier discovers the redstone goal block, triggering a celebration beam.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /scoreboard objectives add c9_d dummy
  3. /scoreboard players set #4 c9_t 4
  4. /fill ~-8 ~-1 ~-8 ~8 ~-1 ~8 polished_blackstone_bricks
  5. /fill ~-7 ~-1 ~-7 ~7 ~-1 ~7 gray_concrete
  6. /fill ~-3 ~-1 ~-7 ~-3 ~1 ~2 crying_obsidian
  7. /fill ~3 ~-1 ~-2 ~3 ~1 ~7 crying_obsidian
  8. /setblock ~-6 ~-1 ~-6 emerald_block
  9. /setblock ~6 ~-1 ~6 redstone_block
  10. /summon marker ~-6 ~ ~-6 {Tags:["c9_m","c9_ctrl","c9_head"]}

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

  1. /scoreboard players add @e[tag=c9_ctrl] c9_t 1
  2. /scoreboard players operation @e[tag=c9_ctrl] c9_d = @e[tag=c9_ctrl,limit=1] c9_t
  3. /scoreboard players operation @e[tag=c9_ctrl] c9_d %= #4 c9_t
  4. /execute if score @e[tag=c9_ctrl,limit=1] c9_d matches 0 unless entity @e[tag=c9_win] as @e[tag=c9_head] at @s align xyz positioned ~0.5 ~ ~0.5 run summon area_effect_cloud ~1 ~ ~ {Tags:["c9_m","c9_cand"],Duration:5}
  5. /execute if score @e[tag=c9_ctrl,limit=1] c9_d matches 0 unless entity @e[tag=c9_win] as @e[tag=c9_head] at @s align xyz positioned ~0.5 ~ ~0.5 run summon area_effect_cloud ~-1 ~ ~ {Tags:["c9_m","c9_cand"],Duration:5}
  6. /execute if score @e[tag=c9_ctrl,limit=1] c9_d matches 0 unless entity @e[tag=c9_win] as @e[tag=c9_head] at @s align xyz positioned ~0.5 ~ ~0.5 run summon area_effect_cloud ~ ~ ~1 {Tags:["c9_m","c9_cand"],Duration:5}
  7. /execute if score @e[tag=c9_ctrl,limit=1] c9_d matches 0 unless entity @e[tag=c9_win] as @e[tag=c9_head] at @s align xyz positioned ~0.5 ~ ~0.5 run summon area_effect_cloud ~ ~ ~-1 {Tags:["c9_m","c9_cand"],Duration:5}
  8. /execute if score @e[tag=c9_ctrl,limit=1] c9_d matches 0 unless entity @e[tag=c9_win] as @e[tag=c9_head] at @s if block ~ ~-1 ~ yellow_concrete run setblock ~ ~-1 ~ cyan_concrete
  9. /execute if score @e[tag=c9_ctrl,limit=1] c9_d matches 0 as @e[tag=c9_head] run tag @s remove c9_head
  10. /execute as @e[tag=c9_cand] at @s if block ~ ~-1 ~ redstone_block run tag @e[tag=c9_ctrl] add c9_win
  11. /execute as @e[tag=c9_cand] at @s if block ~ ~-1 ~ gray_concrete run setblock ~ ~-1 ~ yellow_concrete
  12. /execute as @e[tag=c9_cand] at @s if block ~ ~-1 ~ yellow_concrete unless entity @e[tag=c9_head,distance=..0.4] run tag @s add c9_head
  13. /execute as @e[tag=c9_head] at @s run particle dust{color:[1.0,0.9,0.1],scale:1.8} ~ ~0.4 ~ 0.2 0.2 0.2 0 4 force
  14. /execute if entity @e[tag=c9_win] run particle totem_of_undying ~6 ~1.5 ~6 0.4 1.2 0.4 0.15 12 force

How it works

Frames from the test run

Autonomous Maze-Solving Grid - frame 1Autonomous Maze-Solving Grid - frame 2Autonomous Maze-Solving Grid - frame 3

Recorded on our own test server: 43 frames at about 7.1 fps. Our image check saw: A gray concrete arena with crying obsidian walls shows a yellow frontier wave expanding from an emerald block, leaving cyan tiles and blue/white particles behind as it moves toward a redstone block.

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 open area and run the 10 setup commands in order to build the 17x17 maze arena and summon the initial frontier marker at the emerald start block.
  2. Place 14 repeating command blocks (or 1 repeating command block chained into 13 chain command blocks), all set to Always Active.
  3. Paste the 14 loop commands in order into the command blocks.
  4. Watch the yellow frontier wave spread around the two crying obsidian walls, shifting visited tiles to cyan until it reaches the redstone block goal.
  5. To reset and try a custom maze layout, build your own walls out of crying obsidian inside the border, fill the floor back with gray_concrete, and re-run the last setup command.

Use it with real players

You can edit the maze walls live while the wave expands or build custom puzzles before launching the wave. To trigger the solver manually with an item instead of starting immediately, remove "c9_head" from setup command 10 and run /execute at @p run summon area_effect_cloud ~ ~ ~ {Tags:["c9_m","c9_head"],Duration:5} wherever a player stands on the grid.

Remove it again 5 commands

  1. /kill @e[tag=c9_m]
  2. /scoreboard objectives remove c9_t
  3. /scoreboard objectives remove c9_d
  4. /fill ~-8 ~-1 ~-8 ~8 ~-1 ~8 grass_block
  5. /fill ~-8 ~ ~-8 ~8 ~2 ~8 air

FAQ

Why doesn't the entity count keep growing as the wave expands?

Each candidate is an Area Effect Cloud with a Duration of 5 ticks. Since the wave advances every 4 ticks, only the active 1D frontier edge exists at any moment and old nodes vanish automatically.

Can I change the obstacles in the maze?

Yes! Because the wave only steps onto gray_concrete and stops at redstone_block, any other block you place on the floor acts as a solid wall.

Commands used

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

Similar creations

Join 9Minecraft News & Guides