Changes

Jump to: navigation, search

Computer Science/61b/Homework/hw9/GRADER

1,013 bytes added, 06:42, 22 September 2007
no edit summary
To generate a random maze, modify the depthFirstSearch() method so that the order in which you check each direction (such as <tt>if ((fromWhere != FROMRIGHT) && !verticalWall(x, y))</tt>) is randomized. Then, each time the method checks for a cycle, if it doesn't find one, it can eliminate the wall before recursively checking the other cells.

# Since the basic checking algorithm remains unchanged, it will still do the same things the current algorithm is doing - check every cell, but only once, for a cycle
# There are 4 potential directions to be checked - top, right, bottom, and left. Create an array of length 4 with the digits 1-4. Randomize the digits in the same way we randomized the walls in the original homework. Then have a switch statement, with each case containing the cell check (i.e. <tt>if ((fromWhere != FROMRIGHT) && !verticalWall(x, y))</tt>), and run a for loop iterating through the array and executing each case. This way we make sure that each case is direction is actually checked.
1,277
edits

Navigation menu