Goals

In this project, you will build a memory game that plays until a condition is met.

You will be practicing the following concepts from prior labs:


Summary

In this project, you will make a simple matching game using the graphics package. The idea is that users will click on cards one at a time, to flip them over to find pairs. The below video shows the final game and a demonstration of gameplay.

Due Dates


Getting Started

Download the following files into your PyCharm directory for Project 02:

Do not modify match_graphics.py.

The file icons.zip should be unzipped to create the directory icons/ which holds a series of .gif files. Do not rename these graphics or their parent directory, since the file names are listed in match_graphics.py. The directory icons/ needs to be in the same directory as graphics.py, as match_graphics.py and as your code.


Checkpoint A

For Checkpoint A, you will need to demonstrate a program that draws the game board with all the cards shown. You need to be able to display the following window to complete the checkpoint:
Screenshot of Checkpoint A

Specifically:

Hints:


Checkpoint B

Your Checkpoint B code needs demonstate the following:

Hints:


Final Code

In your final code, you will extend your Checkpoint B code. At this point, the game will mark matches, remember prior matches and detect when we have enough matches to declare victory. It should look just like the opening video in behavior.

Hints:

There is no demo for your final code. See the end of this specification for submission instructions.


Extra Credit

You can get up to 10 points total for extra credit. Extra credit is to create a second verson of the game that is extended or enhanced in some creative way. There are lots of possibilities. For example, you may select alternative game icons from http://game-icons.net (I converted these to 125x125 pixel GIFs to make the two icon sets provided above). You may also use different color schemes to create your own themed game, change rules, add scoring.

To qualify for extra credit you must (1) submit a version of your game without any extra credit enhancements, following the standard submission instructions below and (2) submit your customized game to the "Project 2 extra credit" assignment on Moodle as a single ZIP file containing all the files for your enhanced game. The enhancements must be described in the docstring of the extra credit version.


Grading Rubric

Checkpoints [20%]

Checkpoint demos are each worth 10 points; each is all or nothing.

Correctness [55%]

The most important part of your grade is the correctness of your final program. Your program will be tested numerous times, using different inputs, to be sure that it meets the specification. Attention to detail will pay off on this assignment. For details, see the rubric below.

Programming Design and Style [25%]

In addition to being correct, your program should be easy to understand and well documented. For details, see the rubric below.

Detailed Rubric

Correctness: functional features (55 points)

The following must be true to receive any points for the correctness aspects of the game:

Game Behavior (55 points)
5 pts.On game start, the board is drawn with all cards hidden.
5 pts.When the hidden card at coordinate (i,j) is clicked, the card at coordinate (i,j) is shown.
5 ptsThe 'first pick' stays shown until a 'second pick' is made, at which point both are visible for a brief period of time (after this, what happens depends on if they match).
5 ptsWhen the 'first pick' and 'second pick' match, they stay visible and get a red 'X' drawn over their faces.
5 ptsWhen the 'first pick' and 'second pick' are not a match, they are hidden again.
5 ptsA red 'X' is never drawn over unmatched cards.
5 ptsMatched cards stay visible and stay marked with an 'X' for the duration of the game.
5 ptsWhen making a 'first pick', the following actions are ignored: clicking in the margins of the board, clicking cards that are matched.
5 ptsWhen making a 'second pick', the following actions are ignored: clicking in the margins of the board, clicking cards that are matched, clicking any unhidden cards (like the 'first pick').
5 ptsThe winning condition gets detected when all pairs have been matched, and the you_won() function is called in this scenario.
5 ptsProgram exits without any error messages if the graphics window is closed.

Programming Design and Style (25 points)

Filename (1 point)
1 pt.Your program should obey the naming convention indicated in the assignment.
Docstring (3 points)
There is a docstring at the top of the submitted file with your name (first and last), the course (CS 115) and assignment (Project 2), and a brief description of the program.
1 pt.Your name (first and last)
0.5 pt.The course (CS 115)
0.5 pt.The assignment (Project 2)
1 pt.A brief description of what the program does
Function behavior (4 points)
Each function matches its description and each function implementation is not too long (no more than 20 lines of code).
-1 pt.Not true of one function.
-2 pts.Not true of half or fewer of the functions.
-4 pts.Not true of more than half the functions.
Function documentation (3 points)
You have completed the docstrings of all functions. Each function includes a docstring explaining the job it does, its input parameters, its return value, and any assumptions it makes about its inputs. See match_graphics.py for examples of how to effectively document functions, their parameters and return values.
-1 pt.Some function doctring is significantly incomplete.
-2 pts.Some functions do not have completed doctrings.
-4 pts.Most functions do not have completed docstrings.
Other documentation (3 points)
Not counting the docstrings for your program and functions, your program should contain at least three comments explaining aspects of your code that are potentially tricky for a person reading it to understand. You should assume that the person understands what Python syntax means but may not understand why you are doing what you are doing.
3 pts.You have at least 3 useful comments (1 points each)
Variables (4 points)
Important variables have descriptive names that indicate what they are used for.
2 pts.Variable declarations are not accompanied by comments.
2 pts.Variables do not have names that suggest for what they are used.
Algorithm (2 points)
1 pts.Your algorithm is straightforward and easy to follow.
1 pts.Your algorithm is reasonably efficient, with no wasted computation or unused variables.
Structure (5 points)
You will lose 5 points for having any statements outside of a function definition. There are only three exceptions to this rule:
  • Import statements
  • Definition of constants (variables whose values are known before the program runs and never modified)
  • The call to main
Catchall
For students using language features that were not covered in class, up to 5 points may be taken off if the principles of programming style are not adhered to when using these features. If you have any questions about what this means, then ask.

Submission

You should submit your final code on Moodle by the deadline. I strongly encourage you to take precautions to make and manage backups while you work on your project, in case something goes wrong either while working or with your submission to Moodle.

Name the file you submit to Moodle yourlastnameP2.py, substituting your actual last name (in lowercase) for yourlastname.

Late Policies

Project late policies are outlined in the course policies page.

Collaboration Policy

Programming projects must be your own work, and academic misconduct is taken very seriously. You may discuss ideas and approaches with other students and the course staff, but you should work out all details and write up all solutions on your own. The following actions will be penalized as academic dishonesty:

Project collaboration policies are described in the course policies page.