|
CS-182 -- Lab 3: Maze Program Winter Quarter 1999-2000 Electrical Engineering and Computer Science Department CC-27C, 277-7339 PurposeThe purpose of this lab is to apply selection statements to complete an application. AcknowledgmentsThe 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. AssignmentYou 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:
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:
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:
Detailed instructionsIf you have difficulties with any part of the lab, consult the instructor for assistance. The basic sequence is:
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:
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. |