vendredi 23 juillet 2021

Maze Generation results [closed]

I'm trying to write an algorithm to create mazes. The algorithm looks like this:

  1. Start at a random cell.
  2. Mark the current cell as visited, get a list of the neighbors. For each neighbor, starting with a randomly selected neighbor:
    If that neighbor hasn't been visited, remove the wall between this cell and that neighbor, and then recurse with that neighbor as the current cell.

But the algorithm produces mazes like this: Maze example

I don't know why the algorithm creates full lanes instead of creating dead ends as well to make it look more like a maze instead of a one way road.

I can't narrow down the problem with the algorithm. I though of bad random selection or that the algorithm marks each cell as visited in the recursive step resulting in no dead ends as it can't go back to a cell. I could provide code as well but I think my idea for the algorithm is somehow messed up. I would be grateful for any ideas.




Aucun commentaire:

Enregistrer un commentaire