Hello!
So for an assignment, we have to write a program for the pig dice game.
You are to finish the program below that implements the dice game PIG played by 2 human players.
Pig is a dice game where each player during their turn rolls a 6-sided die. If the player rolls a 2 through 6, they decide whether they want to keep their turn score or roll again. If they roll a 1, the player loses all the points for that turn, thus receiving a turn score of 0 and that turn is over.
The first player to reach 100 points or more wins.
This is the code I have so far. However, it does not work and ends up being program timed out after the 5th or 6th input of y/n.
I was wondering how I would fix this? Thank you!
This is a sample output of what the program is suppose to come out as:
Welcome to the dice game Pig!
The objective is to be first to score 100 points.
Player 1 - Enter your name: Aragorn
Player 2 - Enter your name: Legolas
Aragorn
You rolled a 6
Your score: 6
Do you want to roll again? (y/n): y
Aragorn
You rolled a 2
Your score: 8
Do you want to roll again? (y/n): y
Aragorn
You rolled a 6
Your score: 14
Do you want to roll again? (y/n): n
|
*This part and on is what I cannot get for the code I had written
Legolas
You rolled a 4
Your score: 4
Do you want to roll again? (y/n): y
Legolas
You rolled a 5
Your score: 9
Do you want to roll again? (y/n): n
Aragorn
You rolled a 6
Your score: 20
Do you want to roll again? (y/n): y
Aragorn
You rolled a 1 (PIG!)
Your turn is over
Your score: 14
|