The live demo starts when it’s in view.Paint walls · start on a wall to erase · drag A and B · arrow keys move B
A way round walls and props from one blocked(x, z) question.
What it costs a frame
CPU
1.37 ms
02468101216.7 ms
GPU
not used
CPU, median
1.37 ms
CPU, 95th pct
3.71 ms
Draw calls
0
Weight
Moderate
Measured 3 November 2026 on 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 156, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured with the start and goal circling the map: the path is planned again every frame (lazy grid, A*, pulling) and the walkers replan within a shared budget of 6,000 cells a frame. The frame time includes the Canvas 2D drawing. Phones: tiers are being measured next.
apple · Apple A19 Proin a browser tab · 16 November 2026
not timed
1.96
3.34
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
not timed
1.81
4.34
Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.
What it needs
Renders with
Canvas 2DA 2D canvas: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
What it’s for
NPCs and guards walking round buildings
Click-to-move in top-down games
Units on a map that changes
Robots and agents in a simulation
Routing round obstacles on a floor plan
Pitfalls, in brief
blocked(x, z) must answer for a whole body, its radius included: the grid samples points (cell centres), so a thin wall between two samples is walked straight through.
A goal it cannot reach is not an error: reached is false and the points end at the nearest cell it got to.
The cap (maxVisited, 3000 by default) is per box: a box that is closed in is searched again three times as wide, so visited can come back at up to twice the cap.
Each plan allocates its grid (about 10 bytes a cell, up to 220 × 220 cells): plan when the straight line is blocked (walkClear first) and when the goal moves, not every frame for every body.
A goal further than the box can hold (maxSide cells less the margins) is planned toward a point on the line to it, and reached is false: plan again as the body gets nearer.
2 more in brief
A start up to 3 cells inside something is moved to the nearest open cell; deeper than that the plan is empty, so handle points.length === 0.
Coordinates are world metres on the ground plane, x and z: on a top-down screen z is your y.
7 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From HaTac. Fully custom code.
Hart, Nilsson and Raphael, A* search (1968): The search is A*, with the octile distance as its heuristic for eight-way moves. The algorithm, not code.
Line-of-sight path smoothing (“string pulling”): The well-known technique of joining each point to the furthest later one in sight. The idea, not code.
Comment threads pinned to items or to spots, with replies, @mentions (the longest name wins), edit, resolve and reopen; task cards with a status, an assignee…