That morning I was looking for a random maze generator in the scratch search tab, but I couldn't find any that used list to store the maze. So I created my own ! So here is a random maze generator that store the result in lists, how is it store ? well we start on the bottom-left corner, that tile is store as ID 1, whenever we want to move one tile to the right we just have to add 1 to the ID and if we want to move up, well add the world width to the ID, it works because we are in a clamp space, so we can't go further than the world bounding box (or it will cause some problems)
For this random maze generator algorithm I used the randomized depth-first search (well, I think it's that, I just looked at the gif on wikipedia and told to myself : "oh I can do it like that" and the gif was name "Animation of graph theory based method (randomized depth-first search)") So how does it works ? First we start to a tile and we randomly create a path by : ° adding the current tile to a visited list ° adding one of the neighbor tile which has not been visited yet to the pile ° deleting the current tile of the pile list ° setting the next tile in the pile list to the current list ° repeating these steps while there are tiles in the pile list (so while we didn't run into a dead end) Then while we have not visited every tiles : ° set the current tile to a visited tile that has unvisited neighbor ° repeat the same random path algorithm And then we have a randomly generated maze with any two points connected by a path and contains no loop or isolated area