AI Features

The Sidewinder Algorithm

Learn what the Sidewinder algorithm is and how it can be used for random 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, so that’s where we’ll start. In fact, we might as well start where we did before, in the ...

Ask