The final project for the Python part of this course is to implement the Game of Pig. Rules for the game are given below.
Your project must satisfy these core requirements:
Most of the work on your project will be translating the rules provided into a functional design and implementation. There are not many requirements on how specifically you do this. This can be a double edged sword. On the one hand you have a great deal of freedom in designing your solution; on the other hand we are giving very little specific guidance. If you are having trouble planning or getting started, get help. It is much better (and easier) to get help early and start off 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.
I've posted your project teams and repository information here. Each member of your team should checkout your team repository at the start of the project. To minimize SVN conflicts, follow this routine with each editing session:
Using this cycle will minimize conflicts. If you get a conflict, get help from a member of the course staff to resolve it.
Remember to provide appropriate commit messages. We’ll be grading your proper use of SVN.
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 done before the specified class session.
Before Session 17 — Top Level Structure Diagram: A neatly drawn structure diagram showing the top-level functions that you plan to use in your program including a few formal parameters and return values. You should start thinking about the objects (dictionary types or instances of classes) you will need. This does not have to be your final design, just your initial plan.
Consider the subsequent milestones in your design! In particular, the next milestone has specific requirements for top-level functions.
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, first. 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 scanning the designs, and may share it with other teams.
Before Session 18 — Program Allows Console-Only Play: To support testing and encourage separate development of your model and view, your game must initially support two human players using console-only game play (similar to Blackjack, but with human input for both players).
You will be asked to demo this to your instructor or TA at the start of session 18.
You must include the following two top-level functions (i.e., not inside a class, if you chose to use object-oriented design), printScore(game)
and makeNewGame(numberOfPlayers)
. The printScore(game)
function must print the state of the given game to the console. The makeNewGame(numberOfPlayers)
function takes a number of players. It must return a game initialized to the given state. The game might be represented as a dictionary, an object of a custom class, or some combination. For example, to create a two player game we could call the function like this:
g = makeNewGame(2)
After creating that game, a call to printScore(g)
would output something like:
Player 1 score: 0 Player 2 score: 0 Player 1's turn. Turn score: 0
Note that you have to design and implement some data structure (like a custom object, list, or dictionary) to track the game state. If you are using an object-oriented design, your makeNewGame()
function will probably call a constructor and your printScore()
function will probably call a method. Again, this is not a requirement—just a suggestion.
Before Session 19 — Basic GUI Implemented: By the start of this session, your program should allow two human players to play a standard Game of Pig against each other using an entirely graphical interface. That is, they should not need to read or type in the console to play the game.
Project grades will be based on both individual and group results. We may grade each project milestone, plus the final project program and presentation. Grading will include both the proper functioning of your program and an evaluation of your design, coding style, documentation, teamwork, and proper use of SVN.
Each team will be responsible for presenting and demonstrating their work to the class.
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.
In its basic form, Pig is just a race between two players to reach 100 points. Players alternate turns. During a player's turn they repeatedly roll a single die, adding the value rolled to their turn total. At any point they may hold, adding their turn total to their game total. During a turn, if the player rolls a one, then they forfeit their turn total; however, their game total is always safe. Play passes to the other player after the first player holds or rolls a one.
The Wikipedia article on Pig is a good resource, as is the on-line version of Pig at Gettysburg College.
Once you are done with the basic version, you should add some enhancements. A game with no enhancements will earn no better than a C grade. You will earn a higher grade for doing more challenging ones, and the more, the better, including extra credit. Be creative. What's cool and challenges you? Below are some ideas. Feel free to discuss other ideas with your instructor. Have fun with this!
Implement a computer player. Here are some ideas for doing that from Todd Neller:
Let i be the player's score, j be the opponent's score, and k be the current turn total.
Add game variants like these, again thanks to Todd Heller:
Thanks to Todd Neller at Gettysburg College for his Nifty Assignment from SIGCSE 2010!