I made a maze generator and solver in C# (and Python)

This is the C# version

This simple maze generator uses the depth-first method to make a maze of any odd-by-odd dimensions. It's an ideal project for anyone who wants to demonstrate good recursion comprehension.

It's an application of the depth-first search method of maze generation. There are two versions: C# and Python. The Python version is simpler, but the C# version solves itself.

The starting tile is marked as active. This active tile evaluates which of the four directions it can carve a tunnel to, based on if the direction has already been carved or not. A random direction is chosen and the newly carved is marked as active, where the process repeats until all cells are carved. This depends heavily on recursion, which is probably why students were tasked to do a similar project in Data Structures and Algorithms.

Since any structure a depth-first search is applied to can be interpreted as a tree, the algorithm retraces its steps to the root, and the single path from the start to the end is made. The C# version uses this to have an AI "solve" the mazes by animating a character walking from the start to the finish.

This is the Python version