Link to GitHub. Inspiration for this tiny project was drawn from this video, with some modifications. It was mentioned that the algorithm can be expanded on, for example by generating long hallways - I did so by introducing the option of a long hallway bias, see the picture in the section below.
Moreover, instead of implementing my own stack pointer, I chose a simpler route by simply invoking recursive function calls to carve out a maze path. This is essentially a backtracking algorithm. Moreover, I changed it from C++ to Python. The parameters like maze size are set via global variables at the very top.
What I find intriguing about this algorithm is the beauty in its simplicity. It really is an easy algorithm to implement, yet it solves a seemingly nontrivial problem in that it is guaranteed that every point inside the maze can be reached from anywhere else.
The script simply generates a random number at each position to represent a new direction, and then it goes there - as long as this next position has not been visited yet. The current path is stored on a stack structure and whenever there is no way to go, the algorithm returns back along the stack.