{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Maze - Maze.java Author Lewis/Loftus Solution to...

This preview shows pages 1–2. Sign up to view the full content.

//******************************************************************** // Maze.java Author: Lewis/Loftus // // Solution to Programming Project 11.3 // // Represents a maze of characters. The goal is to get from the // top left corner to the bottom right, following a path of 1s. // Prints the path of the final solution as it is discoverd. //******************************************************************** / public class Maze { private final int TRIED = 3; private final int PATH = 7; private int[][] maze = { {1,1,1,0,1,1,0,0,0,1,1,1,1}, {1,0,1,1,1,0,1,1,1,1,0,0,1}, {0,0,0,0,1,0,1,0,1,0,1,0,0}, {1,1,1,0,1,1,1,0,1,0,1,1,1}, {1,0,1,0,0,0,0,1,1,1,0,0,1}, {1,0,1,1,1,1,1,1,0,1,1,1,1}, {1,0,0,0,0,0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1,1,1,1,1,1} }; private int[][] grid; //----------------------------------------------------------------- // Creates a working copy of the maze to compute the final solution. // The original maze is not modified. Calls traverse to recursively // traverse the maze. //----------------------------------------------------------------- public boolean traverseMaze (int row, int column) { // make copy grid = new int[maze.length][maze[0].length]; for (int i = 0; i < maze.length; i++) for (int j = 0; j < maze[i].length; j++) grid[i][j] = maze[i][j]; return traverse(row, column); } //----------------------------------------------------------------- // Attempts to recursively traverse the maze. Inserts special // characters indicating locations that have been tried and that // eventually become part of the solution. //-----------------------------------------------------------------

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern