Question: Create a Java program that will access mazes. Below is an example maze. . . . . . 0 . . . S . .
Create a Java program that will access mazes. Below is an example maze.
S
F
The player starts at the location labelled S and wants to reach the finish, labelled F Each turn they choose one of the four cardinal directions to move. However, except for S and F the floor is covered in frictionless ice, so they will keep sliding in the chosen direction until they hit the wall surrounding the area, or one of the rocks labelled For example, starting in the map given above:
@
F
the player @ moving left would end up here:
@S
F
So we are dealing with the problem of finding a path from S to F but the reachability relation between points is not the usual one.
Tasks to be performed:
Implement a data structure which can represent maps such as the one in the example. It must provide the necessary infrastructure for finding a shortest
path from the start to the finish.
Add a simple parser which can read a map like the one in the example
from an input file. It needs to determine the width and height and the locations of the start and finish square as well as the rocks. The structure of the files will look like in the example, ie use SF for empty ice squares, rocks, the start and the finish.
Implement an BFS algorithm which finds a shortest path from the start to the finish in any given map, if one exists.It should output all the steps of the solution it found, eg for the example above:
Where the squares are numbered left to right, top to bottom.
Start at
Move left to
Move down to
Move left to
Move down to
Move right to
Move up to
Move right to
Move up to
Move left to
Move up to
Move left to
Move down to
Move right to
Move down to
Move left to
Move down to
Done!
Print the maze first then print the solution.
All the mazes are on separate txt file. like below
F
S
Provide complete implementation for each task. Print the maze first then print the solution.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
