------------------------ Exercise #11 for CST8129 due December 8, 2005 ------------------------ -Ian! D. Allen - idallen@idallen.ca *********************************************************************** *********************************************************************** *** *** Final Version - posted Dec 5 *** *** See the sample script files under Notes for help with this exercise: *** *** interrupts.sh.txt, input_trap.sh.txt, parabolas.sh.txt, g*.sh.txt *** *** Also try running the sample lunar lander program I wrote here: *** *** ~alleni/bin/lunarlander *** *********************************************************************** *********************************************************************** Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Global weight: 6% of your total mark this term Due date: 23h00 Thursday December 8, 2005 (*** NEW DATE ***) Warning: Late exercises will not be marked before your final exam! The online deliverables for this exercise are to be submitted online via the T127 Linux Lab using the submit method described in the exercise description, below. No paper; no email; no FTP. Late-submission date: I will accept without penalty online exercises that are submitted late but before 18h00 Sunday December 11, 2005 After that late-submission date, the exercise is worth zero marks. Exercises submitted by the *due date* will be marked online and your marks will be sent to you by email after the late-submission date. (Warning: Late exercises will not be marked before your final exam!) This exercise is due at 23h00 Thursday December 8, 2005. Exercise Synopsis: Marks: 6% Write a terminal-based Lunar Lander game as a shell script. The game drops a lunar lander craft from a height. Gravity pulls the lander down toward the ground with a constant acceleration. Thrust from the lander counteracts gravity, pushing the lander up. Users will use SIGINT (usually CTRL-C) to interrupt the script to enter new thrust values. The lander does not have infinite or negative thrust - validate all input. The script loops until the lander hits the ground. If the lander is going "too fast", it is destroyed. The object is to touch down on the ground at a "safe" speed. When you run your lander in "test" mode (a command line argument of "test"), the lander never crashes (no matter how fast or how off-base it lands) and every landing is successful. You may attempt this script in one of three ways: Basic - C+ To earn a maximum of "C+" in this assignment, your lander game must handle the above requirements. The script will loop displaying lander height information as lines of text. No ASCII terminal graphics are required. Enhanced - B+ To earn a maximum of "B+" in this assignment, your lander game must allow the lander to move left and right (as well as up and down) and display the lander position using ASCII graphics on the current ASCII terminal. (See the Notes area for sample scripts that do ASCII graphics.) You must handle gracefully cases where the lander moves off the terminal screen. The user must navigate successfully to the "landing base" on the ground; landing off-base crashes the lander. Advanced - A+ To earn a maximum of "A+" in this assignment, your lander game must have several added features such as (for example) levels of difficulty, randomized start position, randomized initial vertical and horizontal velocities, a diminishing fuel supply, additional ASCII graphics that depend on outcome, visual cues when the lander is off-screen, satellites or mountains to avoid, other objects that have gravitational pull on the lander, use of ESC instead of CTRL-C to generate SIGINT, scrolling window that moves left/right if the lander moves off screen, etc. A sample of a simple Advanced-style lander with a (very) few added features is available in WT127 as: ~alleni/bin/lunarlander This file is is execute-only for you. Try it! For best viewing results, shrink the fonts in your terminal window and make it as many lines as possible before starting the program. I don't know if it is possible to land using levels "medium" or "hard". Try it and let me know. Your interrupt key is ESC. A Google search for "ASCII art" will find lots of ASCII graphics you can include in your program. The file g8.sh.txt crudely displays one such ASCII art image when it finishes. (Read the comment for a better way to display ASCII art.) Part I - PDL and code - weight 30% Part II - Test Plan - weight 40% Part III - Testing - weight 30% Where to work: Do your Unix command line work on any WT127 workstation. (You may login to the workstation remotely.) The files you work on will remain in your account after you log off. Do not erase your files after submission; always keep a spare copy of your exercises. WARNING: Do not attempt this exercise on a Windows machine - the text file format is different. You must connect to and work on Unix/Linux. Note that you may connect to a lab workstation *from* a Windows machine (using PuTTY); however, you may not use the Windows machine itself to do your work. Use the vim editor on the Linux machine. Location of the course notes on the Lab workstations: You can find a copy of all the course Notes files on any Lab workstation under directory: ~alleni/public_html/teaching/cst8129/05f/notes/ You can copy files from this directory to your own account for modification or study, if you like. (To avoid plagiarism charges, you must credit any material that you copy and submit unchanged as your own work.) Location of the textbook CDROM files on the Lab workstations: The CDROM files for the Quigley textbook are available in the WT127 Lab under the directory: /home/cst8129/ Exercise Preparation: A. Know where to find an online copy of all the course Notes on the Lab workstations. (See above.) You can get a copy of this exercise from the course notes. B. Complete the online Course Notes readings. Any questions? See me in a lab or post questions to the Discussion news group (on the top left of the Course Home Page). ------------------- Part I - PDL and coding - weight 30% ------------------- Write a properly structured executable shell script named "exercise11script.sh". Follow the style in Notes files script_style.txt and script_checklist.txt. The main loop of your lander is roughly: set lander starting parameters: position, ydelta, acceleration, etc. loop forever add acceleration to ydelta subtract thrust from ydelta add ydelta to y position display current position if lander position is on ground display success / failure messsage reset to starting parameters endif endloop Interrupts (SIGINT) will trigger code to modify the thrust value. If the user signals EOF to input, reset the screen and exit the lander. Modifications to X-delta can be done in a manner simlar to above; except, there is no acceleration due to gravity for X. --------------------- Part II - Test Plan - weight 40% --------------------- Following the test plan models of previous exercises, prepare a White Box test plan of your Lunar Lander, named "exercise11plan.txt". The aim of the White Box tests is to exercise every line of code at least once. This file must be a text file, not a word processor document. Please put your Assignment Label at the start of this file. The Test Plan must document a process by which someone unfamiliar with your code can test it to verify that the code works as expected. The Plan will document what input to provide and exactly what output to expect from the program. You may have to edit your program to insert temporarily particular values or starting conditions to test some of your statements. For example, if you print a particular message when your ship lands at exactly a certain speed, you may need to edit your code to "fake" that speed to test that message properly. Your test plan must document exactly how to make these temporary source code changes, and exactly what the outputs should be. (You may want to place comment blocks in your code indicating where certain tests would make temporary code or value changes.) --------------------- Part III - Testing - weight 30% --------------------- Apply your tests from Part II and document the results in a file named "exercise11results.txt". You may use "script" sessions or cut-and-paste screen captures, if that aids in making the results of various tests clear. This file must be a text file, not a word processor document. Please put your Assignment Label at the start of this file. The intent of the testing is to demonstrate to the reader that you have fully applied all the tests documented in the Test Plan from Part II and that each test is clearly shown to be a Pass/Fail. (Note that your code does not have to pass all its tests!) ---------- Submission ---------- Submit the finished and fully labelled files for marking using the following Linux command line: $ ~alleni/bin/copy11 exercise11script.sh exercise11plan.txt \ exercise11results.txt This "copy11" program will copy the selected files to me for marking. You can copy the files more than once. Only the most recent copies will be marked. Always submit *all* your files for marking at the same time. Warning: Late exercises will not be marked before your final exam! P.S. Did you spell all the label fields and file names correctly?