Sie sind auf Seite 1von 2

Project #1: Maze Solving Task 03 Coding the Solution Documentation

Problem : Algorithm for a robot to find the path from starting point to end point in a Maze. Solution : The usual way of finding the path in a maze by hand is by tracing the path from the starting point in the first spaced path, until a junction is found. When a junction is met, one can randomly select a path, and trace it until either the end point is met or a dead end is met. If a dead-end is met, the path should be retraced to the junction, and another path that has not been tried before must be tried until the end point is found. The same theory can be applied to finding the algorithm for the robot to find the path in the maze. The most important facts that must be considered in solving the maze are 1. Where the starting point is 2. Where the end point is 3. What are the possible moves, or where the spaces are (or the walls are) 4. What to do when a dead-end is met 5. And how to verify whether a given path has been followed before # # # # # # # . . . * # First of all the robot must locate its starting point. Once in the starting point, it can move 1 step in to any of the four directions as shown above, namely in west, north, east and south. We must command the robot to always follow a convention in selecting which direction to check first and next, etc. For example we can always ask robot to check the east and the go checking directions in anti clockwise direction, i.e. east, north, west, and south direction. So once we decide in which direction to check, we must then decide what to look for first, a space, an ending point, or whether a path had been followed at least once. Obviously before checking for any spaces, we must make sure our next step is not

# # . # # # # o . . . #

# # # # # #

directly in to the ending point in all four direction. Because once we locate our end point, our search is over. # # # # # # # . . . * # Say that in all four directions, theres no ending point from where we stand, at the Starting point. Then, we must look for a possible path or a space to move in all four directions giving priority to one direction at a time. For an example in the given maze below, well check one step to east first, where theres a space. Then we step in to that space, mark it so that we know its the path we followed, and check for another space from there. Even though we are at a junction, as we have given priority to direction, robot will next again chose the space in its east. So, in that way the robot will keep on going, marking its path till it comes to the dead-end. Once at the dead end, theres no possible spaces to be found in three direction, except for the path we # # # # # # # . . . * # followed so far in west direction. Therefore we have to give 3rd priority to check whether theres a space that had been marked or followed before. The robot must then follow the path he came before (backtrack), and mark the backtracked path, to # # # # # # # . ^ ^ * # # # ^ # # # # o ^ x x # # # # # # #

# # . # # # # o . . . #

# # # # # # # # # # # # # . . . * #

# # . # # # # o ^ . . #

# # # # # #

# # . # # # # o ^ ^ ^ # # # # # # #

make sure we do not go on that path again, till he come back the junction and chose another path. That way the robot keep choosing a path when it comes to a junction, follow it until it either find the ending point or a dead-end.

If it finds a dead-end, it will backtrack its path, come back to the junction and chose another path to take.

By E/08/248 M. N. T. Perera E/08/255 H. M. P. Prasadini

Das könnte Ihnen auch gefallen