15-112 Spring 2016 Homework 7
Read these instructions first!
Both parts are due Sunday, 28-Feb, at 10pm
- This hw is partly COLLABORATIVE and partly SOLO. Be certain to understand which is which. Tetris is collaborative, and the rest is solo.
- Each part uses up to 1 grace and late day separately. Thus, if you submit them both parts on Monday, you would use 2 separate grace or late days.
- Starting this week, you may use graphics and event-based animation (of course!), but (as usual) you may not use constructs we have not yet covered (recursion, lambda functions (except in run(), etc), unless explicitly allowed below.
- This week there is no autograder. You may make up to 5 submissions of each part to Autolab. As usual, only your last one counts.
Hw7c: Tetris (COLLABORATIVE)
This portion of hw7 is "hw7c", where the "c" means "Collaborative". This problem (Tetris), and only this problem, is optionally collaborative. You may work in groups of up to 2 currently enrolled 15-112 students (yourself included), so do not work with more than one other student. Each student should submit their own work individually, submitted as part of hw7c. Include the name and andrew id of your groupmate, if any, at the top of your hw7c.py file. And as always with collaborative work, you must be actively involved in every part of your solution, and you may never simply copy any code from anyone, nor electronically share your code (email, FB, texting, etc) even with your partner.
- playTetris() [50 pts] [COLLABORATIVE]
Write Tetris according to the design given in this step-by-step tutorial using our event-based animation framework (starting with events-example0.py).
You may not use a different design, even if you think there's a better way to do it (there probably is, but you still have to do it this way). This may seem limiting, but sometimes you are given specs at Polya Step 1 (just indicating the problem to solve), and other times at Polya Step 2 (also indicating the algorithms to use). This is one of those second kind of specs. Your task is to do Polya Step 3, and write the corresponding code, and then using this week's event animation framework.
This portion of hw7 is "hw7s", where the "s" means "SOLO". All the problems on this portion are SOLO, not collaborative. You must work alone, as you have done on all previous hw's this semester.
- playDotsAndBoxes [50 pts] [SOLO]
First, read the Wikipedia page on Dots and Boxes. . Then, write the function playDotsAndBoxes(rows, cols, maxSecondsPerTurn) which will play a human-human Dots and Boxes game on a rows x cols board, but also not allowing more than maxSecondsPerTurn time to elapse on any give turn. If the time elapses, the screen should visibly flash and the player should lose that turn (though not the game). Your user interface can be simple, even quite plain, but it must be functional so two people can use it to play. It must display the board, make clear whose turn it is and where legal moves are, make it easy for players to enter moves, actually make those moves if legal (or reject them if illegal), display who has captured which boxes, alternate turns, display the score, detect game over, and print a suitable game over message. Don't forget about the maximum time per turn, too!
- bonus/optional: playBetterSnake [up to 2pts] [SOLO]
Separately from your version of snake for the problem above, write a new and improved version of Snake, playBetterSnake, included in your splashScreen options, with these additional features, all with a reasonably pleasing user interface:
- A score.
- A timer.
- Multiple snake lives.
- A high score file.
- A splash screen (at the start of the program), a game over screen, and a help screen.
These can be placed randomly, and snakes don't die when they hit walls, they just can't go through walls. So what happens instead? That's up to you. Just do something reasonable and interesting and fun.
- Eagles (they eat snakes)
Eagles start in a random location, but they move towards the snake, and if they get to the snake, they eat it and kill it. Don't make the eagles too aggressive nor too passive, or it won't be fun to play.
- bonus/optional: playSokoban [up to 3pts] [SOLO]
First, read the Wikipedia page on Sokoban. Then, write the function playSokoban() that plays the game. Do not use any images. All drawing must be with graphics primitives (lines, rectangles, ovals, etc). Also, do not use any sound. Besides that, design as you will. The nicer the game, the more points awarded. Have fun!