Content deleted Content added
Artoria2e5 (talk | contribs) No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
Artoria2e5 (talk | contribs) Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
Line 58:
This is in effect a depth-first search expressed in term of grid points. The omniscient view prevents entering loops by memoization. Here is a sample code in [[Java (programming language)|Java]]:
<syntaxhighlight lang="java">
boolean[][] wasHere = new boolean[width][height];
boolean[][] correctPath = new boolean[width][height]; // The solution to the maze
Line 65:
public void solveMaze() {
maze = generateMaze(); // Create Maze (
for (int row = 0; row < maze.length; row++)
// Sets boolean Arrays to default values
Line 79:
public boolean recursiveSolve(int x, int y) {
if (x == endX && y == endY) return true; // If you reached the end
if (maze[x][y]
// If you are on a wall or already were here
wasHere[x][y] = true;
|