Naive · 5 min read
Wall Follower
Keeps a hand on the wall and hopes. A classic hand-on-the-wall reflex with a real guarantee on loop-free mazes, and no map when the walls braid.
Why this category
No graph search. Each tick follows a local rule (random pick, keep a hand on the wall, or ride a potential field) with no plan of the full route.
How it explores
Starting from the entrance...
Why it is Naive
Wall Follower is the old hedge-maze trick: keep your right hand on the wall and you will eventually find the exit. In this demo it is Naive because that rule is still a local reflex. It never searches the space-time graph or builds a map of where it has been.
It is a real algorithm with a real guarantee: on a simply connected maze (walls with no loops), following one hand reaches the exit. The Pac-Man style levels here are deliberately braided. On those, Wall Follower can trace the same loop forever.
How it picks the next move
It starts facing away from the entrance (east on these levels). Each tick it tries turns in clockwise preference from its current heading: right, then straight, then left, then U-turn.
The first option that lands on a walkable cell, and is not a learned death at that tick's patrol phase, wins. Facing updates to that direction. There is no visited set beyond which way it is facing right now.
What it stores after a fail
Deaths are stored as "x,y,phase" with phase = caughtTick % period, covering the whole cone that caught you. Next attempt, those phases are illegal.
That can break a loop if the death sits on the wall it was hugging. It can also do nothing useful if the loop never steps into a learned phase. Unlike Breadth-First Search or A* Search, Wall Follower will not replan a different corridor on purpose. It only obeys the turn rule among cells that are still allowed.
More naive
Try it live
Run this algorithm on a built-in level, or paint your own grid and guards.