For this project, write a C program that will find its way through a maze using the depth-first search algorithm.

computer science

Description

For this project, write a C program that will find its way through a maze using the depth-first search algorithm. This program takes input from a file where the filename is specified in the command line arguments. The input file will only contain two integer values per line of input:

• The first valid line gives the size of the 2-D maze (the number of rows given by the first number, then the number of columns given by the second number), valid values are >= 1 

• The second valid line gives the coordinates of the starting position in the maze 

• The third valid line gives the coordinates of the ending position in the maze 

• The remaining valid lines in the file give the coordinates of blocked positions in the maze


If the command line arguments do not contain a valid filename, you should print an error message to STANDARD ERROR and quit the program. This could be because there was not a name given or the name given did not match that of a valid file. If the command line arguments contains multiple names, we leave it up to you to come up with a “good solution”. Ideas on such a “good solution” could be:


• Use one of the names as the input file and proceed (pick which name makes most sense to use – i.e. use the first filename given or use the last filename given). 

• Give an error message stating that too many names were given and quit. 

• Run the program to solve the maze given with each filename.


The following shows an example of such an input file. The coordinates are given with the row listed first and the column listed second. A maze of NxM has rows numbered from 1 to N and columns number from 1 to M.


Related Questions in computer science category