I'm building a little program in Excel for no reason other than teaching myself basic VBA skills, and I've run into a snag I can't quite figure out. The program is to generate a maze using borders, I have four Subs for making the borders, GoLeft, GoRight, GoDown, GoUp. I am using the below code to generate the path, using a Select Case of a RANDBETWEEN(1,4) to randomize the direction.
I have worked out how to not backtrack, as in it will not go the opposite direction the last loop went. If it goes DOWN, it cannot go UP on the next pass.
The problem I am having is the pathway always tends to loop back over itself. I have determined the way to correct this would be to drop a number into each cell as the path generates, representing the direction of turn that cell encountered, and to use an IF statement within each case?
tl;dr: If Case 1 is selected, how can I leave Case 1 and go to Case 2, if a given condition is met? Or do I just need to nest another level of Select Case?
Since this is a learning exercise for me, I don't need/want the code to be written for me, I just need to know what angle to attack this problem from.
Thanks!
Bookmarks