Requirement

You are to prepare a C++ program that accepts one command line argument. This argument will be the name of a file containing a maze. For example, if the name of your compiled program is a.out and the name of the maze file is maze1 then you would run the program as follows.

./a.out maze1

Maze File

The maze file is a text file made up of spaces for pathways, #’s for walls plus one ‘s’ and one ‘f’, representing the start and finish of the maze. For the maze to be well formed it must meet the following requirements

  • The maze must be surrounded by an unbroken perimeter of #’s. This means there are no paths on the inside of the maze leading to the outside.
  • The start and finish are both inside the maze.
  • After the final # in each line of the maze the next character is a newline.
  • There are no spaces within the maze that cannot be reached by moving down one of the maze paths.
  • There are no U shaped mazes. See diagram below.

The following is an example of a well formed maze file.

#######
# #############
######## ### # ###
# #f### ######### #
#s#### # # # ### #
### # ####### ### ### #
# #### # ### ###
# ########### ###
#### #####
###############

The following points can also be noted about the mazes

  • The maze can be any width and length and, as you can see, does not have to be rectangular.
  • When moving in the maze you may only move up and down and right and left. You may not move diagonally.

The following are examples of U shaped mazes and are not considered well formed.

### ### ####### ###
#s# #f# # # #s#
# #### # or # ### ### #
# # #f# # #
######## ### #######

Such mazes create problems since it's more difficult to work out what's the inside and what's the outside of the maze.

Program Requirements

Your program must do the following

  • Load the maze
  • Calculate some metrics about the maze
  • Print the maze along with the metrics
  • Free up all space allocated to the maze

Please see the Benchmark Program section below to learn exactly how the maze and metrics are to be displayed.

Maze Data Structure

You can assume that all test cases given to your program will be well formed but you will need to check for the following problems:

  • Multiple ‘s’ or ‘f’ in the maze.
  • ‘s’ or ‘f’ declared outside of the maze.
  • ‘s’ or ‘f’ not declared at all.
  • Invalid characters other than spaces, #, s, f or n.

When checking for invalid characters or f or s outside of the maze, you only have to check left, above and below the maze, not the right side. You will find this will make the assignment easier to code.

If you find a maze violation you will exit the program printing an error message stating you are unable to load the maze. Run the benchmark program below to see the exact format of the mess

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.