I want to be able to generate a perfect maze in a file (in C). The maze itself will be represented like such:
**XX**X*
X**X****
XX*X*XX*
XX***XX*
Meaning that the X are walls and the '*' are empty spaces (where you can move).
What I have done for now is: generate a block of 'X' and its size if chosen by the user at launch.
Example :
./maze 10 5
Would generate :
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
And all I have to do now is implement my algorithm.
But sadly, from the many algorithms I have found to generate a perfect maze, most of them are drawn with walls being as you would imagine them, and not a character in a file, so I don't know how to implement it in this case.
My main source being :
http://www.quora.com/What-are-the-algorithms-to-generate-a-random-maze
Can you guys tell me how I could implement such thing with my particular case?
Thanks in advance !
I think the algorithms you linked will work if you expand each cell into 4 cells, and use the top, left and top left as the walls if they exist.
Walls below the cell will be handle as a wall above the cell below, if that makes sense?