This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Handout #30 CS 106A July 22, 2009 Assignment #5Yahtzee! The idea of Yahtzee in CS106A was introduced by Todd Feldman; much of this handout was written by Julie Zelenski. Due: Thursday, July 30st at 10:30am After this week's lectures, your ability to write interesting programs will take a dramatic leap forward. To solidify your understanding, Assignment #5 uses arrays in a variety of contexts to implement a popular multiplayer dice game. There are arrays for the dice, arrays for the dice to reroll, arrays for the player names, arrays for a players score, and even an array of arrays to handle the entire scorecard. By the time youre done, you will be well on your way to mastering this critical concept. The goal Your task is to create a computer version of the game Yahtzee . Some of you may have already played the game, but for those who havent, its simple to learn. There are five dice and one to four players. A round of the game consists of each player taking a turn. On each turn , a player rolls the five dice with the hope of getting them into a configuration that corresponds to one of 13 categories (see the following section on Dice Categories). If the first roll doesnt get there, the player may choose to roll any or all of the dice again. If the second roll is still unsuccessful, the player may roll any or all of the dice once more. By the end of the third roll, however, the player must assign the final dice configuration to one of the thirteen categories on the scorecard. If the dice configuration meets the criteria for that category, the player receives the appropriate score for that category; otherwise the score for that category is 0. Since there are thirteen categories and each category is used exactly once, a game consists of thirteen rounds. After the thirteenth round, all players will have received scores for all categories. The player with the total highest score is declared the winner. Dice categories The thirteen categories of dice configurations and their scores are: 1. Ones . Any dice configuration is valid for this category. The score is equal to the sum of all of the 1s showing on the dice, which is 0 if there are no 1s showing. 26. Twos , Threes , Fours , Fives , and Sixes . (same as above but for different values). Any dice configuration is valid for these categories. The score is equal to the sum of the 2s, 3s, 4s, and so on, showing on the dice. 7. Three of a Kind . At least three of the dice must show the same value. The score is equal to the sum of all of the values showing on the dice. 8. Four of a Kind . At least four of the dice must show the same value. The score is equal to the sum of all of the values showing on the dice....
View Full Document
- Fall '08