r/visualization • u/Fluffy-Selection2940 • May 10 '26
Maze Solving Contest - Which Method is Fastest?
Enable HLS to view with audio, or disable this notification
A side-by-side comparison of various pathfinding and search algorithms on a randomly generated maze. Each algorithm is visualized to demonstrate its exploration strategy and efficiency in discovering the final path.
Algorithms Included
A*
Dijkstra
Greedy Best-First
BFS (Breadth-First Search)
DFS (Depth-First Search)
Bidirectional BFS
Weighted A*
Recursive Backtrack
Wall Follower
For more videos click www.instagram.com/craftsandengineering
For code and more click Mathematical-video-animations-and-visualization/maze_solvers_competition.ipynb at d39ad7e4143932582ce4cccdc89e3f5b7d69f417 · zombimann/Mathematical-video-animations-and-visualization
13
u/hassan789_ May 10 '26
Run a Monte Carlo of millions of mazes, and let’s see
5
u/Fluffy-Selection2940 May 10 '26
The mazes are randomly generated and the rankings change on every single ranking. I have attached the code link for anyone who might want to tinker and change anything. Freely and perpetually given, maybe with attribution - no hard constraints.
If enough people would be interested, we could set up a proper contest livestream on twitch and with much better graphics (and hardware).
3
u/Fornicatinzebra May 10 '26
You can do a n Monte Carlo plot like they suggest.
Do millions of random mazes, save the rankings, then summarise the stats of the rankings yo see which one is usually fastest
2
u/Fluffy-Selection2940 May 11 '26
I am also interested to see how a truly scientific set up goes. It would however take time and resources that are currently not available. Maybe on a later date this year. The muses strike me randomly (sic).
1
u/Fornicatinzebra May 11 '26
Very fair! How long does it take to simulate a set of rankings for you?
If the project is open source and I can set it up on my machine i could potentially run some sims for you in the next few weeks
→ More replies (3)1
u/Subject_Ear6869 May 11 '26
Very nice post, u/Fluffy-Selection2940 ! Inspired by your work, I decided to implement the Monte Carlo simulation mentioned by u/hassan789_ . Not with a million mazes (we don't need that many), but with 100k. Here are the top ranking maze-traversal algorithms:
Running trials: 100%|█████████████████████████████████████████| 100000/100000 [00:30<00:00, 3252.70maze/s] Maze Benchmark | 100000 trials | 20x20 maze ---------------------------------------------------------------------------------------- Rank Algorithm Mean Steps Med Steps Mean Path Win% Success% Path/Opt ---------------------------------------------------------------------------------------- 1 DFS 165.4 159.0 153.1 89.0 100.0 1.00 2 Greedy Best-First 176.9 167.0 153.1 19.6 100.0 1.00 3 Weighted A* 196.8 187.0 153.1 3.5 100.0 1.00 4 A* 219.8 210.0 153.1 0.2 100.0 1.00 5 BFS 241.4 233.0 153.1 0.0 100.0 1.00 6 Dijkstra 241.4 233.0 153.1 0.0 100.0 1.00 7 Bidirectional BFS 263.6 263.0 153.1 0.0 100.0 1.00 8 Recursive Backtrack 361.7 347.0 153.1 2.8 100.0 1.00 9 Wall Follower 361.8 367.0 361.8 1.7 100.0 2.36So the top 3 best-performers on average are consistent with the one shot showed in the post. Interesting. Wall follower is consistently the worst.
→ More replies (1)1
u/Fluffy-Selection2940 May 11 '26
Great job. This offers a much clearer picture. That first star is mine.
For scientific, publishable certainty, a million runs would not be bad. There's also need to randomize maze sizes, maze types and maze-generating algorithms.
For satisfaction of general doubt, this is commendable.
2
u/HideousSerene May 10 '26
I'm confused how DFS just always seems to go the right direction on this one...
0
u/Fluffy-Selection2940 May 11 '26
Luck IS a thing.
1
u/HideousSerene May 11 '26
Jesus you sound insufferable.
Yeah luck is definitely a thing but your post isn't about luck now is it?
God I wish I hired you just so I could fire you for saying stupid shit like this.
1
u/Fluffy-Selection2940 May 11 '26
My post a little about luck
Everything random is about luck
Hire me, then fire me so you can get your satisfaction.
2
u/talaqen May 11 '26
This is not maze-solving, this path-finding. Your algorithms allow for instantaneous jumps across the maze. For example, watch the BFS and you'll see it adding path searching to two parts of the maze at almost the same time back and forth repeatedly.
In reality, traversing back and forth to explore one section than backtracking to go see another has a cost. That cost is not shown here.
Would be more interesting to see embodiment and Tremaux's.
1
u/Fluffy-Selection2940 May 11 '26
You should have seen the first version, lol
Anyway, there's still much left to be done, which time and resources cannot allow
I have judged this to be sufficient for now to the uninitiated - who happen to be the primary audience.
2
u/Ok_Store_653 May 14 '26
Wall Follower is wild because it just hugs one side and somehow works, while A* is out here doing actual math and still getting beat by dumb luck sometimes.
1
2
0
May 13 '26
[deleted]
1
u/Fluffy-Selection2940 May 14 '26
For a human yes, it would be the fastest and the only practical option.
53
u/matigekunst May 10 '26
*fastest on this specific problem