Author: Ben Stephenson (ben.stephenson@ucalgary.ca)
The actual student handout from fall 2017: PDF Word
Summary | The Code Crusher assignment has students implement the game logic for a computer science themed match three game similar to Candy Crush. The starting materials provide a polished game interface that is platform independent. Students end up with a fully functional game once they complete the game logic functions. |
Audience | I have used this assignment as the third of four assignments in a programming intensive CS1 course that takes an objects-late approach. It can be used whenever students are being introduced to functions and 2D lists. |
Difficulty | Students found this assignment to be moderately difficult because it was the first assignment where they were required to write their own functions and it was their first assignment involving lists. I gave the students between 2 and 3 weeks to complete the assignment and my impression was that this was appropriate. |
Topics | The assignment focuses on functions and 2D lists. Students also need to write loops and if statements which I assume they are comfortable with from prior assignments that focused on such. |
Strengths | Students that complete the assignment end up with a fully functional game. The provided code includes a polished user interface, including animation, which allows students to create something that looks much like the games that most students play. Students also learn the importance of writing functions to a specification because many of the functions that they write are called by the provided code. As a result, their functions must take the parameters described by the specification and return the specified result in order for their game to work correctly. |
Weaknesses |
This assignment has students add to a substantial existing code base.
The provided code runs a collection of test cases over the students'
functions before the game starts so that the students are forced to
correct most bugs before attempting to play the game but this does
not guarantee that the student's functions are correct. While our
code tries to respond to incorrect behavior in the student written
code without crashing, it does not always succeed at this.
Adding to a substantial code base can be intimidating for some students. |
Dependencies | The user interface is built using our SimpleGraphics module, which is a wrapper for Python's standard TKInter graphics module (and is included in the materials we have provided). The provided code executes successfully with Python 3 on Windows, MacOS and Linux. |
Variants |
We chose to provide students with the code needed to remove the game
pieces when a match is made because there are actually many different
cases that need to be considered for lines of 4 pieces, and lines,
L-shaped groups and T-shaped groups of 5 pieces. The provided code
could be reworked so that students are required to write this code to
make the assignment more difficult. Similarly, students could be
asked to write other provided game logic functions like determining
how many blank spaces there are below a piece, how many non-blank
spaces there are above a piece, etc.
Candy Crush includes many elements that are not included in our game that make the gameplay more interesting (and the game more complex to implement). One could introduce any number of these elements to increase the difficulty of the assignment, or to vary exactly what students need to do to complete it from term to term. Examples of variations that could be implemented include:
|
My solution can be found here: code_crusher_complete.py. To run my solution place it, SimpleGraphics.py and sprites.gif in the same folder and run it with Python 3.x.