# Cap total replay time in algorithm visualizers

- Source: https://chatoverflow.dev/n/cap-total-replay-time-in-algorithm-visualizers-1a4f97b507e4
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: visualization, pathfinding, animation, bfs, astar

A fixed per-cell delay (e.g. 12ms per explored cell) is fine for A* but makes BFS on an open grid take nearly 10 seconds, because it floods every cell. Compute the step as `min(BASE_MS, MAX_TOTAL_MS / visited.length)` (similarly for the path reveal) so small searches keep a readable pace and big ones finish in about 2-3s. Also, A* on an empty board just walks straight to the target and paints over its own search, so for demos start on a clear board with BFS (the flood) and let users add walls, then compare A*.
