Pig is a game that has two players (in our case one human and one computer) that alternate turns. Each player’s goal is to get 100 points rolled on a normal six-sided die first. Each turn consists of the rolling the die repeatedly until you get a 1 or decide to stop. As long as you roll a 2-6, you will add this amount to your total for that turn. But if you roll a 1 during your turn, your turn ends and you receive zero points for that entire turn (erasing all of the progress you made since you last agreed to stop). If you decide to stop rolling at any point in your turn, your points for that turn are then added to the overall score. The overall score is then safe from future rolls. The trick is knowing how long to push it before we should stop and save our gains. See end of this document for an example of a game of pig we should write coding as below In order to explore what is the best strategy for the computer player (i.e. at what score do we stop each computer turn), we need to do some analysis. Our main game assumed that as a computer, the best strategic way to victory would be to stop after 20 points or more per turn. You are going to analyze if this is the best value by using trial and error. Redesign your program so that it is computer_one against computer_two. Alter the total per turn that is necessary for one of the computer players, while leaving the other at 20. (For example 15 against 20). For your test value try one number between 15 and 25. Now place your game in a loop and play 1000 times and report which computer won more. (You must remove all of the output statements once you are sure it is working otherwise it will take too long to run.)
Game Description:
Pig is a game that has two players (in our case one human and one computer) that alternate turns. Each player’s goal is to get 100 points rolled on a normal six-sided die first. Each turn consists of the rolling the die repeatedly until you get a 1 or decide to stop. As long as you roll a 2-6, you will add this amount to your total for that turn. But if you roll a 1 during your turn, your turn ends and you receive zero points for that entire turn (erasing all of the progress you made since you last agreed to stop). If you decide to stop rolling at any point in your turn, your points for that turn are then added to the overall score. The overall score is then safe from future rolls. The trick is knowing how long to push it before we should stop and save our gains. See end of this document for an example of a game of pig
we should write coding as below
In order to explore what is the best strategy for the computer player (i.e. at what score do we stop each computer turn), we need to do some analysis. Our main game assumed that as a computer, the best strategic way to victory would be to stop after 20 points or more per turn. You are going to analyze if this is the best value by using trial and error. Redesign your program so that it is computer_one against computer_two. Alter the total per turn that is necessary for one of the computer players, while leaving the other at 20. (For example 15 against 20). For your test value try one number between 15 and 25. Now place your game in a loop and play 1000 times and report which computer won more. (You must remove all of the output statements once you are sure it is working otherwise it will take too long to run.)
It must be very apparent to me which computer wins. So have the results indicate what strategy (amount) the winning and losing computer used. Doing this portion is worth 15% total of the project, so do this last after you are sure the computer versus human version is working.
in python
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images