Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

complete the code for the game Pig. Please use the instructions below to help. I've already started the code but I need help fixing it

 complete the code for the game \"Pig.\" Please use the instructions below to help. I've already started the code but I need help fixing it and completing it. Please write code in PYTHON***


This is the code I have so far:

 


<... your=\"\" own=\"\" code.=\"\" ...=\"\"> Note, that the playing should stop as soon as one of the players reaches 100 points. The other player should not get another turn after that. As before, you may want to add some additional print statements at this stage so that you can see what's going on. Here is what an example run of this function might look like. Player 1 got O points. Player 2 got 0 points. Player 1 got 12 points. Player 2 got 15 points. Player 1 got 15 points. Player 2 got 15 points. Player 1 got 12 points. Player 2 got 13 points. Player 1 got 12 points. Player 2 got 14 points. Player 1 got 0 points. Player 2 got 15 points. Player 1 got 15 points. Player 2 got 0 points. Player 1 got 13 points. Player 2 got 14 points. Player 1 got 12 points. Player 2 got 12 points. Player 1 got 14 points. Player 1's final score: 105 Player 2's final score: 98 Don't forget that, ultimately, this function should just return a number to indicate the winner and that you should comment out all print statements before moving on to the next section. a 3.2 Does going first or second make a difference? Do players 1 and 2 have an equal chance of winning? Define a function called simulation. This function should take two parameters which indicate the values for that players 1 and 2 use. The function simulation should then use the two-player-pig function to run 100,000 games of two-player Pig and count how often each player wins. It should print out the results in the following format: Games won by player 1: 53509 Games won by player 2: 46491 As in the previous simulations, you need a simple counting while loop that keeps track of the number of games played. Does it matter for a Pig player whether they go first or second? Add your answer to your program as a comment. def hold_at_x_turn(max_points): points = @ reroll = True while reroll: rolt=randint(1, die) prints\"Roll: \" + str(roll) af roll! whold and points=max_points:>







Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions