100 points due 4/12/02
You are going to write a program to play Yahtzee. The necessary functions will be divided up into several groups so that you don't have to write the entire program. This will give you a taste of how big programs are developed as well as teaching you how to use a makefile.
Yahtzee is a game for 2 or more players that uses 5 dice. Each player gets 13 turns. In each turn, a player rolls all the dice. The player may choose to re-roll any subset of the dice two times.
The score for a turn is based on the numbers showing after the third roll. The score is applied to one of the 13 configurations which must be achieved (or forfeited) during the game. The configurations can be played in any order.
| Coonfiguration | Description | Score |
| aces | any number of aces | 1 * # aces rolled (two aces => score of 2) |
| twos | any number of twos | 2 * # twos rolled |
| threes | any number of threes | 3 * # threes rolled |
| fours | any number of fours | 4 * # fours rolled |
| fives | any number of cwfivesaces | 5 * # fives rolled |
| sixes | any number of sixes | 6 * # sixes rolled (4 sixes => score of 24) |
| three of a kind | three dice with the same value | total all dice |
| four of a kind | four dice with the same value | total all dice |
| full house | pair plus three of a kind | 25 |
| small straight | sequence of 4 numbers in a row | 30 |
| large straight | sequence of 5 numbers in a row | 40 |
| Yahtzee | five of a kind | 50 |
| Chance | any combination of dice | total all dice |
A total of 63 or more for the first six configurations earns a bonus of 35 points. An extra Yahtzee in a game earns a bonus of 50 points.
Your assignment is to write the main program which runs the game and one of the function modules listed below. I will provide a makefile and the object code for all the modules except the main program. The header file yahtzee.h has prototypes for all the required functions. You may add prototypes for any other functions that you write to this header file. For compatibility with other modules, you should not change the prototype of any of the functions I have listed. You will also need to get copies of the object files for the modules you aren't writing code for from the p5 directory.
| functions for rolling and re-rolling the dice | |
| functions to test and score the n-of-a-kind hands | |
| functions to test and score large and small strights | |
| a class that allows the computer to be one of the players |
Because I haven't specified the input format for this program, your readme needs to be sufficiently detailed that I can figure out what to type in to the program.
#includesrand( time(NULL)); // at the beginning of the main program.
makeThe make utility will use the file called makefile to determine what needs to be done to create an executable.
make cleanBe sure that you are in that directory and type
submit tcole cs117 p5