assignment4

assignment4 - CMPSC121 Spring 2008 Assignment Four 100...

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

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 ﬁrst 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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/19/2008 for the course CSC 121 taught by Professor Deng during the Fall '08 term at Penn State.

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
Ask a homework question - tutors are online