All algorithms

Naive · 5 min read

Potential Fields

Pulled to the exit, pushed off danger. A local force field: attract to the exit, repel from death phases and walls, no graph search.

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

Exploring: 1 of 22 states checked

expandedwallhazardroute

Why this category

Potential Fields is Naive for the same reason as Random Walk and Wall Follower: each tick is a local score among safe neighbours. There is no queue, no visited set, and no global route.

Attraction to the exit and repulsion from danger are useful reflexes, but local minima and oscillation are classic failure modes — exactly the Naive lesson.

How it picks the next move

List orthogonal neighbours that are walkable and not a learned death at this tick's phase. Score each as minus Manhattan distance to the exit, minus repulsion from nearby "x,y,phase" kill cells and adjacent walls, with a small penalty for immediate reversal.

Step to the highest score. Repeat until the exit, a dead end, or the tick limit.

What it stores after a fail

Deaths still become "x,y,phase" bans that remove options from the local score. Potential Fields does not build a detour on purpose — it only stops considering banned cells at that phase.

Unlike A* Search, it will not retime a corridor unless the field happens to push it onto a different phase by wandering.

More naive

Try it live

Run this algorithm on a built-in level, or paint your own grid and guards.