Question

In: Computer Science

In the game of craps, a pass line bet proceeds as follows: Two six-sided dice are...

In the game of craps, a pass line bet proceeds as follows: Two six-sided dice are rolled; the first roll of the dice in a craps round is called the “come out roll.” A come out roll of 7 or 11 automatically wins, and a come out roll of 2, 3, or 12 automatically loses. If 4, 5, 6, 8, 9, or 10 is rolled on the come out roll, that number becomes “the point.” The player keeps rolling the dice until either 7 or the point is rolled. If the point is rolled first, then the player wins the bet. If a 7 is rolled first, then the player loses. Write a program that simulates a game of craps using these rules without human input. Instead of asking for a wager, the program should calculate whether the player would win or lose. The program should simulate rolling the two dice and calculate the sum. Add a loop so that the program plays 10,000 games. Add counters that count how many times the player wins and how many times the player loses. At the end of the 10,000 games, compute the probability of winning [i.e., Wins / (Wins + Losses)] and output this value. Over the long run, who is going to win the most games, you or the house?

Solutions

Expert Solution

Thanks for the question, here is a program in Python that plays the game Crap, and count the number of wins and losses for 10000 times and at the end it computes the probability of winning.

Since the programming languge was not explicity mentioned, this is done in Python, in case it needs to be done in  C or C++ or Java just let me know and will do it.

Here is the code with output screenshot


thanks a lo t!! 

==============================================================

import random

wins = losses = 0

for _ in range(10000):

    while True:
        dice_one = random.randint(1, 6)
        dice_two = random.randint(1, 6)
        total = dice_one + dice_two
        if total == 7 or total == 11:
            wins += 1
            break
        elif total == 2 or total == 3 or total == 12:
            losses += 1
            break
        else:
            point = total
            while True:
                dice_one = random.randint(1, 6)
                dice_two = random.randint(1, 6)
                total = dice_one + dice_two
                if total == 7:
                    losses += 1
                    break
                elif total == point:
                    wins += 1
                    break
            break

print('Total Wins : {} '.format(wins))
print('Total Losses : {} '.format(losses))
probability = (wins)/(wins+losses)
print('Probability of winning is : {:.5f}'.format(probability))

======================================================================


Related Solutions

In the game of craps, people bet on the outcome of the throw of two, six-sided...
In the game of craps, people bet on the outcome of the throw of two, six-sided dice. Specifically, wagers are placed on the sum of the outcome on the upward facing number on each of the two dice. We are going to discuss relative likelihoods by counting the number of ways (the number of microstates) associated with specific sums (the macrostate). A. How many microstates are associated with a throw summing to 4? B. How many microstates are associated with...
In the game of craps, a player (known as the shooter) rolls two fair six-sided dice....
In the game of craps, a player (known as the shooter) rolls two fair six-sided dice. The shooter immediately loses if the sum of the dice is 2, 3, or 12 and immediately wins if the sum of the dice is 7 or 11 on the first roll. If the sum is anything else (4, 5, 6, 8, 9, or 10), that number becomes the point and the shooter rolls again. The shooter now wins by rolling that same point...
In the game of Craps, you roll two dice. When you bet on a “snake eyes”,...
In the game of Craps, you roll two dice. When you bet on a “snake eyes”, meaning a 1 on both dice, you win $30 for each $1 you bet. Otherwise, you lose your dollar. What is the probability of winning this bet? What is the expected value of making this bet? If you play this game 100 times, how much would you expect to lose?
This problem concerns the dice game craps. On the first roll of two dice, you win...
This problem concerns the dice game craps. On the first roll of two dice, you win instantly with a sum of 7 or 11 and lose instantly with a roll of 2,3, or 12. If you roll another sum, say 5, then you continue to roll until you either roll a 5 again (win) or roll a 7 (lose). How do you solve for the probability of winning?
Write a C++ program to play the dice game "Craps". Craps is one of the most...
Write a C++ program to play the dice game "Craps". Craps is one of the most popular games of chance and is played in casinos and back alleys throughout the world. The rules of the game are straightforward: A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the...
. Three Dice of a Kind Consider the following game: You roll six 6-sided dice d1,…,d6...
. Three Dice of a Kind Consider the following game: You roll six 6-sided dice d1,…,d6 and you win if some number appears 3 or more times. For example, if you roll: (3,3,5,4,6,6) then you lose. If you roll (4,1,3,6,4,4) then you win. What is the probability that you win this game?
Craps is a dice game in which the players make wagers on the outcome of the...
Craps is a dice game in which the players make wagers on the outcome of the roll, or a series of rolls, of a pair of dice. Most outcomes depend on the sum of the up faces of two, fair, six-sided dice. 1) What is the lower class boundary of the "6" class? 2) Find the mean. 3) Find the standard deviation. 4) Find the z-score for snake eyes.
Write a program in Python to simulate a Craps game: 1. When you bet on the...
Write a program in Python to simulate a Craps game: 1. When you bet on the Pass Line, you win (double your money) if the FIRST roll (a pair of dice) is a 7 or 11, you lose if it is ”craps” (2, 3, or 12). Otherwise, if it is x ∈ {4, 5, 6, 8, 9, 10}, then your point x is established, and you win when that number is rolled again before ’7’ comes up. The game is...
Objective Make a function to serve as a Craps dice game simulator. If you are not...
Objective Make a function to serve as a Craps dice game simulator. If you are not familiar Craps is a game that involves rolling two six-sided dice and adding up the total. We are not implementing the full rules of the game, just a function that returns the value of BOTH dice and their total. Details In the function you create: Make a function that uses pointers and pass by reference to return THREE separate outputs (arrays are not allowed)....
Sarah D's road manager plays a dice game with two dice. The six sides of on...
Sarah D's road manager plays a dice game with two dice. The six sides of on each die are numbered from 2 to 7. Define the random variable X to be the sum of the numbers on the up-face of the two dice when rolled. a. Construct table showing PDF and the CDF of the random variable X b. Calculate the mode of the distribution. c. Calculate the expected value of X. d. Calculate variance of X. e. Calculate P(4
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT