ScratchData LogoScratchData
Back to AlSweigart's profile

Maze Generator (Recursive Backtracking Algorithm)

ALAlSweigart•Created February 1, 2014
Maze Generator (Recursive Backtracking Algorithm)
238
205
11478 views
View on Scratch

Instructions

This program uses the "recursive backtracking algorithm" for generating a maze. A description of this algorithm can be found here: http://weblog.jamisbuck.org/2010/12/27/maze-generation-recursive-backtracking After the maze is done, use the arrow keys to move the cat to the cheesy puffs. To make maze generation faster, shift-click the green flag to enable turbo mode. After the maze is done, shift-click the green flag again to turn off turbo mode so you can walk around the maze. (You can also set the BACKTRACK DELAY variable in the code to 0 to make the maze-making faster.)

Description

Learn to program games with this free online Scratch course: https://inventwithscratch.com/class The algorithm is pretty simple: 1) Randomly move around to cells you haven't visited before. 2) When you reach a dead end, backtrack until you get next to a cell you haven't visited before. Keep moving in that direction. 3) If you've backtracked all the way to the start, you're done.

Project Details

Project ID17358777
CreatedFebruary 1, 2014
Last ModifiedJuly 29, 2018
SharedFebruary 1, 2014
Visibilityvisible
CommentsAllowed