Design or generate a new maze for the MazeSearch program in this chapter, and rerun the program. Explain the processing in terms of your new maze, giving examples of a path that was tried but failed, a path that was never tried, and the ultimate solution.
What will be an ideal response?
or a 0 in each cell of a two-dimensional array. Because the likelihood of generating a maze with a solution is generally low, subsequent mazes could be generated using a while loop until a maze with a solution is generated.
A maze with a solution could be hard-coded with the following statement:
private int [][] grid = {{1,0,1,0,1,1,1,1,1},
{1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1},
{1,1,1,0,1,0,1,0,1},
{0,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1},
{1,0,1,1,1,1,1,0,1}};
After the search arrives at position (5,0), it attempts position (6,0). Encountering a 0 causes this path to fail. It then attempts position (5,1) which succeeds. Subsequently, position (6,1) fails and position (5,2) succeeds.Because the maze is traversed successfully from position (5,2), no attempt is ever made to find a path from position (4,1). The following grid shows the solution path marked with 7s.
7 0 1 0 1 1 7 7 7
7 0 1 0 1 0 7 0 7
7 0 1 0 1 0 7 0 7
7 0 1 0 1 0 7 0 7
7 0 1 0 1 0 7 0 7
7 7 7 0 1 0 7 0 7
0 0 7 0 1 0 7 0 7
1 0 7 0 1 0 7 0 7
1 0 7 0 1 0 7 0 7
1 0 7 0 1 0 7 0 7
1 0 7 7 7 7 7 0 7
You might also like to view...
Long lists of items can be divided into several ____ to fill the placeholder width and maximize the slide space.
A. bullets B. placeholders C. columns D. none of the above
To select all of the artwork on one layer, click the Select All button.
Answer the following statement true (T) or false (F)
____ is application software that makes people more productive by automating common or repetitive tasks.
A. Productivity software B. Utility software C. Operating system software D. Shareware
Which of the following is a long double literal with a value of 3.14159?
A. 3.14159 B. 3.14159f C. 3.14159L D. 3.14159LD E. 3.14159LL