For the past few months or so, I have been somewhat interested in mazes (and not Risk so that project has been on hold although I did get a bit of the attack phase and increased the quality of the map) and looked into many of the various maze algorithms that exist. I explored many of these algorithms and implemented DFS recursion, Aldous-Broder, and Wilson's algorithms on the CE with much help from this series of blog posts. The latter two tend to produce less biased mazes with a variety of short and long corridors so I decided to use them in this project: a zen-like game of endless mazes. Once you finish one, a new one will automatically be generated. There is no timer and no scoring, just completing the mazes. I plan to include maze size selection and color customizations, but have done none of the graphics, only the generating code.
As of right now, the code utilizes Aldous-Broder to generate the first 1/3 of the maze (I saw a comment saying this is roughly the ideal convergence time) before switching and completing the rest with Wilson's. As I mentioned, I do not have any fancy graphics to share as of right now. However, this is a 50x50 maze generation I ran in CEmu that took ~6 seconds to complete. I doubt I would allow mazes that large in the final program due to graphics but I wanted to semi-stress test it.
Code:
The algorithms provide only one path for any start and end cell in the maze and uses every cell in the grid.
As of right now, the code utilizes Aldous-Broder to generate the first 1/3 of the maze (I saw a comment saying this is roughly the ideal convergence time) before switching and completing the rest with Wilson's. As I mentioned, I do not have any fancy graphics to share as of right now. However, this is a 50x50 maze generation I ran in CEmu that took ~6 seconds to complete. I doubt I would allow mazes that large in the final program due to graphics but I wanted to semi-stress test it.
Code:
######################################################################################################
# # # # # # # # # # # # # # # # # # #
# # ### # # ### ##### # # ### # ### ##### # # # # # # ####### ##### # ### # ##### # ##### # ##### ###
# # # # # # # # # # # # # # # # # # # # # # # # # # #
### # ### ##### # # ####### # # ##### # # # # # ### ########### ### ### # # # ##### # # ##### # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
### # # ### ##### # # ### ### # ####### ### ##### ### # # ### # ### ### ### # # # ### ####### # # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # ### ### # # ### # ##### # ##### ##### # # # ##### # ##### ######### # # # ### ### ######### ###
# # # # # # # # # # # # # # # # # # # # # # # # # #
# # ### ####### ######### # ### # # ### ### # ####### ####### # # ### # ### # # # ##### # # ### ### #
# # # # # # # # # # # # # # # # # # # # # # # # # # #
##### ##### ### # # ### ##### ### # ### # ### # # ### ### ### ### ####### # # ##### # ### ### # # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # #
### ### # ##### ####### ##### # # # ### ### # # # # ### ##### # # # ##### # # ### ### ##### # ##### #
# # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # ##### # ##### # # ### ######### # ##### # # ### ### # # # ### # ##### # ####### ##### ####### #
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
######### # ### ##### ### # # ############# ##### ### # # ### ##### ########### ### # ####### ### # #
# # # # # # # # # # # # # # # # # # # # # # # # #
# # # ### ### ### ##### # # # # ##### # ##### # ##### ### ########### ##### # # ############# ### ###
# # # # # # # # # # # # # # # # # # # # # # # #
# ########### # ### # # # # # # # ####### ### # # ### ### # # ### ##### ### # ### ### # ### ##### # #
# # # # # # # # # # # # # # # # # # # # # #
# ########### ### ##### ######### ### ### # # ### ##### ####### # ### # ######### ##### # # # # ### #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # ####### ### ### # ### ### ####### # ######### ##### ### ### # # # ### ######### ##### ##### #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ### # ##### ### ### # ### # # ### ### # ### # # # # ### # ##### # ##### # ### # ### ##### ##### # #
# # # # # # # # # # # # # # # # # # # # # # # # # # #
# ### # ######### ##### ##### ### ### ########### ##### ######### ### # ##### # # # # ### # ### #####
# # # # # # # # # # # # # # # # # # # # # # # #
####### # ### ##### ### # ######### ##### # # ### # ### # # # # # ### ##### ### # # # ### # # ##### #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
### # ##### ### # ####### # # # # # ##### ### # # ### # ####### ######### ### # ### ### # # # ### # #
# # # # # # # # # # # # # # # # # # # # #
# ### ##### # ######### # ####### # # ### ### ### ##### # ### ### ### # # # # ####### ##### ##### # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
### # ##### # ### # ### # ####### # # ##### ### # # ### # ##### ### # # ### # ### # # ##### # ### # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
### # # ### # ##### # # ##### # # ### # ####### ### ### ### ##### ####### # ### ### # # ### ### # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # ### ##### ### ##### ######### ### # ####### ##### ##### # # ##### # ### ### # # ### ### # # ###
# # # # # # # # # # # # # # # # # # # # # # # # #
# ### ### # ### # ### # # ##### # ### # ##### # ### ########### ######### # # # ######### ####### # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # ### # ######### ### # ### ########### ### # ### ### # # # # ####### ################# # #####
# # # # # # # # # # # # # # # # # # # #
# ### ########### ##### ### ### # ### ##### # # ### # # # ### # ##### # # # # ######### # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # ### ### # # # ### ### ####### ### ### ### ######### # ##### # # ### ######### ##### # # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ### ########### # ### # ##### ##### # # # ### # ##### # ### ### # ##### ### ### ##### ### ##### ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ########### ####### # # ### ### # ##### ##### # # ### ####### ### ### ##### ### # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # #
# # ##### # ### ### # ### ##### ####### # ### ##### ##### ### # ##### ########### ### ####### # # # #
# # # # # # # # # # # # # # # # # # # # # # #
# # ### ##### # # ### ######### ### ### ### ### ### # ##### # ### # # ##### ### ################# # #
# # # # # # # # # # # # # # # # # # # # # # # # #
##### # ##### ##### # ####### # # ####### ### # ### ##### ### ### # ### ### ##### ##### ### # # ### #
# # # # # # # # # # # # # # # # # # # # # # # # #
# # # ### # # ### # # ##### ### ### ### ############# ####### # # # ##### ### # # ##### # ### # #####
# # # # # # # # # # # # # # # # # # # # # # # # #
### ### ######### ### ### ### ######### # # ### # # # ####### ####### # # ##### ##### # # ##### # # #
# # # # # # # # # # # # # # # # # # # # # #
# ### ########### ### ### ### ####### # ### ### # ### # # ### ##### ### ##### ########### ### # ### #
# # # # # # # # # # # # # # # # # # # # # # # # # #
# # ##### # # ### ### # # # ### ####### ### ### # ######### # ### # ### ##### ### ### # ##### ### ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
##### # # ### ####### ### # ##### ### ####### ##### # # # ### ### ####### # # ##### ### # ###########
# # # # # # # # # # # # # # # # # # # # #
# # ### # ##### ### # # # ########### ####### # ### # ##### ### # ### ### ### # ######### ### ### ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ##### # # ### ### ### ##### # # # # # ######### ##### ##### ######### ####### ##### # ######### # #
# # # # # # # # # # # # # # # # # # # # #
# # ####### ########### ### # # # # ### # ### # ### ### ####### # ### # # ####### ### # ### # ##### #
# # # # # # # # # # # # # # # # # # # # # # # #
# ### ####### # # ### ### ########### # # # # ### ### ##### # ##### ##### ### # # ####### # ####### #
# # # # # # # # # # # # # # # # # # # # # # # # # # #
# ######### ### ### # # # # # ### # ##### ### ### ### # # ####### ### ##### ##### ##### ### # # ### #
# # # # # # # # # # # # # # # # # # # # # # # # #
# ### # ##### # ### ### ### ####### # # ######### ######### # ######### ### ##### # # ### # # # # ###
# # # # # # # # # # # # # # # # # # # # # # # #
# ### ##### # ### ########### # # # ##### ##### # ### # # ##### ### ######### ######### # ##### # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ########### # # ##### # # ### ### ##### ####### # ######### # # ### ### # # # ### # ### ### ### # #
# # # # # # # # # # # # # # # # # # # # # # # # # # #
### # ### # ####### ### ### ####### # ##### ### # # ### ##### ### ### ### ##### # ##### ### # #######
# # # # # # # # # # # # # # # # # # # # #
# ### ####### ### ### ### ##### ### # # ### ######### # ########### # ### # # ####### # ######### # #
# # # # # # # # # # # # # # # # # # #
# ### ### ### ### ### # ### ############# ### # # # ### # ##### ##### # ##### # ### # ### ######### #
# # # # # # # # # # # # # # # # # # # # # #
# # ### ##### # ##### ##### # ##### # ##### ### ### # ##### # # ######### ### ############### # #####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ######### ##### # # ##### # ##### # # # ### # ### ######### # # # # # # ### # ####### ### # ##### #
# # # # # # # # # # # # # # # # # # # # #
### ### # ### ######### # # # # # ### # ### ### # ### ##### # ### # ### ####### ##### # ### # ### ###
# # # # # # # # # # # # # # # # # # # # #
#####################################################################################################
The algorithms provide only one path for any start and end cell in the maze and uses every cell in the grid.