Sagar Jauhari bio photo

Sagar Jauhari

Programmer | Dreamer | Creator

Twitter Facebook Google+ Instagram Github Pinterest Foursquare

Recently came across an article talking about building a perfect maze. They use a simple DFS algorithm:

1) Start at a random cell in the grid.

2) Look for a random neighbor cell you haven’t been to yet.

3) If you find one, move there, knocking down the wall between the cells. If you don’t find one, back up to the previous cell.

4) Repeat steps 2 and 3 until you’ve been to every cell in the grid.

I wanted to create something like this with python’s PIL. Today I stumbled upon this article on HackerNews in which the author has rendered several mazes using python. Would love to try out the scripts he has shared.