15-112 Spring 2012 Homework 8
Due Sunday, 25-Mar, at 10pm

Read these instructions first!


  1. Midterm1 reprise
  2. Fall-11 Midterm1 reprise
  3. Snake Tutorial
  4. More Snake
  5. Lunar Lander

  1. Midterm1 reprise
    This problem is COLLABORATIVE.  You may work in groups of up to 4 students (yourself included).  In the file named "midterm1-reprise.pdf" (yes, it has to be a PDF file!), first list your name and andrew id and those of your collaborators (if any).  Then, include all the answers to midterm1, including the work required to find those answers, and including the bonus problems.  For example, in the reasoning-about-code problems, you need to clearly (though very concisely) explain the logic and not just provide the answer.  Note: it is not acceptable for one student to solve all the problems and the others to copy down the solutions.  You must solve all the problems yourself, and you must type your own solutions in any case and not electronically share solutions with others.  Of course, you can and should work as a team to derive and understand the solutions, but you must be actively involved in each step and you must be sure that you fully understand all the solutions you submit.  That, after all, is the whole point of a reprise of these midterm problems!  Also note that you may use a Python interpreter to help confirm your answers before submitting.
     
  2. Fall-11 Midterm1 reprise
    This problem is COLLABORATIVE.  Repeat the previous problem, only providing answers to the fall11-midterm1, in the file named "fall-11-midterm1-reprise.pdf".
     
  3. Snake Tutorial
    This problem is COLLABORATIVE.  You may work in groups of up to 4 students (yourself included).  Carefully follow all the steps in this step-by-step Snake Tutorial.  Of course, you are ultimately given the answer in the tutorial.  Even so, while you may consult that solution, you may not simply copy and submit that version, but instead you must work through each step carefully and then submit the version that you typed in (and hopefully completely understood, from first principles) yourself, even if it is basically the same as the solution (as one would expect).  Submit the file "snake.py".  On the first line, list your name and andrew id and those of your collaborators (if any).
     
  4. More Snake
    This problem is SOLO.  In the file moreSnake.py, starting from the snake8.py file at the end of the Snake Tutorial, add the following features:
    1. A simple splash screen at startup (listing the game name and your name and andrew id).
    2. A pause screen (which is visible when the user presses 'p' for 'pause', and where the game resumes (exactly where it left off) when the user presses 'p' again).
    3. A score, which should be displayed at the top-center, above the board (which will have to be moved down by enough pixels to make room for the score).  The score should start at 0 for each game, and increase by 1 each time the snake eats food.
    4. A high score list, which should be displayed as part of the "Game Over" screen at the end of each game.  This is just a list of the 3 highest scores (during this execution; so if you exit and restart the program, the list is cleared), in sorted order from largest (on top) to smallest (on the bottom).  If there are fewer than 3 scores available, do not list the missing scores as 0's, but just do not list them at all (thus, you will list one score after the first game).
    5. Two levels.  Level 1 works just as described in the Snake tutorial.  But when the snake eats the 5th piece of food, the game switches to Level 2, with the following changes:
      1. Speed-up:  make the game move noticeably faster, but not unplayably faster.
      2. Poison:  in addition to randomly-placed food, a separate randomly-placed piece of red poison is placed on the board (and of course not on the snake nor on the food).  If the snake eats the poison, it dies.  Note that you must be sure the poison is not placed one square away from the snake's head unless that is the only location remaining.
         
  5. Lunar Lander
    This problem is SOLO.  In the file lunarLander.py, write a very, very simple Lunar Lander game.  The game starts with a ship (a rectangle) some distance over a planet (a line or wide rectangle, your choice).  Gravity (which need not abide perfectly by physics, though it should be close-ish) pulls the ship down increasingly faster.  The up arrow fires the rocket to resist gravity, either slowing the descent or, if held in long enough, actually propelling the ship upward.  There is no horizontal motion in the game.  The goal is to gently land the rocket on the planet.  If you land too hard, you crash and lose.  Also, you should run out of fuel at some point and then free fall, which probably will lead to crashing.  Provide some feedback indicating the score and the current fuel, and also indicating a safe landing or a crash.  The feedback can be very basic, but should be easily discernible.  After each landing, play again (and again and again).  Don't go too crazy with this.  Keep it simple.  And have fun!


carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem