Review the assignment guidelines.
Craps is one of the most popular dice games played at casinos and casino nights.
Write a program that plays a simplified version of the game as explained below and prints out various statistics about the simulation.
In this simplified version we are only concerned if a player (as opposed to the casino or 'house') wins or loses a round.
The game starts by the player rolling 2 six sided dice. We call this the initial roll.
If the initial roll is a 7 or 11, the player wins and the round is over.
If the initial roll is a 2, 3, or 12, the player loses and the round is over.
If the initial roll is 4, 5, 6, 8, 9, or 10 the round continues. This is initial roll is referred to as the point.
If the player did not win or lose on the opening roll, the player continues to roll the dice. The rules are now different. If the player rolls a 7 before rolling the point again, they lose the round. If the player rolls and matches the point, they win the round. The player rolls keeps rolling in the round until they roll a 7 (and lose) or roll to match the point. (and win)
Some examples of possible rounds:
Initial roll = 11, player wins
Initial roll = 3, player loses
Initial roll = 10. The point is 10. Subsequent rolls: 9, 3, 2, 9, 12, 11, 9, 7 (player loses)
Initial roll = 8. The point is 8. Subsequent rolls: 11, 10, 11, 10, 8 (player wins)
Your program shall:
Ask the user if they want to set the initial seed or not.
If they want to set the seed, ask for the seed. (Note, this option exists so
that when you test the program and when we grade the program, we will have the same
results even though we are using pseudo-random numbers. Use the random.seed(int)
method to set the seed.
Ask the user the number of rounds they want the program to simulate.
Simulate the given number of rounds.
Print out how many times the player wins and the maximum number of rolls in any given round.
You may assume the user always enters integers for the seed, but look at the sample output for the expected output if they enter a number of rounds less than or equal to 0.
You are not required to use named constants for magic numbers. (Literal ints in your program other than -1, 0, 1, 2)
Expected output: (user input is in bold below)
This program simulates the dice game of craps. Do you want to set the seed? Enter y for yes, anything else for no: y Enter an int for the initial seed: 1212 Enter the number of rounds to run: 10000 Player won 4935 times in 10000 rounds. Maximum number of rolls in a round = 30
Recall the random.randint(a, b) method. This method returns an int from a inclusive to b inclusive with each int in the range having a roughly equal probability of being returned.
More sample input and output in this file. Note if the player only plays 1 round the output is 'round' instead of 'rounds'. Likewise if the player only wins one of the rounds the output is 'time' instead of 'times'.
Analysis [Recall, this course carries the UT qualitative reasoning flag]: People gamble in casinos. Typically, in the long run, the casinos come out the winner. In a comment at the bottom of your program answer the following questions. Note, the most basic bet is an even money bet. Meaning if you bet $10 and win you get an additional $10. If you bet $10 and lose, you are out $10.
1. Does the simulation support the idea that in the long run, casinos come out the winner? Why or why not?
2. Assume you have $2,000. You can simply keep the money or play craps at a casino. If you play craps, each round you must bet $10 and you must play until you run out of money or have completed 500 games. Would you choose to keep the $2,000 and not play or play craps as described? Why or why not?
Recall, you must include and fill out the header for the assignment and place it at the top of the program. Replace any items in <> with the proper information and delete the <>. (Note, I am no longer requiring the number of slip days used to be included in the header.)
# File: dice.py
# Description:
<A DESCRIPTION OF YOUR PROGRAM>
# Assignment Number: 6
#
# Name: <YOUR
NAME>
# EID: <YOUR EID>
# Email: <YOUR EMAIL>
# Grader: <YOUR
GRADER'S NAME Mayra OR Risha>
#
# On my
honor, <YOUR NAME>, this programming assignment is my own work
# and I have
not provided this code to any other student.