Creating a maze solving algorithm in Java

前端 未结 5 1355
萌比男神i
萌比男神i 2021-02-01 10:56

I\'ve been assigned with the task of creating a maze solver in Java. Here\'s the assignment:

Write an application that finds a path through a maze.  
The maze sh         


        
5条回答
  •  抹茶落季
    2021-02-01 11:43

    You probably should module your program - as I can understand it, you are reading the maze from file and trying to solve it at the same time.

    A better approach will be to split the program into 2 distinct parts:

    1. read the input file and create a matrix with all the data
    2. solve the maze from given matrix

    Doing so will help you to build and test each part seperately, which will probably result in better, more reliable program.

    Solving the maze could be done by a simple BFS, which is similar to what your algorithm originally suggested , which is a DFS

提交回复
热议问题