DEV Community

Navya Sharma
Navya Sharma

Posted on Edited on

I Turned Pathfinding Algorithms into an Interactive Game

🧩 MazeBench: Benchmarking and Visualizing Pathfinding Algorithms

What is MazeBench

An interactive framework for visualizing and benchmarking BFS, DFS, A*, and Ant Colony Optimization (ACO) on randomly generated mazes.

Why I Built MazeBench 🧐

Initially, my goal was to create an interactive framework where I could visualize each algorithm step by step and compare their search patterns. To make the project more engaging, I used Pygame to give it the look and feel of a real-time maze-solving game.

As I explored a few research and review papers, I noticed that different pathfinding algorithms were often evaluated under varying conditions, such as obstacle density, single-exit, and multiple-exit mazes.

Inspired by this, I decided to build a benchmarking system of my own. I extended the project by adding an automated script that runs BFS, DFS, A*, and ACO across 100 randomly generated mazes and compares their performance using metrics such as runtime, nodes expanded, path length, search efficiency, and success rate.

Features

  • Interactive Maze Visualization – Watch each algorithm explore the maze in real time.
  • Four Pathfinding Algorithms– BFS, DFS, A*, and Ant Colony Optimization (ACO).
  • Step-by-Step Animation – Observe how different algorithms search and make decisions.
  • Random Maze Generation – Generate a new solvable maze with every run.
  • Multiple Exit Support – Evaluate algorithms in more realistic maze configurations.
  • Automated Benchmarking – Run all algorithms across 100 randomly generated mazes.
  • Interactive Performance Dashboard – Compare runtime, path length, nodes expanded, search efficiency, and success rate.
  • Exportable Results – Generate benchmark reports and CSV files for further analysis.

Architecture 🏗️

The project follows a modular architecture, separating maze generation, search algorithms, visualization, and benchmarking into independent components. The diagram below illustrates only the interactive visualization framework; the benchmarking pipeline is intentionally omitted for clarity.

Benchmark Setup 📊

Rather than testing the algorithms on a single maze, I wanted a fair comparison across different scenarios. Each algorithm was evaluated on 100 randomly generated mazes under identical conditions.

Metrics collected:

  • Runtime
  • Nodes Expanded
  • Path Length
  • Search Efficiency
  • Success Rate

Results 📈

One of the biggest takeaways was that no single algorithm dominated every metric.

  • DFS achieved the fastest runtime but often produced longer paths.
  • BFS and A* consistently found optimal paths.
  • A* explored the fewest nodes while maintaining optimality.
  • ACO produced competitive solutions but required significantly more computation.

The dashboard below summarizes the complete benchmark across all 100 runs.

🔗 Interactive Benchmark Dashboard: View Live Dashboard

What I Learned 💡

This project reinforced a simple but important lesson:

'The fastest algorithm isn't always the best algorithm'

Visualizing and benchmarking these algorithms made their trade-offs much clearer than simply studying their implementations. Choosing the right algorithm ultimately depends on the problem you're trying to solve.

Thanks For Reading So Far! 😊

💻 GitHub Repository: MazeBench

⭐ If you found this project interesting, feel free to leave a star on GitHub!

Which pathfinding algorithm or feature would you add next to improve MazeBench? I'd love to hear your thoughts in the comments.

Top comments (0)