Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java programming The following grid of hashes(#) and dots( ) is a 2D array representation of a maze The hashes represent the walls of
In Java programming
The following grid of hashes(#) and dots( ) is a 2D array representation of a maze The hashes represent the walls of the maze and the dots represent the possible paths through the maze. Moves can only be made to a location in the array that contains a dot. Algorithm Explanation There is a simple algorithm for walking through a maze that GUARANTEES finding the exit (assuming there is an exit). If there is not an exit, you will arrive at the starting location again. Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. As long as you do not remove your hand from the wall eventually you will arrive at the exit of the maze. If you follow the algorithm. What to do: Write a program to walk through the maze. You must write a recursive function. The function should recieve as arguments 12-by-12 character array representing the maze and the starting point (x, y location in the maze). As the function attempts to escape from the maze it should place an X for the current path taken. The program should display the maze at each step so you can watch as the maze is solved. Put an X where you have traveled and maybe an O where you currently are located. The end of the maze will be a capital F' (stands for finished). This algorithm doesn't work for all mazes. Can you come up with a maze where this doesn't work? Rules you must follow: Recursive Algorithm, must use recursive method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started