PyTetris
		
			Project Requirements 
		
		
			The goal of this project is to implement the Tetris video game in 
			Python in teams of two or three students . Rules for the game are given below. 
		
		
			Your project must satisfy the following core requirements: 
		
		
			- 
				You must design and implement a fully functional Tetris game including: 
				
					- 
						moving and rotating pieces 
					
- 
						allowing only legal moves 
					
- 
						detecting when the game is over 
					
 
- 
				Your project must use a graphical user interface (GUI) for game playing. (We 
				will provide lots of it, which you will modify.) 
			
- 
				You must implement 8 classes, one per piece type plus one for the playing board. You will be required to use an object-oriented design.  
			
- 
				All team members must 
				
					contribute to 
				
				and 
				
					understand 
				
				their project. 
			
			Most of the work on your project will be translating the rules 
			provided into a functional design and implementation. If you are 
			having trouble planning or getting started, get help. It is much 
			better (and easier) to get help early and start with a good plan 
			than to try to hack a poor design into a semi-functional program in 
			the final days before the project is due. 
		
		
			Milestones 
		
		
			To make sure that you are on-track to complete your project, you 
			must meet the following milestones. Each milestone will contribute 
			to your overall project grade. Each milestone must be completed 
			
				before 
			
			starting
				
			the next. 
		
		
			- 
				
					Milestone 1 — UML Class Diagram Sketch: A neatly drawn UML class diagram showing the user-defined classes for your program including instance variables and methods. This does not have to be (and likely won't be) your final design, just your initial plan. To get you started on the right track, we're requiring your design to include classes for each of the pieces, like 
				
					Tee 
				
				(explained below), and a class for the playing board. You should 
				ask yourself the following questions at the start:
					- What instance variables need to go in Tee? 
					
- What operations must it support? 
- What instance variables need to go in the playing board?  
					
- What operations must it support?
 The diagram can be hand-drawn or you may use a program to draw it. We
					strongly suggest that you draw your initial design on a whiteboard. Regardless of the way you choose to draw the diagram, 
					you must turn in a single plain white 8½ × 11 inch sheet of paper showing your final design. 
					This format is non-negotiable as we will be photo-copying your design.
- 
				
					
						Milestone 2 — Text-based version of piece motion. 
					
					You must demo this to your instructor before moving on to the GUI-based version. Also, make sure that you commit this version of your code 
					to SVN and state clearly in your commit message that the text-based version is done. 
				 
- 
				
					
						Milestone 3 — 
					Finish game including enhancements (see below). 
					  
- 
				
					Milestone 4 —  Demo your game to your 
					instructor and fellow classmates. 
- 
				
					Milestone 5 — Complete individual team evaluations.  
				
			
			Grading 
		
		
			Project grades will be based on both individual and group results. We will grade each project milestone, plus the final project program. Grading will include both the proper functioning of your program and an evaluation of your design, coding style, and documentation (including SVN commit messages). The grade will also depend heavily on what enhancements you add (see below). 
		
		
			Each team member will be required to complete an evaluation survey about his or her own performance and that of each of his or her teammates. We will use these surveys and our own observations to assign individual project grades. 
		
		
			About Tetris 
		
		
			Overview 
		
		
			Tetris is a one-player game in which pieces of various shapes fall from the top of the board, one at a time. The player can rotate the falling piece clockwise, move it left or right as it falls, or cause it to drop, until it stops by hitting a stationary piece. Once it does, a new piece starts to fall. The goal of the game is to position the pieces so that complete rows (lines) 
			are filled with pieces. This causes the row(s) to disappear, the rest 
			of the pieces above it(them) to fall, and points to be scored. Play 
			continues until there is at least one stationary piece at the top row of the board. The following picture is taken from 
			the solutions of a team of students. 
		
		 
		
			There is an interesting discussion of the history of Tetris 
			
				here. 
		
		
			Rules 
		
		
			Terminology 
		
		
			- 
				The 
				
					playing board 
				
				is the whole playing area. It consists of 10 columns and 18 rows of grid 
				
					cells, 
				
				for a total of 180 cells. In it are an 
				
					active piece that is falling and can be moved, and the 
				
					landscape 
				
				(a group of stationary, de-activated pieces at the bottom of the 
				board). When the landscape contains a complete row of 10 cells, a 
				
					line 
				
				is completed, the line is 
				
					cleared, and the landscape 
				above the cleared line 
				
					slides 
				
				down. 
			
			Piece Types 
		
		
			 
		
		
			There are 7 different pieces of various shapes. Note that each has the same area (4 cells).  Pictured are: 
		
		
			- 
				
					MrChunky 
				
				(Alright, 
				
					square 
				
				is confusing, 
				
					block 
				
				is too vague, and Dr. Clifton likes crazy names. When 
				
					you 
				
				teach the class, 
				
					you 
				
				can pick the names. :) ) 
			
- 
				
					Bar 
				
				(looks like a line, but the name 
				
					line 
				
				is already taken). 
			
- 
				
					Ell 
				
				(if you turn it upright, it looks like the letter L) 
			
- 
				
					Jay 
				
				(the letter J) 
			
- 
				
					Tee 
				
				(the letter T) 
			
- 
				
					RightZig 
				
				(sitting down, the top is on the right) 
			
- 
				
					LeftZag 
				
				(complementing the RightZig) 
			
The centroid of each piece is marked with a dot. We use this centroid to mark the position of the piece.  
	Also, 
	
		each pieces rotates around this point (except MrChunky, who doesn't rotate).
		Note that each piece, depicted above, is shown in its default orientation, that is,
	
		the orientation in which it starts 
	at the top of the playing board.
		Initial Game Setup 
	
	
		- 
			The board has 10 columns and 18 rows. 
		
- 
			All of the grid cells start empty. 
		
- 
			One of the 7 pieces is chosen randomly, and is placed on the middle top of the board. 
		
		Game Play 
	
	
		In each time step: 
	
	
		- 
			The player can rotate the active piece clockwise, move it left or right, or cause it to drop instantaneously until it can move no more (unlike the online version where the falling can be slowed again). 
			
				- 
					One may not be able to do all of these operations. For instance, if a piece is already touching the left wall, the player cannot cause it to move further left. Also, if rotating a piece would cause it to hit another piece or the wall, it is not allowed. Multiple moves are allowed, if the player can do them quickly. 
				
 
- 
			If there is empty space below the falling piece, the piece falls (moves down) 1 
			grid cell at a time. 
		
- 
			Otherwise, it has hit a stationary piece of the landscape. We then 
			check to see if one or more lines are completed. If so, we remove 
			the line and cause the rows above it to drop down. If not, we check to see if the game is over. The game is over when the landscape extends up to the top row. 
		
		To get a feel for game play, please play the basic solution we provide. 
	
	
		Suggestions 
	
	
		- 
			Plan first! Use top-down design and object-oriented design. Get help early if you need it! 
		
- 
			You'll want to follow the 
			
				model-view 
			
			approach that 
			Zelle uses in section 12.3. We'll provide you with lots of the GUI 
			once you show us you can manipulate the pieces. 
		
		Enhancements 
	
	
		Once you are done with the basic version, you will be required to add some 
		
			enhancements. You will earn a higher grade for doing more challenging ones, and the more, the better. 
		
		
		Here are some suggestions, to get you thinking. 
	
	
		- 
			Keep track of how many lines are cleared. 
		
- 
			Do advanced scorekeeping, such as awarding more points for clearing multiple lines at once. 
		
- 
			Highlight a row as it is being cleared. 
		
- 
			Add outlines to the pieces. 
		
- 
			Add sound effects using the 
			
				winsound 
			
			Python library. 
		
- 
			Display the next random piece to fall in an "on-deck" panel at the top of the screen. 
		
- 
			
				Be creative: what's cool and challenges you?