Naive · 5 min read
Random Walk
No plan, no memory, just picks a direction. No graph search, no memory of where it has been, just a coin flip among safe neighbours each tick.
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
Random Walk never builds a route. There is no queue, no stack, no visited set, and no sense of where the exit is. Each tick it looks at the neighbouring cells that are still legal and picks one at random.
That is the whole algorithm. It exists so every other option in the dropdown has a floor to beat. Naive does not mean useless for teaching. It means not searching. If Random Walk solves a level, it did it by luck or by a very small grid.
How it picks the next move
At tick t, from cell (x, y): list orthogonal neighbours that are on the grid and not walls; drop any neighbour whose (nx, ny, t % period) key is in the learned death set; pick uniformly at random among what remains; step there. Repeat until the exit, a dead end, or the tick limit.
It does not remember cells it already walked. Circling is allowed.
What it stores after a fail
Same memory model as every other algorithm in this demo. When a guard spots the player at tick T, the engine records the whole vision cone at that patrol phase as "x,y,phase" where phase = T % layoutPeriod.
Those keys are hard bans on the next attempt. A square that kills you at phase 6 can still be walked at phase 10 if nothing was learned for phase 10. Surviving a square does not store a safe fact. Only deaths are remembered.
Because Random Walk has no global plan, that blacklist only shrinks the local coin-flip options. It does not retime a clever detour the way A* Search might.
More naive
Try it live
Run this algorithm on a built-in level, or paint your own grid and guards.