Skip to content

Tudor230/AStar-Labyrinth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AStar-Labyrinth

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.

Project Objective

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

Syllabus Integration

Topic 3: Binary Trees (Open List)

The frontier (open list) is implemented as a Binary Min-Heap:

  • peek for best candidate access
  • popMin and pushOrUpdate in O(log n)
  • supports frequent priority updates during exploration

File: src/logic/structures/BinaryMinHeap.js

Topic 2: Red-Black Trees (Closed List)

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

A* Engine

Core search logic:

  • expands lowest f(n) node first
  • tracks cameFrom and gScore
  • reconstructs final shortest path
  • emits step events for live visualization

File: src/logic/pathfinding/aStar.js

Visualization

The React interface shows:

  • randomized maze generation (20x20, 30x30, 50x50)
  • frontier expansion (open and closed states)
  • current processed node
  • final traced shortest path

Main UI files:

Performance Notes

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

Run Locally

npm install
npm run dev

Open the URL shown by Vite (usually http://localhost:5173).

Validation

npm run lint
npm run test
npm run build

Tests

Unit tests are included for:

  • Binary Min-Heap behavior
  • Red-Black Tree insertion/membership behavior
  • A* shortest-path correctness and no-path scenarios

Test files:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors