Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧭 Pathfinding Visualizer Pro

Python Pygame Algorithms Graph Theory

A high-performance algorithm visualization tool that goes beyond basic grids to simulate real-world navigation challenges like terrain costs and robotic path smoothing.

The Problem: Standard algorithm visualizations are often too abstract, treating every movement as equal cost and every path as a jagged grid-walk, which fails to represent real-world navigation or CNC machining requirements.

The Solution: An interactive "Sandbox" that introduces industry-relevant concepts—weighted "Mud" nodes, diagonal Euclidean costs, and post-processing optimization—to demonstrate how algorithms like A* actually "think" in complex environments.


📸 Capabilities

  • Algorithm Face-Off: Run Dijkstra (the careful explorer) and A* (the guided missile) side-by-side in real-time to compare efficiency and node visitation.
  • Terrain Physics (Mud): Hold Shift to draw "Mud" nodes (Cost: 10). Watch algorithms dynamically decide whether to plow through the swamp or take the long way around.
  • Procedural Mazes: Uses the Recursive Division algorithm to instantly generate complex, non-trivial maze structures with a single click.
  • Path Smoothing: Includes a post-processing pass using Bresenham's Line Algorithm to "string pull" the jagged grid path into a smooth, realistic trajectory suitable for robotic motion.
  • Dynamic Physics: Supports 8-directional movement with calculated Euclidean costs ($\sqrt{2}$ for diagonals), creating natural, organic paths.

🛠 Tech Stack

Component Technology Description
Core Python 3.11+ Main application logic
Engine Pygame Accelerated 2D rendering & Event handling
Data Structures Priority Queues Min-Heap implementation for O(log n) retrieval
Algorithms A*, Dijkstra Weighted graph traversal
Math Bresenham's Line-of-sight checks for path smoothing
UI Custom Responsive, resize-aware grid layout

🚀 Quick Start

# 1. Clone the repo
git clone [https://github.com/maxykoin/pathfinding-visualizer.git](https://github.com/maxykoin/pathfinding-visualizer.git)
cd pathfinding-visualizer

# 2. Install dependencies
pip install -r requirements.txt

# 3. Launch the Visualizer
# Note: We run as a module to handle imports correctly
python -m main

🧠 System Architecture

The application is built on a modular "Generator-Based" architecture:

  1. Grid State Management: The grid is dynamic and responsive. When the window resizes, the Grid Manager recalculates the optimal node size (pixels) to fit the screen while preserving the map topology.
  2. Generator Logic (yield): Algorithms are implemented as Python Generators. Instead of blocking the thread, they yield control back to the UI loop after every node visit, allowing for smooth, adjustable animations without freezing the window.
  3. The Optimization Pipeline:
    • Step 1 (Search): The algorithm finds the optimal path on the weighted graph.
    • Step 2 (Reconstruct): We backtrack from End to Start to build the raw path.
    • Step 3 (Smooth): The get_smooth_path function iterates through the raw path, checking line-of-sight between non-adjacent nodes to eliminate unnecessary waypoints (String Pulling).

Built with ❤️ by Nina Cunha

Data Science · Industrial Automation · Software Engineering

LinkedIn GitHub


About

Modular Python/Pygame pathfinding engine featuring generator-based visualization of A* and Dijkstra on weighted graphs with diagonal cost modeling, maze generation, and post-processing path smoothing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages