Skip to content

Made a algorithm visualizer using python, it'll show live how the algorithm finds it's way to the end of the maze, it also has a benchmark feature so you could compare different algorithms speed.

Notifications You must be signed in to change notification settings

Kapaply/Pathfinding-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pathfinding Visualizer (Python, DSA)

Motivation: I noticed I've been struggling a little bit with DSA, so I decided to make a whole project around it. I figured if I could successfully code a pathfinding visualizer, I surely would understand Djikstras algorithm, BFS and A*. Hopefully this helps others too.

https://github.com/Kapaply

Features

  • Algorithms: BFS (unweighted shortest path), Dijkstra (weighted), A*(heuristic-guided).
  • Heuristics: Manhattan, Euclidean, Chebyshev/Diagonal.
  • Data structures: adjacency via grid neighbors, binary heap priority queue (using heapq), parent maps.
  • Visualization:
    • CLI: step-by-step ASCII animation.
    • Pygame (optional): pretty grid with live expansion coloring.
  • Benchmarks: compare runtime and explored nodes across algorithms on random mazes.
  • Tests: correctness checks with pytest.

Quick Start

#Use a venv
python -m venv .venv && source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install library in editable mode
pip install -e ".[dev]"              # for tests
pip install -e ".[viz]"              # for pygame visualizer
pip install -e ".[plots]"            # to generate benchmark plots (optional)

# Run the CLI visualizer
python -m pathviz.visualize_cli --algo astar --rows 25 --cols 45 --density 0.28 --speed 0.01
# Other algos: bfs, dijkstra

Pygame Visualizer (optional)

python -m pathviz.visualize_pygame --algo astar --rows 30 --cols 50 --density 0.30

Benchmarks

python -m pathviz.benchmarks --rows 35 --cols 60 --trials 5 --density 0.3 --seed 1337 --plot out.png

Run Tests

pytest -q

Project Structure

pathfinding-visualizer/
  src/pathviz/
    __init__.py
    grid.py
    heuristics.py
    algorithms.py
    visualize_cli.py
    visualize_pygame.py
    benchmarks.py
  tests/
    test_algorithms.py
  examples/
    run_cli.py
    run_pygame.py
  docs/
    architecture.md
  pyproject.toml
  README.md
  LICENSE

About

Made a algorithm visualizer using python, it'll show live how the algorithm finds it's way to the end of the maze, it also has a benchmark feature so you could compare different algorithms speed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages