CCSC: Midwest 2010 Nifty Tools & Assignments
Delvin Defoe, Matt Boutell, and Curt Clifton
Rose-Hulman Institute of Technology


Students work in teams of two or three to implement the Tetris video game. We provide a series of unit tests to help students write correct logic, and give them a very basic graphical interface. They write the logic for the piece movements and are encouraged to enhance their game by adding advanced features.

About Tetris

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 hits a stationary piece and stops. Once a piece stops, a new piece begins to fall.

The goal of the game is to position the pieces so that they fill complete rows (lines). 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 picture to the right is taken from the solution of a team of students.

An interesting discussion of the history of Tetris is available here.

Assignment Documents

Nifty Metadata

Summary PyTetris: Students will use startup code (includes template for model, controller, and text-based view) to implement and test the rules of the Tetris video game. They will then plug in and enhance the provided GUI.
Topics Basic object-orientation; code reading and extending; designing, implementing and testing a medium-size software project; model-view-controller design pattern; unit testing; team building, and team management.
Audience CS1
Difficulty Easy-to-intermediate. We typically assign it 2/3 of the way into our quarter-length CS 1 course, and give students 1.5 weeks to complete it.

This assignment beings together several concepts to which students are exposed at various points during CS1. It forces students to apply concepts like object-oriented design, object-oriented programming, functional decomposition, separation of concerns, and design patterns like model-view controller (MVC). It also gives them an opportunity to use and sharpen their code reading, code reuse, code modification, debugging, unit testing, team building, and team management skills.

The extensive unit tests help students write correct code. They can be confident their piece movement logic is correct before getting wrapped up in enhancing the GUI.

This project gives students the experience of developing a real game that uses a real GUI and animation. Our students have especially enjoyed the phases of the assignment that allow them to integrate the GUI in their project and add enhancements to it.

The team building experiences that our students receive is also rewarding. Such experiences prepare them for the real world, in which they will most likely work on projects in teams.

Weaknesses Students must first complete the text-based version of the game before plugging in the GUI. Some dislike that they must demonstrate that the text-based version of the game works before they can explore and enhance the GUI based version.

Our GUI uses a slightly-modified version of the graphics library that comes with John Zelle's Python Programming: An Introduction to Computer Science text. We only modified it to accept keyboard input. The part of our code that uses this is small and self-contained, and could easily be replaced with one built upon another library.

Students need to have a basic understanding of classes and how they interact with each other. This assignment also requires that students be able to read, understand, and modify code written by someone other than themselves. They must be able to convert a problem specification into code that actually solves the problem. Moreover, they must be able to work collaboratively in a group setting.


There is a lot of variability in the assignment. Students are given template code involving a set of classes and signatures to methods that must be implemented. The provided method signatures are the extent of the interclass dependencies. Beyond those, students are encouraged to use any sound approach to complete the implementation of the project.

Once students complete the basic version of the game, they are required to add some enhancements. There is a lot of flexibility in the number and complexity of the enhancements students can add. Better grades are awarded to students who add more challenging features.

Pedagogical Outcomes

The main pedagogical objectives for this project are:

Discussion of Unexpected Benefits

We have assigned games in the past where students spent countless hours initially getting their GUI perfect before they even thought about the game logic. In contrast, one of the most satisfying aspects was watching the students labor first to write correct code that passed all the unit tests, then experience the excitement of seeing the game come alive as they dropped in the vanilla GUI we later gave them.

Another highlight was seeing the students demonstrate their teams' final submissions to their classmates and explain what they learned. They were genuinely excited and proud about their work, especially given that they completed it in only 1.5 weeks, ending during the 7th week of class.

During the demos, some students commented that some of their code for various pieces was redundant. What a teachable moment to show off our concise solutions that used inheritance! Even though inheritance isn't part of our CS1 course, it piqued curiosity about CS2.

Contact Information

Delvin Defoe, Matt Boutell, and Curt Clifton
Department of Computer Science and Software Engineering
Rose-Hulman Institute of Technology
5500 Wabash Ave
Terre Haute, IN 47803-3999