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

CMSC 202 - Project 5

Stars and Bars Maze Solver

Assigned Sunday April 30, 2006
Design Due Saturday May 6, 2006 at 11:59 pm
Program Due Sunday May 14, 2006 at 11:59pm
Updates
  • May 2 - BarCell class UPDATE: added End character, removed ability for start or end to be in the exterior wall
  • May 2 - If command-lines are incorrect - exit program
  • May 2 - Guarantees from previous projects still hold

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. 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

In this last iteration of the Maze Solver system, you will be required to use templates and exceptions to enhance your application to handle a variety of Maze formats and to more elegantly handle errors.

Functional Description

Basically, the functional requirements are the same as in previous projects. Maze guarantees from Project 4 still hold. Functional requirements from Project 4 also still hold, with the addition of a command-line variable.

Command-line Variables UPDATED!

Your application will accept one of the following parameters: STARS or BARS. We will run your application with one of the following lines: Proj5 STARS Proj5 BARS The STARS command-line variable indicates that you will use the star-based Maze. The BARS command-line variable indicates that you will use the bar-based Maze.

If the user enters something that you have not implemented on the command line, simply alert the user and exit the program. For example, if you have not implemented the extra credit, and the user attempts to use 'MAZE' on the command line, simply alert the user and exit.

STARS Maze

The stars maze is the format you are already familiar with, where the '*' character represents the walls and the 'S' and 'E' represent the start and end. The following is an example of a STARS maze: 11 11 * * * * * * * * * * * * S * * E * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

BARS Maze UPDATED!

This maze is formatted almost identically to the STARS maze except that each wall can either be one of any of these characters: '-', '_', '\', '|', '/'. The start can be either 's' or 'S' and the end is represented by a 'q' or 'Q'. The following is an example of a possible maze: 11 11 / - - - - - - - - - \ | | | q | | | | - - | | - - - / | | | S | - - | | - - - - / | | / - | | - - - - - \ | | | | | | | | | | \ - - - - - - - - - / Notice that in the BARS maze, you cannot make assumptions about the organization or placement of any of the wall characters.

Design and Implementation Requirements

You are not required to use dynamic memory for this assignment or polymorphism. However, the functionality requirements of the previous project (including the use of the three basic crawlers) must remain, but you need not retain the polymorphism if you didn't get it working.

Templates

You must use templates to support the solving of stars and bars mazes. You must create a new MazeCell class to support the new BARS mazes. Your Maze and MazeCrawler classes must be templated on these two mazecell classes. Let us pretend that you have named your MazeCell classes StarCell and BarCell. You must create Maze and MazeCrawler objects as follows (obviously with whatever variable names you would like to use, and wherever in your code they are appropriate): Maze<StarCell> maze; Maze<StarCell>* maze; Maze<BarCell> maze; Maze<BarCell>* maze; MazeCrawler<StarCell> crawler; MazeCrawler<StarCell>* crawler; MazeCrawler<BarCell> crawler; MazeCrawler<BarCell>* crawler;

Exceptions

You must convert all of your application code to support the throwing of Exceptions instead of your existing method of indicating errors. So whenever you have a function or method that returns an error condition or discovers a precondition that has not been met, it must throw an exception to be handled either by the calling code or some other function/method in the stack. You may handle the errors wherever appropriate, either in classes or in main or both.

You must also support a hierarchical organization of Exception classes, you must create at least three (3) exception classes. These can be as complicated or as simple as you require, but they should have names that reflect the error that occured. You may choose to inherit from the STL 'exception' class or simply define your own base-class.

Your Exception classes can be declared and implemented in a single pair of files named 'Exception.cpp' and 'Exception.h' (or any other names you like).

Extra Credit

You can implement neither, one or both of the extra credit components, but they will be graded "all or nothing".

Parameterized MazeCell Class (10 pts)

In addition to supporting the above templated types, you must create a completely parameterized MazeCell class that uses a collection of parameters to specify what characters are used for walls, the start and the end. You should use templates with multiple parameters to specify the following three key components of any MazeCell: You must implement this as a separate class from the StarCell and BarCell classes - so if you decide to implement this you will have three different MazeCell-based classes. Hint: look at the non-type template parameters.

You will accept a few command-line parameters in order to demonstrate the extra credit. The first is the keyword 'MAZE', followed by the wall character, the start character and the end character. Here are some examples:

Proj5 MAZE * S E Proj5 MAZE - Q W Proj5 MAZE | m H

Best-First Search (10 pts)

Add a 6th option for a Crawler, where the Crawler determines which direction to choose at each intersection by choosing the path that is "closest" to the end square. Distance from the neighboring cell to the end cell should be computed using the standard distance formula: distance = square_root((x2 - x1)^2 + (y2 - y1)^2) The Crawler should choose the neighboring cell that is both unvisited and closest to the End. If the Crawler reaches a dead-end, it should backtrack. This is a modified algorithm based on the Depth-first search strategy of the previous project. The essential idea is that when attempting to choose a neighboring direction, we believe that cells closer to the end are more likely to lead us to a solution - this is called a "heuristic" and is often used in Artifical Intelligence applications to make "wise" decisions. Heuristics are actually a class of estimation algorithms that justify a choice based on some numerical computation representing the likelihood that the choice is better than all others.

This Crawler should be selected with number '6' on your main programming menu. Its output should be like the Depth-First Crawler's output, 'x' or 'X' on the path found, 'b' or 'B' on the backtracked paths, and the number of squares visited (including start and end).

General Tips


Project Design Assignment

Your project design document for this project must be named p5design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj5 p5design.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 Proj5 at the Linux prompt. This will compile all necessary .cpp files and create the executable named Proj5.

The make utility can also be used for compiling a single file without linking. For example, to compile Proj5.cpp, type make Proj5.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, Proj5 executable and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.

You MUST use the /usr/local/bin/g++ compiler to compile and build each file. Do not depend on setting your default compiler to be this compiler, the grader may use a different compiler. There are two compilers on the GL systems, and you are required to use the one located at /usr/local/bin/g++. Also, you MUST be sure to use the same compiler for compiling ALL of your files - different compilers make different .o files and they will NOT play well together.


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.

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 Proj5 Proj5.cpp Proj5Aux.cpp Proj5Aux.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 Proj5

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 Proj5

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

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

Details on Submit Tools.

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: Tuesday, 02-May-2006 12:09:34 EDT