Origin Shift Maze Generation

Project Description

Generates a maze using the origin shift algorithm, which is the following:
1. Make a grid of nodes with a set number of rows and columns. These indicate the direction of the path.
2. For each node, if there is an adjacent node to the east, point that node to the east. Otherwise, if there is an adjacent node below, point that node to the south.
3. Mark the node in the bottom-right corner as the origin.
4. Repeat the following until the maze is ready: Select a random node adjacent to the origin, point the origin node towards the selected node, make the selected node the new origin.

Here, the yellow star is the origin, and the black lines are the valid paths. They are not walls, so don't expect to find a solution when going on the blank spaces! Try starting from two corners and moving from one point to another by going on the paths.

Click the stage to toggle slow mode. Pause the project when your maze is ready. Hover over the turtle sprite to see node data.

The height and width of the maze can be modified. It is 16x16 by default.

Created March 23, 2025

Last updated September 24, 2025

Published September 20, 2025