Craps simulation game

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>
im trying to simulate craps game, approximate a big number of rolls,
the program should in case of Pass(Won) in the first roll obatin a total of 7 or 11(Win).
if its 2,3 or 12 its lost
Any other total in the first roll becomes the point, in this case, in order for the roll to be won, the player must roll many times the 2 dices, get a new total = point, if total is 7, he looses.
in the end,
the program should execute success rate, number of games won and lost
number of games finishes with 1 and multiple rolls.

```python

import random

number_rolls = 0
result = -1

point=0
print()

first-roll = int(input(‘roll dice:’))

if first-roll <= 0:
print(‘Terminé’)
elif first-roll > 500000:
print(“Too big”)
first-roll = int(input(‘please try again:’)) # it should ask user to enter a number(roll)

else:
# print(‘let’s start.’) edited
print(“let’s start.”)

while (result != first-roll): 


    result = random.randint(1,6)  
    number_rolls +=  1


    if result in {7, 11}:  #won
        print('Won')
    elif result in {2, 3, 12}: # lost
        print('lost')
    else:
        if result == 7:
            print('lost')
        while True:
            if point == first-roll: 
                point += 1
                print('won')
            if point == 7:
                print('lost')
                point-=1

print(‘the roll was’, first-roll)
print(“we did {0} lancer(s)before we get the first {1}”.format(result, first-roll))
print(‘the number of rolls devided by the first roll:’, format(number_rolls /first_roll, ‘8.6f’))
print(‘Won games’, format(point))
print(‘lost games’,format(point))
print(‘End’)

<do not remove the three backticks above>

here:

print('let's start.')

where does the string end? a bit early don’t you think?

1 Like

Recall that there are two phases, ‘come out’ and ‘point’. The latter phase is not entered until a point roll, 4, 5, 6, 8, 9 or 10.

come out

roll 7 or 11            =>  "pass" line wins
roll 2, 3, or 12        =>  "pass" line loses; "don't pass" line wins
roll 2 or 3             =>  "don't pass" line ties (pushes)
roll 'point'            =>  over to point phase, otherwise...

…the shooter continues to roll in this phase unless they opt to pass the dice. I suspect for your game there is no dice pass so just continue until there is a point roll. (tally losses)

point phase

The shooter keeps rolling until, “sevens out” or “hits” point.

roll 7 before a 'hit'   =>  "pass" line loses; "don't pass" line wins
roll point              =>  "pass" line wins; "don't pass" line loses

Two while loops are suggested here, one for the come out phase followed by a conditional one for the point phase. The condition being Pass or Craps excluded.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.