Question

You are coding a simple game called Pig. Players take turns rolling a die. The die...

You are coding a simple game called Pig. Players take turns rolling
a die. The die determines how many points they get. You may get
points each turn your roll (turn points), you also have points for the
entire game (grand points). The first player with 100 grand points is
the winner. The rules are as follows:
Each turn, the active player faces a decision (roll or hold):
Roll the die. If it’s is a:
1: You lose your turn, no turn total points are added to your
grand total.
2-6: The number you rolled is added to your turn total.
Hold: Your turn total is added to your grand total. It’s now the
next player’s turn.
Requirements.

These are the requirements for the as-
signment. This means they are general

and apply to the entire assignment,
rather than one specific part. Not every
assignment will have a requirements
section.

• Display the game score every time the active player changes.
• Use whatever techniques you think best for creating reliable code
which is easy to read and maintain. Do not optimize for computer
performance. Choose data structures which are easy to expand, or
preferably, automatically re-size themselves (if needed).
• Make your output as clear and easy to understand as possible.
item Use structured programming or object oriented programming
techniques.
• You cannot use any data structures from the standard template
library. No vectors or anything like that.

• Make a simple AI with a random number. Each decision the com-
puter rolls, 1-3 hold, 4-6 roll again.

• Style guide elements apply: comments, layout, Program Greeting,
Source File Header, and variables etc. etc.
Specification Bundles.
These are additional requirements for the assignment. You code
the specifications from the various groups to control the maximum
potential grade you can get for this assignment. The more work you
do, the better grade you can get. Specifications are bundled into

Folsom Lake College

pig (pig) 2

groups: "A", "B", and "C". You must meet the specifications of the
lowest group before I will count the specifications for the highest
group. For example, you must meet the "C" specifications before I

will count the "B" specifications. If you miss one element of a spec-
ification bundle, that is the grade you will get for the assignment -

regardless of how much extra work you do. Note: sometimes you
will get comments stacking on top of each other - that’s OK even
though you would never do that in the real world.

You want to comment where these
specifications begin because I will be
looking for them. You want me to find
them. To confirm I can find them, use
the grep trick discussed below.

"C" Specification Bundle.
1. // Specification C1 - Time Seed
Get the current time and use it for a random number seed.
2. // Specification C2 - Student Name
Allow name to accept first plus last name (ie 2 words). Display it
somewhere in the output.
3. // Specification C3 - Numeric Menu
Use a numeric menu to collect the human players actions. See
figure 1 for an example menu.
4. // Specification C4 - Bulletproof Menu
Detect and re-prompt if incorrect data is entered.

"C" Bundle Menu Options.
1. 1. Roll
2. 2. Hold
3. 3. Quit
Figure 1: Allowable menu options for
this bundle.

"B" Specification Bundle.
1. // Specification B1 - Track each turn
Keep track of the points each player scores each turn.
2. //Specification B2 - Randomize Start
Randomly determine which player starts the game.
3. // Specification B3 - Alpha Menu
Switch to an alphanumeric menu. Only accept the letters between
the <>’s. See the next page for an example. List specification C3
like this: // Specification C3 - REPLACED. Put this comment right
above specification B3. Note: Specification C4 now applies to this
alphanumeric menu.
4. // Specification B4 – Resign Option
The human can quit the current game and automatically restart a
new one. See figure 2 for an example menu.

"A/B" Bundle Menu Options.
1. <R>oll
2. <H>old
3. Re<s>ign
4. <Q>uit
Figure 2: Allowable menu options for
this bundle.

"A" Specification Bundle.
1. // Specification A1 - Main Event Loop
Run the program in a main event loop. Prompt the player when
the game ends if they want to play another game. Use a ’y’ or ’n’
prompt to stop playing games.

pig (pig) 3

2. // Specification A2 - Group Stats
Keep track of the number of games played, who won and lost each
game and the number of turns each game took. Don’t forget to
keep track of games resigned, too. You can use a struc for this is
you wish.
3. // Specification A3 - Current Date
Include in the program greeting the current date and time this
program started. Use a library to automatically get this, do not ask
the client to enter it.
4. Specification A4 - Upper and Lower Case
You can accept upper and lower case letters for your menu in
specification B3.

Homework Answers

Answer #1

#include <iostream>

#include <cstdlib>

#include <ctime>

int dieroll();

int yourturn();

int main()

{

int humanscore=0,compscore=0;

srand(time=(NULL))

{

humantotalscore =yourturn(totaal human score)

cout<<total score so far is <<human total score>

if(human totalscore >=100)

{

cout <<"you win";

return 0;

}

comptotalscore=comptotalscore+compturn(comptotalscore)

if (comptotalscore is >=100)

}

}

}

int dieRoll()

return(rand%6)+1;

}

int human turn (int humanscore)

char roll0or hold;

do

{

score=dieroll();

if(score == 1)

{

return 0;

}

cout<<you rolled a <<score<< "score so far this turn is"<<this score<<end1;

}

while(rollorhold == r || rollorHold == R)

{

cout << "cpu holds."<< end1;

return thisTurnscore;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Implement the following problem as a self-contained Python program (module). Please write in beginner level code!...
Implement the following problem as a self-contained Python program (module). Please write in beginner level code! Thanks! 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 six-sided die. After each roll: a) If the player rolls a 1 then the player gets no new points and it becomes the other player’s turn. b) If the player rolls...
You and a friend are rolling a set of 7 dice. The game works such that...
You and a friend are rolling a set of 7 dice. The game works such that if a die shows the values 1, 2, 3, or 4 you will get a point for that die. Each die that shows 5 or 6 your friend will get a point for. Construct a probability model for a single roll of the dice then answer the following. A)What is the probability you made 2 points? B)What is the probability that your friend will...
You and a friend are rolling a set of 5 dice. The game works such that...
You and a friend are rolling a set of 5 dice. The game works such that if a die shows the values 1, 2, 3, or 4 you will get a point for that die. Each die that shows 5 or 6 your friend will get a point for. Construct a probability model for a single roll of the dice then answer the following. Step 1 of 5: What is the probability you made 2 points? Step 2 of 5:...
In java create a dice game called sequences also known as straight shooter. Each player in...
In java create a dice game called sequences also known as straight shooter. Each player in turn rolls SIX dice and scores points for any sequence of CONSECUTIVE numbers thrown beginning with 1. In the event of two or more of the same number being rolled only one counts. However, a throw that contains three 1's cancels out player's score and they mst start from 0. A total of scores is kept and the first player to reach 100 points,...
You and a friend are rolling a set of 6 dice. The game works such that...
You and a friend are rolling a set of 6 dice. The game works such that if a die shows the values 1, 2, or 3 you will get a point for that die. Each die that shows 4, 5, or 6 your friend will get a point for. Construct a probability model for a single roll of the dice then answer the following. Step 1 of 5: What is the probability you made 2 points? Step 2 of 5:...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional char array with three rows and three columns as the game board. Each element in the array should be initialized with an asterisk (*). The program should run a loop that: • Displays the contents of the board array. • Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and...
Setup: 3 different people take turns rolling dice. They all get doubles WITHIN 3 ROLLS. NOT...
Setup: 3 different people take turns rolling dice. They all get doubles WITHIN 3 ROLLS. NOT IN A ROW. Each person waits their turn to roll. On each persons turn, they each roll doubles WITHIN 3 ROLLS. GIVEN THE FOLLOWING CONDITIONS: - There is a 25% chance that the dice are loaded so that:  Each die is loaded so that 6 comes up half the time P(6) = .5 for each die. The other numbers (1-5) are equally likely to show...
Problem 4)A simplified version of the dice game 10,000 is played using 5 dice. The player...
Problem 4)A simplified version of the dice game 10,000 is played using 5 dice. The player rolls the 5 six-sided dice, each 1 that is rolled, the player achieves a score of 100. A) How many possible ways are there to roll i l's over these 5 dice? (Hint: use combinations) B) The probability of any one dice rolling to a value of 1 is 1/5 (since each dice has six sides). Use the binomial probability distribution. Calculate the probability...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules of the game are as follows:  The game is played with two (2) players.  There are three (3) different Stacks in the game.  Each turn, a player pushes a disk on top of exactly one of the three Stacks. Players alternate turns throughout the game. Each disk will include some marker to denote to whom it belongs.  At the end...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a 3x3 grid. The winner is the first player to place 3 consecutive marks in a horizontal, vertical or diagonal row. Understanding the Problem: In this assignment, you will: 1) Create a tic tac toe board data structure. 2) Check for game over. 3) Clear the tic tac toe game for each game. 4) Display the tic tac toe board to screen. 5) Simulate playing...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT