Maze Generation by Recursive Backtracking
It's useful to think of a maze as an array of cells with doors leading north, south, east, and west.
Maze Algorithms
P5.js example code demo.