Maze Solver Project by HImanshu Kashyap

AttainU
AttainU

Maze Solver

Aim:

The aim of this project is to build a python program that runs as a command-line tool. It should take the input and output file name as command-line arguments. Using the square matrix present in the input file it should generate a path to reach from source to the destination point of the maze and put it in the output file. If the maze is unsolvable, it should return -1 as the only value in the output file. In the maze matrix, 0 means the block is a dead end and 1 means the block can be used in the path from source to destination.

How to solve the problem :

Read the input matrix from the inputFile.txt and form a 2-D mtrix from it. In the given 2-D matrix cosider the position of the element as node where 1 is present and make a graph from it. Now check whether it is possible to reach from source to destination in the 2-D matrix with the help of 1's If yes find the position of all the 1's present in 2-D array and store them in a list say resultArray. Create another 2-D array say outputList and make each position which is present in resultArray as 1 and rest of the position as 0 Write the outputList in the outputFile.txt

Concepts used to implement the solution :

  • File handling
  • Graph
  • BFS
  • Dijkstra

 

Demo :