15-112 Spring 2012 Homework 8
Due Sunday, 25-Mar, at
10pmRead these instructions first!
- Parts of this homework are SOLO
and other parts are COLLABORATIVE
(see hw1 and the syllabus for details). Be sure to know which is which, and
when you do collaborate, be certain to list the names and andrew id's of
each collaborator. You may collaborate with different students on
different questions.
- Create a directory named hw8, and place every required file (as
specified below) in that directory. To submit, zip that directory into
the file hw8.zip, then submit just that one zip file.
- If you do not know how to zip a directory, contact a CA at office hours
for help (ideally, more than a few minutes before the due date/time).
- Be sure to zip the directory. Do not create a rar file, or
a tar file, or any other kind of archive. Just zip. Again, if
unsure, contact a CA at office hours for help.
- There are no starter files or public or private autograders this week.
- Grading for this homework may be extrapolated based on randomly-selected
portions of your submissions. However, if we notice any missing
portions, these will of course be deducted in any case.
- Up to 10 points in style points may be deducted from your score on this hw.
So use good style!!!
- Midterm1 reprise
- Fall-11 Midterm1 reprise
- Snake Tutorial
- More Snake
- Lunar Lander
- 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.
- 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".
- 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).
- 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:
- A simple splash screen at startup (listing the game name and
your name and andrew id).
- 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).
- 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.
- 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).
- 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:
- Speed-up: make the game move noticeably faster, but
not unplayably faster.
- 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.
- 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