UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 - Project 1

A-Maze-ing - Maze Solver

Assigned Sunday February 12, 2006
Design Due Sunday February 19, 2006
Program Due Sunday February 26, 2006 at 11:59pm
Updates

Objectives


General Project Description

As an employee of Childrens' Games, Inc., you have been tasked with the responsibility of demonstrating that all of the mazes that have been generated for the new Maze & Puzzle book are indeed solvable. Fortunately, another developer has created an application that generates "perfect" mazes. It is your responsibility to double-check each maze that the application generated so that children around the world will have brighter lives when they receive the Maze & Puzzle book as a gift.

Project Description

For the first phase of the project, your boss requires that you implement the following components of functionality:

Maze File

The file that stores the maze is formatted as follows: <Nbr of Rows> <Nbr of Columns> <Maze row 1> <Maze row 2> ... <Maze row n> The following guarantees can be assumed about the maze files we will use to test your application:

User Interaction

The system is required to request the filename from the user. After processing the file, the system is required to ask the user if there is another maze to check. The user should reply with 'y' or 'Y' if there is, and anything else if there is not. If the user would like to continue, then the system should request another filename and repeat the above. This must be the only input requested from the user. There are no guarantee made about the existence of this file or whether there is anything at all in the file. However, if there is anything in the file, it will be guaranteed to be formatted as above.

If the user supplies a non-existant file or empty file, the system should continue to reprompt for another filename until the user supplies an existing file that has a maze in it. The system should NOT prompt the user for a 'y' or 'Y' to process another maze at this point.

Solving a Maze

There is a relatively simple algorithm that can be used to guarantee finding a solution to any maze that has a solution. The basic strategy is called the "right-hand rule" - if you were walking the maze, you simply keep your right hand in contact with a wall at all times. It requires some retracing of your steps as you continue through the maze, but it guarantees that you will find the End of the maze if it exists and is accessible from the Start position.

There are a variety of methods and algorithms for implementing this strategy, but one algorithm that you may use is:

Until you find the end square or return to the start square In the current square, facing in the direction you were previously heading, If you can go right, do so otherwise, if you can go forward, do so otherwise, if you can go left, do so otherwise, turn around and go back one square The algorithm above is described with respect to the direction you are currently heading. So, let us say that North is "up" in the maze, if you are currently heading North, then when deciding which square to travel to next you will first try to head East, then North, then West, then South in a counter-clockwise motion. If you were originally heading South, then you would attempt to go West first, then South, then East, then North. You should notice that because of the guarantee that the start position will be unique and surrounded by exactly 3 walls, it will not matter which direction you choose initially.

There are many different ways to represent the data in this algorithm, use one that makes sense to you. Enumerated types (C++ Primer lesson) might provide a handy notation for determining which direction you're heading and which one you want to go next.

You must implement the right-hand rule for solving these mazes.

Design and Implementation Requirements

Functions

This project is designed to give you ample opportunity to explore, experience, and use functions with a variety of different styles of parameters. You MUST use functions in this project whenever possible. If your main function is longer than 25-50 lines or so - it is probably too long - you need to break it apart. However, if your functions are all less than 5 lines, or several look very similar, you may need to rethink/combine them.

Example Input and Output

Examples have been provided in Ms. Wortman's public directory for this project (location listed below).

Example Program Execution

linux2[18]% Proj1 Please enter the name of the maze file maze21x21.txt * * * * * * * * * * * * * * * * * * * * * * S * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * E * * * * * * * * * * * * * * * * * * * * * * Maze Solved! * * * * * * * * * * * * * * * * * * * * * * S * x x x * * * * x * x * x * * * * * * * * * * * * x * x * x * * * * * * x * x * x * * * * * * * * * * * * x x x * x * * * * * * * * * * * x * * * * * * * * * x * x x x * * * * * * * x * x * * * * * * * * * * * * * * * * x * x * x x x x x x x * * * * x * x * x * * * * * x * * * * * * * x * x x x * x x x * x * * * * * x * * * * * x * x * x * * * * * * * x x x * x x x * x * x * * * * * x * x * x * * * * * x * * * * * * * x * x x x * x x x * x * * * * * x * * * x * x * x * x * * * * * * * * x x x * x * x * x * x x x x x x x * * * * * x * x * x * x * * * * * * * x * * * * x x x * x x x * x x x x x x x x x x E * * * * * * * * * * * * * * * * * * * * * * Would you like to solve another maze? Y Please enter the name of the maze file maze5x5.txt * * * * * * S * E * * * * * * * * * * * Maze Solved! * * * * * * S * E * * x * x * * x x x * * * * * * Would you like to solve another maze? y Please enter the name of the maze file maze_noSol.txt * * * * * * * * * * * * * * * * * * * * * * S * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * E * * * * * * * * * * * * * * * * * * * * * * Unsolvable! * * * * * * * * * * * * * * * * * * * * * * S * x x x * x x x * x x x x x x x x x * * x * x * x * x * x * x * * * * * * * x * * x * x * x * x * x * x * x x x x x x x * * x * x * x * x * * * x * x * * * * * x * * x x x * x * x x x * x * x * x x x * x * * * * * * x * x * x * x * x * x * x * x * * x * x x x * x * x x x * x x x * x * x * * x * x * * * * * * * * * * * * * x * x * * x * x * x x x x x x x x x * x x x * x * * x * x * x * * * * * x * x * x * * * x * * x * x x x * x x x * x * x * x * x x x * * x * * * * * x * x * x * x * x * x * * * * x x x * x x x * x * x * x * x * x x x * * x * x * x * * * * * x * x * x * * * x * * x * x x x * x x x * x * x * x * x x x * * x * * * x * x * x * x * * * x * * * x * * x x x * x * x * x * x x x x x x x * x * * * * x * x * x * x * * * * * * * x * * * * x x x * x x x * x x x x x x x x x * E * * * * * * * * * * * * * * * * * * * * * * Would you like to solve another maze? N

Example Maze Files

21 21 * * * * * * * * * * * * * * * * * * * * * * S * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * E * * * * * * * * * * * * * * * * * * * * * * 5 5 * * * * * * S * E * * * * * * * * * * * 21 21 * * * * * * * * * * * * * * * * * * * * * * S * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * E * * * * * * * * * * * * * * * * * * * * * *

Data Structures

General Tips


Project Design Assignment

Your project design document for project 1 must be named p1design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj1 p1design.txt Remember - the design is due ONE WEEK before the project. Late designs will not be accepted.

Project Makefile

The "make" utility is used to help control projects with large numbers of files. It consists of targets, rules, and dependencies. You will be learning about make files in lab. For this project, the makefile will be provided for you. You will be responsible for providing makefiles for all future projects. Copy the file makefile from Ms. Wortman's public directory to your directory.

When you want to compile and link your program, simply type the command make or make Proj1 at the Linux prompt. This will compile all necessary .cpp files and create the executable named Proj1.

The make utility can also be used for compiling a single file without linking. For example, to compile Proj1.cpp, type make Proj1.o.

In addition to compiling and linking your files, make can be used for maintaining your directory. Typing make clean will remove any extraneous files in your directory, such as .o files and core files. Typing make cleanest will remove all .o files, core files, Proj1 executable and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you receive with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the
CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first C++ program, pay particular attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your file header comments
  2. Your function header comments (particularly pre- and post-conditions)
  3. Function and variable names
  4. In-line comments
  5. Code readability
  6. Limiting variable scope

Project Submission

Steps for Submission

  1. submit all files
  2. submitls to verify they are in the remote directory
  3. submitmake to build your files remotely
  4. submitrun to run your files remotely
Assuming you've used the recommended file names, then to submit your project, type the command submit cs202 Proj1 Proj1.cpp Proj1Aux.cpp Proj1Aux.h Makefile The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project (using the makefile) are listed. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj1

Be sure to build your project once it has been submitted using the submitmake command, so that you know that all of the files are there and are the most up-to-date versions:

/afs/umbc.edu/users/d/a/dana3/pub/CMSC202/submitmake cs202 Proj1

Test your program to ensure that all files are the most recent versions:

/afs/umbc.edu/users/d/a/dana3/pub/CMSC202/submitrun cs202 Proj1

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!

Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Sunday, 12-Feb-2006 15:44:32 EST