assignment4

assignment4 - CMPSC121 Spring 2008, Assignment Four 100...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPSC121 Spring 2008, Assignment Four 100 Points; due Friday, March 7, at 10pm You will write a program to play the game of Pig. 1 The rules of the game The game of Pig is a simple two player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn a player rolls a dice. After each roll: If the player rolls a 2-6 then she can either: ROLL AGAIN, or HOLD. At this point the sum of all rolls made this turn is added to the player’s total score and it becomes the other player’s turn. If the player rolls a 1 then the player loses her turn and gets zero point for this turn. If a player reaches 100 or more points after holding then the player wins. Write a program that plays the game of Pig, where one player is human and the other is the computer. The computer program should play according to the following rule: Keep rolling on the computer’s turn if it has not won and the number of points that it accumulated in this turn is less than 20. 2 The program’s behavior Here is a sample use-case to show how the computerized program, named pig.cpp, should behave: Welcome to Pig! Now it is your turn. Do you want to roll or hold (r/h)? r
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

assignment4 - CMPSC121 Spring 2008, Assignment Four 100...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online