Path Planner

Path Planner Banner

Path Planning Algorithm Analysis (C++ & Raylib) Link to heading

A comparative study of deterministic and stochastic pathfinding algorithms in static and dynamic grid environments. This project visualizes and benchmarks BFS, DFS, A*, and a Genetic Algorithm (GA) using a custom C++ engine built with Raylib.

Visual comparison: A (Orange) & BFS (Yellow) find the optimal path, while DFS (Purple) explores inefficiently and GA (Blue) struggles with local optima.*

Features Link to heading

  • Real-time Visualization: Built with Raylib for high-performance rendering.
  • 4 Algorithms Implemented:
    • Breadth-First Search (BFS): Guarantees shortest path (Benchmark).
    • Depth-First Search (DFS): Memory efficient but non-optimal.
    • A* Search (A-Star): Optimized heuristic search (Manhattan Distance).
    • Genetic Algorithm (GA): Evolutionary approach with crossover, mutation, and “wall-sliding” physics.
  • Dynamic Environment:
    • 100x100 Grid (10,000 nodes).
    • Randomly generated static mazes.
    • Dynamic moving obstacles (Patrol bots).
  • Data Logging: Automatically exports performance metrics (Time, Path Length, Nodes Visited) to CSV.
  • Python Analytics: Includes a script to generate IEEE-style convergence and comparison graphs.

Installation & Build Link to heading

Prerequisites Link to heading

  • C++ Compiler: G++ (MinGW for Windows, or native GCC for Linux/macOS).
  • Raylib: Must be installed and linked.
  • Python 3.x: (Optional) Required only for generating graphs.
  • Python Libs: pandas, matplotlib, seaborn.

Compiling Link to heading

Linux/macOS:

g++ main.cpp bfs.cpp dfs.cpp astar.cpp ga.cpp -o path_planner -lraylib -lGL -lm -lpthread -ldl -lrt -lX11

Windows (MinGW):

g++ main.cpp bfs.cpp dfs.cpp astar.cpp ga.cpp -o path_planner.exe -O2 -lraylib -lopengl32 -lgdi32 -lwinmm

Usage Link to heading

  1. Run the Simulation:

    Bash

    ./path_planner
    
    • The window will open, generating a map and running all 4 algorithms sequentially.

    • Note: The Genetic Algorithm may take several seconds (or minutes) depending on parameters.

    • Results are saved to experiment_data.csv.

  2. Generate Graphs:

    Bash

    python3 plot_graphs.py
    
    • This generates comparison_bar.png and convergence_graph.png.

Configuration Link to heading

You can tune the algorithm parameters in ga.cpp and common.h:

C++

// ga.cpp - "Nuclear" Settings for Stress Testing
const int POPULATION_SIZE = 2000;
const int MAX_GENERATIONS = 1000;
const int CHROMOSOME_LEN = 5000;  // Path memory limit
const float MUTATION_RATE = 0.05f;

Results Summary Link to heading

AlgorithmAvg Time (μs)Path LengthOutcome
A* (A-Star)770199 (Optimal)Best
BFS1,667199 (Optimal)Accurate
DFS284535 (Poor)Fast but Dumb
Genetic Alg800,000,000+4,879 (Trapped)Failed