All algorithms

Informed search · 7 min read

A* Search

Cost so far, plus distance to go. Expand by cost-so-far plus distance-to-exit, respect soft patrol risk, and replan when death phases land.

Why this category

Search that orders expansion using extra knowledge: path cost (including soft patrol risk), straight-line distance to the exit, jump pruning, or both.

How it explores

Exploring: 2 of 31 states checked

expandedwallhazardroute

Why it is Informed

A* Search is Dijkstra's Algorithm and Greedy Best-First Search fused: expand the state that minimises cost-so-far + distance-to-exit. That is why it sits under Informed and why it is the default in the editor and demo.

Cost keeps it honest about what the route has already spent. The heuristic keeps it aimed at the door instead of flooding the whole grid like plain Dijkstra's Algorithm.

How it picks the next move

Priority equals g + h, where g is accumulated cost and h is Manhattan distance to the exit. Each step adds 1 + riskPenalty to g when the cell sits near a guard's patrol position that tick. Neighbours must be walkable, not yet settled, and not present in the learned death set as "x,y,tick % period". First time the exit is popped, reconstruct the path and walk it against real cones.

The red tiles in the diagram are hard bans for this plan (the same shape as learned deaths). Soft risk is a preference layered on top, not a wall.

What it stores after a fail

When the walk gets spotted at tick T: rebuild that guard's vision cone at tick T; store every cone cell as "x,y,T % period"; run A* Search again from the entrance with the larger blacklist.

Example: dying on (5, 3) at tick 6 with period 20 stores "5,3,6" (plus the rest of the cone at phase 6). The next plan may still use (5, 3) at tick 10, because phase 10 was never banned. A* Search discovers that retiming the same way it discovers any other cheaper legal path: by searching space-time with the new walls in place.

It never writes safe entries. Surviving a cell teaches nothing. Only the death calendar grows.

More informed search

Try it live

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