Question: I need to write a program in C to solve text based mazes. The usage of the program is: mopsolver [-hdsp] [-i INFILE] [-o OUTFILE]

I need to write a program in C to solve text based mazes. The usage of the program is:

mopsolver [-hdsp] [-i INFILE] [-o OUTFILE]

where the options are:

-h print this help message stdout and exit

-d display the maze after reading (Default: off)

-s print shortest solution steps (Default: off)

-p print an optimal path (Default: off)

-i INFILE read maze from INFILE (Default: stdin)

-o OUTFILE write all output to OUTFILE (Default: stdout)

The entrance for the maze will always be (0,0) and the exit will always be (N-1, M-1) where n is the number of rows and m is the number of columns. We want to move from the top left of the maze to the bottom right. The format of the maze is one or zero seperated by a single space and each line ends with a newline right after the last digit, where 0 is an empty space and 1 is a wall. We can assume all rows contain the same number of elements. The data can come from standard input or a user specified file. An example of a maze would like like:

0 1 1 1

0 0 0 1

1 1 0 1

1 1 0 0

When given this input we must determine if it is solvable and be able to print out the solution. An example of the printed output would be:

|----------|

+ * * * |

| + + + * |

| . * + * |

| . * + + |

|-----------|

Where the + signs indicate the solution, . represents an open space, and * represents a blocked location.

We should put our code in a file called mopsolver.c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!