Final Homework Project - Timmy Finds The Exit

Final Homework Project

In the previous homeworks we have done a few mini-projects where I have done most of the top down, modular design and some (increasingly less) of the module implementation for you. Now it is your turn. In this project I only give you the specification for what the program must do. It is up to you break the problem down into "bite-size" modules, decide what data structures and functions you will need for these modules, and implement them. You should also create your own makefile for compiling your program. As with the previous homeworks, this is a team project, with one set of files submitted per team.

Timmy Finds The Exit (TFTE) - the Spec

The program you will design and build implements a game called Timmy Finds The Exit. This is a one player game (you against the computer) using a "fancy" display, similar to the Calculator, Bowling, or Darts Projects

In TFTE, your player, Timmy, is located on one side of a 8 by 10 cell area minefield. Your task is to move Timmy safely through the minefield to find a secret exit that is not visible. You earn points if you move and you will earn a large amount of points if you find the exit. If the player moves on to a spot where there is a mine, Timmy dies and the game should reset if the player chooses to continue.

                          o |   |   |   |   |   |   |   |   |
                          Y |S 1|   |   |   |   |   |   |   |        MINES
                         ---|---|---|---|---|---|---|---|---|---           
                            |   |   |   |   |   |   |   |   |        |    | 
                         S  |S 2|   |   |   |   |   |   |   |        |    | 
                         ---|---|---|---|---|---|---|---|---|---
                            |   |   |   |   |   |   |   |   |
                         S  |   |   |   |   |   |   |   |   |
                         ---|---|---|---|---|---|---|---|---|-       FLAGS
                            |   |   |   |   |   |   |   |   |              
                         S  |S 1|S 1|   |   |   |   |   |   |        |    | 
                         ---|---|---|---|---|---|---|---|---|---     |    | 
                            |   |   |   |   |   |   |   |   |
                         S  |S  |S  |   |   |   |   |   |   |
                         ---|---|---|---|---|---|---|---|---|---
                            |   |   |   |   |   |   |   |   |        SCORE
                         S  |S  |S  |   |   |   |   |   |   |        _    _
                         ---|---|---|---|---|---|---|---|---|---    | |  | |
                            |   |   |   |   |   |   |   |   |       |_|  |_|
                         S  |S  |   |   |   |   |   |   |   |
                         ---|---|---|---|---|---|---|---|---|---
                            |   |   |   |   |   |   |   |   |
                         S  |S  |S  |   |   |   |   |   |   |

Moving Around

To move about in the field, you use the keyboard. You can move Timmy in any of the 8 directions from his current position by using the 8 keys surrounding the 'j' key:

                                y | u | i
                                --|---|--
                                h |   | k
                                --|---|--
                                n | m | ,

As Timmy moves through the field, he indicates safe cells (cells known to not contain a mine) on his map. The safe cells should show the value of timmy's proximity probe at that cell. (read more about the proximity probe below in detecting mines). Basically the safe spots should show how many mines there are in the 8 cells surrounding that spot.

Detecting Mines

To help Timmy find his way through the mines, he is equipped with a "proximity probe" which tells him how many mines there are in the 8 cells surrounding him (today's modern Army has all the coolest gadgets). Unfortunately, the probe cannot tell him where those mines are, it will just show how many.

Planting Flags

However, Timmy is also equipped with a limited number of hi-tech indicating flags to use to indicate cells to avoid by others behind him. He may plant a flag (using the keyboard) in any of the 8 surrounding cells when he suspects there is mine there. The keys to plant a flag are the shifted versions of the movement keys:

                                Y | U | I
                                --|---|--
                                H |   | K
                                --|---|--
                                N | M | <

When planted, the flag will indicate whether there is a mine there or not.

Earning Points

Timmy earns 1 point for each new safe cell he finds by moving into it. In addition, he earns 2 points for each flag he plants correctly in a cell that contains a mine. However, he loses 1 point for each flag he plants in a cell that does not contain a mine.

If Timmy successfully finds an exit, he earns a bonus of 10 points.

The game ends when Timmy finds the exit or gets blown up by stepping on a mine.

Win Condition

Besides mines being randomly generated on the field, there should be one random spot that is the exit. If the player navigates to that spot they win. And the game ends.

Field Set-up

When the game begins, the computer randomly places a number of mines in the field and issues Timmy the same number of flags (how many mines and flags to place is explained below). In addition, some of Timmy's predecessors have already mapped some of the safe cells in the field. The number of known safe cells is a random amount, however, it will never exceed 20 cells. These known safe cells (for which there are no points) are always as far to the left of the field, and always adjacent to other safe cells in the same row or the left boundary of the field.

The number of mines in the field is determined by the level of difficulty the user chooses to play. The levels are:

Level - # of Mines / # of Flags

Easy - 6/6

Hard - 16 / 16

The player may choose to play the game as many times as they want (with new minefields and Timmy's each time) At the beginning of each game, Timmy starts in the upper left cell of the field.

Implementation Hints and Help

You should think about this project before you attempt to write any code.

  • What modules will you need?
  • What does each do?
  • What data structures will you use to represent the information needed to proceed with the game?
  • What functions will you need?
  • What kind of information should they be given and what should they return?

USE THE FIVE STEP DESIGN PROCESS

Then you should begin tackling the modules one by one; writing the algorithms for the functions and then coding them in C and testing them. Remember to develop and test your program incrementally like we did for the calculator - using your own "throw away" drivers to test. (You may turn these in, and we MAY look at them, but we are primarily interested in the final product).

One of the more difficult modules to implement in this program is the display module. So, I will join your software team and help you write that module. You will find a header file with the prototypes of the functions I provide in:

With the object module containing the code in

            ~ee160/Code.lect/TFTE/display.o

You will also find a sample executable in that directory to see how the game should work.

There are several different approaches to the implementation of this game. Most of the C things you will need we have already been covered (and a few others will be covered soon).

START RIGHT AWAY.

This is a significant project; comparable in size to the calculator. You have about 4 weeks to complete it (overlapping with hw4). With the REQUIRED 6 hours per week per member of your team outside of class, plus the lab times during the last partial week of the semester, there should be plenty of time to complete this project. However, DO NOT WAIT TILL THE LAST WEEK or you will not get it done. NO LATE PROJECTS WILL BE ACCEPTED. Starting early will also give you time to experiment and try different approaches. Don't be afraid to abandon a working module for a better, more modular, approach.

DOCUMENT EARLY AND OFTEN.

A significant part of the grade for this project is based on your style and documentation. Writing your code properly formatted and commented with the steps of your algorithm from the beginning will save you a lot of time in the end.

START SMALL AND BUILD UP.

The project is rather "under-specified". There are many additional features and capabilities you can add, and some "reasonable" engineering decisions you will need to make, however, these are considered "Frills" (including robustness), and not worth as much as a well organized, formatted and documented program that compiles and meets the basics of the spec.

What You Turn In

You will submit ONE copy of all of the files for this project per team all at one time. So transfer the version of your files your team wants to submit to your coordinator for this assignment, and the coordinator will send them in. I recommend the coordinator put all the files for this problem in a separate Project directory. (It might be a good idea to compile and test them one last time before sending them in to make sure they work). Please DO NOT send different files from different members - we do not want to hunt around to find all of your team's programs. Use the "grade" command to turn in all of the .c and .h files and the makefile needed to compile your program (we will simply run "make" to compile your project) Your grade command will look something like the following:

If you are in Section 001, use:

            grade -5s1,ee160 *.c *.h makefile

If you are in Section 002 use:

            grade -5s2,ee160 *.c *.h makefile

If you are in Section 003 use:

            grade -5s3,ee160 *.c *.h makefile

If you are in Section 004 use:

            grade -5s4,ee160 *.c *.h makefile

You should verify that you turned in things successfully, which you can do with the command (which simply leaves the file names off from the previous command).

            grade -5s1,ee160
 
            OR
 
            grade -5s2,ee160
 
            OR
 
            grade -5s3,ee160

            OR
 
            grade -5s4,ee160

NOTE: after the files are prepared for grading, you will no longer be able to see your file listing using the above command.


Ratings

In addition, as with previous homeworks, each member of the team should send me a confidential email evaluating the effort of the team using the rating form provided. You MUST include comments at the end of the form describing what parts of the programs where done by each member of the team, including yourself, and an assessment of how teamwork was used to complete this assignment. This evaluation WILL be used to adjust the individual homework grades for your project. Your evaluation is due at the same time as the assignment. NO LATE EVALUATIONS WILL BE ACCEPTED. If you do not email your eval on time, your homework grades will be adjusted based on your teammates' inputs and your voice will not be heard. In addition, your individual score will receive an automatic 10 point penalty for not turning in the eval. Remember, this project is 10% of your course grade.

As usual, should you have any questions just send mail or stop by and see me or the TA.


HW Review with Instructor.

You must schedule time for your group to present you program to the instructor. Here is the list of features for this assignment.

  1. Menus
  2. Both difficulty levels
  3. Movement
  4. Movement off the edge not allowed
  5. Detector
  6. Flag Planting
  7. Flag Planting off the edge not allowed
  8. Win Condition

You can use this list to fill in the Project Review Sheet. Print out a copy of the sheet. Or make and print a sheet with the same format. Sheets must be printed. Fill in all the info required and bring the sheet with you to your scheduled review time.