After finding out about recursive backtracking, I figured I’d try my hand at developing a basic maze algorithm. After making what appeared to be a working recursive backtracking maze, I ran into a few issues, as well as some major crashing.
Essentially, it works off of a grid of integers with variable associations. Maze paths can be adjacent to walls, and must be spaced one away from non-barrier tiles in use, but fill empty ones. Simple enough. I check all directions for each tile and, while it is possible to move to one of those directions, it will loop through in order to handle recursion. As for finding the coordinates themselves, I have a parallel array of coordinates that I used to check each position (x or y * tilesize, allows for static mesh placement). I haven’t developed a true system of random pathway choice, so I need to handle that as well, and the current fixup is pretty terrible looking (you’ll see)
An example of a smaller maze and the maze it generates, nothing too fancy.
Because the mazes are dependent on while loops and directions, it appears that the recursive methods enter an infinite loop after some number of tiles has been reached (stopping points included 30 by 30 and 58 by 20). This is what it looks like if I use a for loop that occurs four times, so there are definitely more movements to be made.
I generate the integer grid and assign values here. The outside tiles are set as barriers, and the rest are empty.
Been messing around with whether or not it should occur with a for loop and such, but I figured I was better off starting at the first open position (1 by 1, or 200 by 200 if considering tile size)
An example of directional checks. Went through each one to make sure that the coordinate math was correct, so they do calculate the space to be moved to as well as three surrounding blocks (like a tetris block)
Still have to figure out an efficient way to randomly choose between directions without making this sort of mess.
I suppose I’m at a pretty hard standstill here. Maybe I’m missing something really key to this process here? Perhaps this sort of programming isn’t particularly suited for Blueprints as much as it is for C++? Will we ever find a solution? Who is the father?