Knowing how to create a maze is as essential as breathing. So here is a simple algorithm to create mazes along with a link to a GitHub repository for its implementation in Swift.
1. Start at cell
2. Find a neighbor at random that you haven’t yet visited.
3. If you find one, move there, removing the wall between the current cell and the chosen cell. If you don’t find one, go back to the previous cell.
4. Repeat steps
3. until you’ve been to every cell in the grid.