The Sidewinder Algorithm
Explore how the Sidewinder algorithm generates random mazes by grouping cells and carving strategic passages. Understand its process starting from the western column, how runs of cells are formed and closed out, and learn about its inherent maze biases and edge cases. This lesson helps you grasp algorithmic approaches to maze creation and prepares you for practical coding in maze generation.
Understanding the Sidewinder algorithm
There’s an algorithm called Sidewinder, which, though closely related to the Binary Tree algorithm, still manages to reduce the biases a little. Recall that Binary Tree chooses between north and east at every cell; Sidewinder, on the other hand, tries to group adjacent cells together before carving a passage north from one of them. Let's go ahead and grab another piece of paper, sketch another grid on it, and we’ll jump right in.
The Sidewinder algorithm explained and illustrated
Now, unlike Binary Tree, Sidewinder won't easily let us start carving anywhere we like. It has a strong preference for beginning in the western column, ...