Glowing Pathfinding Tracer

Watch a live Breadth-First Search algorithm flood a 19x19 deepslate labyrinth with glowing cyan nodes before backtracking the shortest golden path to the exit.

Java EditionComplex Contraptions & CinematicsExpert24 commandsTested on a real 26.2 & 26.3 server
Glowing cyan and golden tiles visualize a pathfinding algorithm inside a dark deepslate labyrinth. Download the GIF Video & GIF © www.9minecraft.net

SimulationsTechnologyCyanGoldGreenLearningMap MakingBlock displaysBlock building (fill/setblock/clone)21+ commands

This command creation visualizes a real Breadth-First Search (BFS) pathfinding algorithm inside a 19x19 deepslate labyrinth. Starting from the top-left corner, a wave of glowing cyan tiles flows down every corridor, splitting at intersections and filling dead ends until it locates the emerald exit beacon.

Once the target is reached, the flood stops and a glowing golden path traces backward from the exit to the start, highlighting the exact shortest route through the maze.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-9 ~-1 ~-9 ~9 ~1 ~9 polished_deepslate
  3. /fill ~-8 ~ ~-8 ~8 ~1 ~8 chiseled_deepslate
  4. /fill ~-7 ~ ~-7 ~-7 ~1 ~-1 air
  5. /fill ~-7 ~ ~-5 ~7 ~1 ~-5 air
  6. /fill ~-3 ~ ~-7 ~-3 ~1 ~7 air
  7. /fill ~3 ~ ~-7 ~3 ~1 ~5 air
  8. /fill ~-7 ~ ~3 ~7 ~1 ~3 air
  9. /fill ~-1 ~ ~-1 ~7 ~1 ~-1 air
  10. /execute align xz run summon block_display ~7.5 ~ ~-0.5 {Tags:["c9_exit"],block_state:{Name:"minecraft:emerald_block"},Glowing:1b,glow_color_override:65280,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.35f,0.1f,-0.35f],scale:[0.7f,1.4f,0.7f]}}

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

  1. /execute unless entity @e[tag=c9_node] run scoreboard players set #wave c9_t 1
  2. /execute unless entity @e[tag=c9_node] align xz run summon block_display ~-6.5 ~ ~-6.5 {Tags:["c9_node"],block_state:{Name:"minecraft:cyan_concrete"},Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.3f,0.05f,-0.3f],scale:[0.6f,0.4f,0.6f]}}
  3. /execute as @e[tag=c9_node] unless score @s c9_t matches 1.. run scoreboard players operation @s c9_t = #wave c9_t
  4. /execute unless entity @e[tag=c9_path] at @e[tag=c9_exit] run tag @e[tag=c9_node,distance=..0.4,limit=1] add c9_path
  5. /execute unless entity @e[tag=c9_path] as @e[tag=c9_node] if score @s c9_t = #wave c9_t at @s positioned ~1 ~ ~ if block ~ ~ ~ air unless entity @e[tag=c9_node,distance=..0.4] run summon block_display ~ ~ ~ {Tags:["c9_node"],block_state:{Name:"minecraft:cyan_concrete"},Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.3f,0.05f,-0.3f],scale:[0.6f,0.4f,0.6f]}}
  6. /execute unless entity @e[tag=c9_path] as @e[tag=c9_node] if score @s c9_t = #wave c9_t at @s positioned ~-1 ~ ~ if block ~ ~ ~ air unless entity @e[tag=c9_node,distance=..0.4] run summon block_display ~ ~ ~ {Tags:["c9_node"],block_state:{Name:"minecraft:cyan_concrete"},Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.3f,0.05f,-0.3f],scale:[0.6f,0.4f,0.6f]}}
  7. /execute unless entity @e[tag=c9_path] as @e[tag=c9_node] if score @s c9_t = #wave c9_t at @s positioned ~ ~ ~1 if block ~ ~ ~ air unless entity @e[tag=c9_node,distance=..0.4] run summon block_display ~ ~ ~ {Tags:["c9_node"],block_state:{Name:"minecraft:cyan_concrete"},Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.3f,0.05f,-0.3f],scale:[0.6f,0.4f,0.6f]}}
  8. /execute unless entity @e[tag=c9_path] as @e[tag=c9_node] if score @s c9_t = #wave c9_t at @s positioned ~ ~ ~-1 if block ~ ~ ~ air unless entity @e[tag=c9_node,distance=..0.4] run summon block_display ~ ~ ~ {Tags:["c9_node"],block_state:{Name:"minecraft:cyan_concrete"},Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.3f,0.05f,-0.3f],scale:[0.6f,0.4f,0.6f]}}
  9. /execute unless entity @e[tag=c9_path] run scoreboard players add #wave c9_t 1
  10. /execute if entity @e[tag=c9_path] if score #wave c9_t matches 2.. run scoreboard players remove #wave c9_t 1
  11. /execute if entity @e[tag=c9_path] at @e[tag=c9_path] as @e[tag=c9_node,tag=!c9_path,distance=0.6..1.2] if score @s c9_t = #wave c9_t run tag @s add c9_path
  12. /execute as @e[tag=c9_path] at @s run particle end_rod ~ ~0.6 ~ 0.1 0.1 0.1 0.01 1
  13. /execute as @e[tag=c9_path] run data merge entity @s {block_state:{Name:"minecraft:gold_block"},glow_color_override:16766720,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.35f,0.05f,-0.35f],scale:[0.7f,0.85f,0.7f]}}
  14. /execute if entity @e[tag=c9_path] unless score #wave c9_t matches 2.. run scoreboard players remove #wave c9_t 1

How it works

Frames from the test run

Glowing Pathfinding Tracer - frame 1Glowing Pathfinding Tracer - frame 2Glowing Pathfinding Tracer - frame 3

Recorded on our own test server: 48 frames at about 9.5 fps. Our image check saw: A deepslate labyrinth filled with glowing cyan path markers and a highlighted golden path leading from the top-left to a glowing green block on the right.

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 where you want the 19x19 maze to appear.
  2. Run each of the 10 setup commands in chat one by one to construct the deepslate labyrinth and place the emerald exit beacon.
  3. Place a line of 14 Repeating Command Blocks (or 1 Repeating followed by 13 Chain Command Blocks) nearby.
  4. Set all command blocks to Always Active and paste the 14 loop commands into them in exact order.
  5. Watch the cyan wave automatically flood the corridors from the corner and highlight the shortest golden route.

Use it with real players

To run the pathfinder between a player and a custom destination, summon the c9_exit block display at your target location, then replace the starting node summon coordinates in the second loop command with at @p align xz run summon block_display ~0.5 ~ ~0.5 ... so the search begins right at your feet.

Remove it again 5 commands

  1. /kill @e[tag=c9_node]
  2. /kill @e[tag=c9_exit]
  3. /scoreboard objectives remove c9_t
  4. /fill ~-9 ~-1 ~-9 ~9 ~1 ~9 air
  5. /fill ~-9 ~-1 ~-9 ~9 ~-1 ~9 grass_block

FAQ

Can I change the walls of the maze after it is built?

Yes! Because the nodes check for air blocks dynamically using if block ~ ~ ~ air, you can break or place walls inside the 19x19 interior and reset the nodes to watch it solve your custom layout.

How do I replay the pathfinding animation once it finishes?

Run /kill @e[tag=c9_node] in chat. The loop automatically detects when no nodes exist, resets the wave counter to 1, and starts a fresh search from the corner.

Commands used

/data/execute/fill/particle/scoreboard/summon/tag

Similar creations

Join 9Minecraft News & Guides