Learned how to make an algorithm to create a maze and decided to try and visually explain the concept of what the algorithm is doing in each step as a potential resource to teach others.

## Step 1

The area is divided into blocks of 4 cells in a 2 by 2 formation.

## Step 2

The algorithm chooses one block at random. This becomes the "current block".

## Step 3

From the "current block", the algorithm checks the adjacent blocks to see if they have been "visited" before and that they are within the edges of the maze. Then it chooses one neighbouring block at random.

## Step 4

Remember that each block is 4 cells (see step 1). By default these cells are set as walls which are the same colour as the background colour. The algorithm removes 2 of the walls to create a path between the two blocks. Moving always to the bottom-right cell of the chosen block. The algorithm marks this block as being "visited" and uses this new block as the "current block" before repeating steps 3 and 4 again.

## Step 5

If the algorithm ends up at a dead end, it retraces the path checking each step until it finds a block that hasn't been "visited" yet.

Ultimately, the algorithm will check each block until the path extends into ALL the blocks.

The result is a randomly generated maze!