Craps simulation game


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.

import random 

number_rolls = 0 
result = -1


first-roll = int(input('roll dice:')) 

if first-roll <= 0:  
elif first-roll > 500000:
    print("Too big")
    first-roll = int(input('please try again:')) # it should ask user to enter a number(roll)

    # 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
        elif result in {2, 3, 12}: # lost
            if result == 7:
            while True:
                if point == first-roll: 
                    point += 1
                if point == 7:

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('let's start.')

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


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.