TestMaze.txt: StdDraw can be found at http://introcs.cs.princeton.edu/java/stdli
ID: 3682006 • Letter: T
Question
TestMaze.txt:
StdDraw can be found at
http://introcs.cs.princeton.edu/java/stdlib/StdDraw.java
For this question, you will modify the provided ASQ2Template.java file to find the shortest path in a Maze the input file to test the maze will also be provided). This is similar to the maze program that you saw in class (or soon will see). Rename the class to A5Q72. First, you need to add the required code to explore all the paths in the maze and select the one with smallest length as the result. The solve method explores all possible paths, but does not 'remember' the shortest path seen. You will add that by updating a global variable called bestsolution. You will also add a random element to the recursive search used in solve. The solve method always searches for the next move in the same order (as defined in the global variable directions). Instead of always starting at index 0 in directions, choose a different starting index randomly. You should keep the solve method signature intact and only modify the body of the solve method. The locations where you should add or modify code are marked with comments.Explanation / Answer
public static void main(String[] args) throws Exception { Scanner scan = new Scanner(new File("maze.txt")); Scanner user = new Scanner(System.in); int rows = scan.nextInt(); int columns = scan.nextInt(); int px = 0; int py = 0; String [][] maze = new String[rows][columns]; String junk = scan.nextLine(); for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.