Thursday, August 13, 2015

Maze Restrictions? No Problem!

Apart from the peril of excessive compilation time, I've finally figured out how to get the maze to not produce any dead ends. By way of setting up the walls on an odd numbered square for example, 11x11, there is a 9x9 square in the middle, which yields a 7x7 set of squares that are set comfortably in the middle (4x4 pillars, to be specific). However, if one goes with 10x10, the algorithm still tries to produce 4x4 pillars, with the last row and column set firmly against the wall instead of properly stranded. This makes it very easy for certain seed values to yield unwinnable results. Solution? Restrict the values upon maze generation. A simple modulo does nicely.



Another restriction I found in the code was the declaration of a multi-dimensional array with set boundaries based on a max. It would be simple to break the code by placing something larger than the max in editor, so I also placed a quick check. Now we have a robust maze generation system that procedurally generates a simple yet complex and winnable maze that can be scaled in size (no squares needed). Now to just place the ball in the start spot and perhaps a bit of fancier visuals?

No comments:

Post a Comment