Autonomous Maze-Solving NPC

Watch a glowing Copper Golem dynamically calculate paths around shifting deepslate walls to reach a relocating target beacon in a cybernetic arena.

Java EditionMobs & PetsHard20 commandsTested on a real 26.2 & 26.3 server
A glowing NPC reaches a beacon inside a dark deepslate arena with shifting walls. Download the GIF Video & GIF © www.9minecraft.net

Custom MobsTechnologyBlackOrangeCyanLearningMini-gameMap MakingBlock displaysSummoned mobsBlock building (fill/setblock/clone)Rotation math13-20 commands

This command creation builds a self-contained pathfinding arena where an autonomous Copper Golem navigates through shifting maze obstacles to reach a glowing beacon. Every few seconds, the target beacon teleports to a new quadrant while deepslate walls rise and fall across the floor.

Using real-time directional ray-checking and laser telemetry particles, the NPC scans for blocked paths, makes right-angle turns around barriers, and leaves a neon breadcrumb trail until it captures the goal.

1. Setup - type these once 6 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-9 ~-1 ~-9 ~9 ~-1 ~9 minecraft:polished_deepslate
  3. /fill ~-9 ~ ~-9 ~9 ~1 ~9 minecraft:tinted_glass hollow
  4. /fill ~-8 ~ ~-8 ~8 ~1 ~8 minecraft:air
  5. /summon minecraft:block_display ~6 ~ ~6 {Tags:["c9_e","c9_goal"],Glowing:1b,glow_color_override:65535,block_state:{Name:"minecraft:beacon"},transformation:{translation:[-0.4f,0.0f,-0.4f],scale:[0.8f,0.8f,0.8f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
  6. /summon minecraft:copper_golem ~-6 ~ ~-6 {Tags:["c9_e","c9_bot"],NoAI:1b,Glowing:1b,CustomName:{"text":"Pathfinder","color":"aqua"}}

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

  1. /scoreboard players add #tick c9_t 1
  2. /execute if score #tick c9_t matches 1..20 run fill ~-3 ~ ~-5 ~-3 ~1 ~2 minecraft:cracked_deepslate_tiles replace minecraft:air
  3. /execute if score #tick c9_t matches 1..20 run fill ~3 ~ ~-2 ~3 ~1 ~5 minecraft:cracked_deepslate_tiles replace minecraft:air
  4. /execute if score #tick c9_t matches 80 run fill ~-3 ~ ~-5 ~3 ~1 ~5 minecraft:air replace minecraft:cracked_deepslate_tiles
  5. /execute if score #tick c9_t matches 80..100 run fill ~-5 ~ ~2 ~2 ~1 ~2 minecraft:cracked_deepslate_tiles replace minecraft:air
  6. /execute if score #tick c9_t matches 80..100 run fill ~-2 ~ ~-3 ~5 ~1 ~-3 minecraft:cracked_deepslate_tiles replace minecraft:air
  7. /execute if score #tick c9_t matches 160.. run fill ~-5 ~ ~-3 ~5 ~1 ~2 minecraft:air replace minecraft:cracked_deepslate_tiles
  8. /execute if score #tick c9_t matches 160.. run scoreboard players set #tick c9_t 0
  9. /execute as @e[tag=c9_bot] at @s facing entity @e[tag=c9_goal,limit=1] feet positioned ^ ^ ^0.95 unless block ~ ~ ~ minecraft:air run tp @s ~ ~ ~ ~85 ~
  10. /execute as @e[tag=c9_bot] at @s facing entity @e[tag=c9_goal,limit=1] feet positioned ^ ^ ^0.95 if block ~ ~ ~ minecraft:air run tp @s ~ ~ ~ ~ ~
  11. /execute as @e[tag=c9_bot] at @s positioned ^ ^ ^0.35 if block ~ ~ ~ minecraft:air run tp @s ^ ^ ^0.22
  12. /execute as @e[tag=c9_bot] at @s unless block ^ ^ ^0.6 minecraft:air run tp @s ~ ~ ~ ~65 ~
  13. /execute at @e[tag=c9_bot] run particle minecraft:dust{color:[0.1,1.0,0.8],scale:1.0} ~ ~0.2 ~ 0.05 0.05 0.05 0 2
  14. /execute at @e[tag=c9_goal] run particle minecraft:end_rod ~ ~0.8 ~ 0.2 0.8 0.2 0.02 2

How it works

Frames from the test run

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

Recorded on our own test server: 60 frames at about 9.9 fps. Our image check saw: A deepslate arena contains shifting deepslate walls and a small glowing NPC standing right next to a glowing beacon in the bottom right corner.

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 in the center of a flat open area and run the 6 setup commands in chat one by one.
  2. notice the polished deepslate arena, tinted glass border, glowing beacon goal, and the Pathfinder Copper Golem.
  3. Place a line of 14 repeating command blocks set to Always Active nearby.
  4. Paste one loop command into each repeating command block.
  5. Watch the walls shift every few seconds while the golem steers around obstacles to reach the beacon.

Use it with real players

To have the autonomous NPC pathfind toward a real player instead of the beacon, replace @e[tag=c9_goal,limit=1] in the loop commands with @p. The Copper Golem will dynamically navigate around walls to follow you across the maze.

Remove it again 4 commands

  1. /kill @e[tag=c9_e]
  2. /scoreboard objectives remove c9_t
  3. /fill ~-9 ~ ~-9 ~9 ~2 ~9 minecraft:air
  4. /fill ~-9 ~-1 ~-9 ~9 ~-1 ~9 minecraft:grass_block

FAQ

How does the NPC avoid getting stuck on corners?

It uses two forward block checks: a 0.95-block ray toward the beacon to steer parallel to walls early, and a 0.6-block collision bumper that rotates it 65 degrees if a corner blocks its path.

Can I build my own custom maze inside the arena?

Yes! You can disable the wall-shifting commands (loop commands 2 through 7) and build any wall layout inside the glass border using solid blocks.

Commands used

/execute/fill/particle/scoreboard/summon/tp

Similar creations

Join 9Minecraft News & Guides