Interactive web visualization of A* pathfinding on randomized labyrinths.
The project is built with React for UI rendering, while all algorithmic logic is implemented in plain JavaScript modules.
Find the shortest path between a start cell and a goal cell in a randomized maze using A*:
- Evaluation function:
f(n) = g(n) + h(n) - Heuristic: Manhattan distance
The frontier (open list) is implemented as a Binary Min-Heap:
peekfor best candidate accesspopMinandpushOrUpdateinO(log n)- supports frequent priority updates during exploration
File: src/logic/structures/BinaryMinHeap.js
Visited nodes (closed list) are stored in a Red-Black Tree:
- guaranteed self-balancing behavior
- membership checks in
O(log n) - avoids degeneration for adversarial insertion orders
File: src/logic/structures/RedBlackTree.js
Core search logic:
- expands lowest
f(n)node first - tracks
cameFromandgScore - reconstructs final shortest path
- emits step events for live visualization
File: src/logic/pathfinding/aStar.js
The React interface shows:
- randomized maze generation (20x20, 30x30, 50x50)
- frontier expansion (
openandclosedstates) - current processed node
- final traced shortest path
Main UI files:
By combining A* with tree-based structures:
- open-list priority operations stay efficient under heavy updates
- closed-list membership remains logarithmic even on long corridors
- larger labyrinths (30x30, 50x50) remain responsive in-browser
npm install
npm run devOpen the URL shown by Vite (usually http://localhost:5173).
npm run lint
npm run test
npm run buildUnit tests are included for:
- Binary Min-Heap behavior
- Red-Black Tree insertion/membership behavior
- A* shortest-path correctness and no-path scenarios
Test files: