How to create auto-generated mazes???

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BigDC

I use Godot 3.4.4
How can I go about learning to create 2D top-down mazes that will be auto-generated from tilemaps and that have a starting position going into the maze and having an ending position that leaves the maze, and be connected to each other without any blockage or breakage, and have it save the auto-generated maze as a scene to be loaded at anytime that a player can run and/or walk through, please give me some guidance on this? Oh just to let you know, when it comes to maths, Homer Simpson is a freaking genius compared to me lol.

There are 4 maze-generation tools in the Godot Asset Library. Have you looked at those?

jgodfrey | 2022-03-28 16:52

:bust_in_silhouette: Reply From: Wakatta

Before you write a single block of code plan out exactly what you want to do because appending features later on usually breaks working functionality and creates bugs.

When you can’t find your way look at aStar like the 3 wise men by using other’s work as a reference or template for research into how things are done.

The general way to get a program like this done, would be to break up each operation into smaller bite sized tasks.

  • Randomly set start and end at the edge of a rect
  • Partially fill the rect with randomly placed obstacles
  • Use A* to navigate a path from start to end
  • Create rules for how the maze is to be built
  • Fill the rect with obstacles using the rules and avoiding the path returned by A*

There will not be a tutorial on how to do everything and so you need to adopt a workflow to save on time for every project you start.

:bust_in_silhouette: Reply From: samjmiller

I found this guide easy to follow, and it gave me great results for auto-generating mazes:

https://abitawake.com/news/articles/procedural-generation-with-godot-create-dungeons-using-a-bsp-tree