[MSOE Homepage]

Dr. Taylor's MSOE homepage

Unix is a Four
Letter Word

My Photo Album

My Personal Homepage

CS-182 Main page

CS-182 -- Lab 3: Maze Program

Winter Quarter 1999-2000



Electrical Engineering and Computer Science Department
Dr. Christopher C. Taylor

CC-27C, 277-7339

www.msoe.edu/~taylor/

Purpose

The purpose of this lab is to apply selection statements to complete an application.

Acknowledgments

The maze program was developed by Dr. Mark J. Sebern who was inspired by an idea developed by Richard Rasala and others at Northeastern University. Minor modifications were made to the program by Dr. Christopher C. Taylor.

Assignment

You have been asked to design and implement a computer program to navigate through a maze. You have been given an application that is complete except for the module that controls the maze navigation. Your job is to implement that module. Initially, the maze might look like this:

The red circle represents "your" position in the maze as you attempt to reach the target (the blue square). You may travel only on the white maze cells; the green cells are off limits.

[Note: the colors may not be distinguishable on black-and-white printouts of this page. Run the application or view this web page online to see the colors.]

The application program calls your module to determine what move to make next; the possible moves are:

  • Move left
  • Move up
  • Move down
  • Make no move (normally used only when you have reached the target)

If you navigate the maze correctly, the end result may look something like this:

The yellow squares indicate the path that you took to reach the target. Note that the final path may be different, depending on the method you use to navigate. The actual maze is generated "pseudo-randomly" and depends on the "maze number" value and the behavior of the random-number generator on your computer.

The code you write will be part of a function named DoMove. You will learn more about writing your own functions later in this course. For now, there are only a few things you need to know about functions, in order to complete this project.

The DoMove function can be found in the file maze2.cpp; the version you are given to work with looks like this:

MazeMoveType DoMove (int NumMoves, bool OnTarget,
                     bool OkLeft, bool OkUp, bool OkDown)
// Make the next move, based on the state of the maze.
// Parameters:
//  NumMoves - number of moves made so far (zero on first move)
//  OnTarget - true if current position is target cell
//  OkLeft   - true if it is legal to move left
//  OkUp     - true if it is legal to move up
//  OkDown   - true if it is legal to move down
// Returns:
//  MoveNone, if no move should be made (maze complete)
//  A move code (MoveLeft, MoveUp, or MoveDown),
//    if a move should be made
{
// This example code does NOT search the maze correctly!
// It is here so you can see something work until you put the
// correct code here.

  // Initialize move to "none", in case we decide the maze
  // is complete.
  MazeMoveType move = MoveNone;

  // If the current position is not the target cell,
  // decide what move to make.
  if (!OnTarget)
  {
    if (OkLeft)
    {
      move = MoveLeft;
    }
    else
    {
      move = MoveDown;
    }
  }
  return move;
}

The NumMoves, OnTarget, OkLeft, OkUp, and OkDown objects are special; they are called formal parameters. For now, you can treat them as regular data objects that are given values each time the DoMove function is called (each time your program code is supposed to decide how to make the next move in a maze).

The move object in the DoMove communicates your instructions on the move you choose to make. This object is of an enumeration (enum) type, with the following values:

// MazeMoveType enumeration
enum MazeMoveType { MoveNone, MoveLeft, MoveUp, MoveDown };
// This enumerated type is used to specify one of the possible
// moves in the maze: no move, left, up, or down.

Detailed instructions

If you have difficulties with any part of the lab, consult the instructor for assistance. The basic sequence is:

  1. Download the ZIP file containing the source code and other files necessary to build the application.
  2. Create a folder (e.g., c:\My Documents\cs182\lab3).
  3. Unzip the ZIP file into the created folder using WizUnZip on the warp network or a similar tool. With some tools (e.g., PKUNZIP), you may need to specify the "-d" option to create subdirectories for the Microsoft version of the files.
  4. Open the supplied project file (part of the ZIP archive) and build the application. You may need to adjust the project directory paths if you have made modifications to your MSVC60 setup on your own computer.
  5. Run the application. The example code in maze2.cpp will implement an incorrect version of the maze navigation.
  6. Design a navigation algorithm.
  7. Modify the body of maze2.cpp so that it implements your algorithm. Do not modify any other source files.
  8. Test the program.
  9. Extra credit: If the basic navigation is too simple for you, modify your program so that it visits every open maze cell before terminating. In other words, all initially white (open) cells should be yellow (visited) when your navigation terminates. Note that you must still end up at the target cell.

Lab report (due 11:00pm, the day prior to week 5 lab)

The lab report should be self-contained. That is, it should be possible for someone to understand what you did and why without seeing anything other than your report. Your report should include:

  • Purpose
  • Problem Statement
  • Procedure (include reasons for your design decisions, etc...)
  • Documented source code (just maze2.cpp)
  • Discussion (example maze traversals (see the Electronic submission guidelines for information on how to include graphic files in your report), problems you encountered, etc...)
  • A summary of your activity log indicating how much time you spent on each phase of the assignment. Please report the time in the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Documentation
    • Other
  • Conclusions (what you learned, suggestions of how the lab could have been better, things you would have done differently, etc.)

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

If you have any questions, consult the instructor.


This page was created by Dr. Christopher C. Taylor.