melikyanarmina / mini_project2

0 stars 0 forks source link

In this implementation, the player wins immediately after setting the goal number. However, in the game of craps, the player typically wins only after rolling the goal number again on a subsequent dice roll. #2

Open melikyanarmina opened 7 months ago

melikyanarmina commented 7 months ago
     Thank you for checking my code @areviksol

You mean that it need to be repeated until it become 7, like this

import random

def roll_dice(): return random.randint(1, 6) + random.randint(1, 6)

dice_a = random.randint(1, 6) dice_b = random.randint(1, 6) first_roll = dice_a + dice_b print(f"First roll: {first_roll}")

if first_roll == 7 or first_roll == 11: print("You win") elif first_roll in (2, 3, 12): print("Casino wins") else: print(f"Goal number is: {first_roll}")

goal_number = first_roll

while True:
    next_roll = roll_dice()
    print(f"Next roll: {next_roll}")
    if next_roll == 7:
        print("You lose")
        break
    elif next_roll == goal_number:
        print("Player wins")
        break
    else:
        print("Roll again")

_Originally posted by @areviksol in https://github.com/melikyanarmina/mini_project2/issues/1#issuecomment-1943823821_

areviksol commented 7 months ago

This means that after setting the "goal" number, the player needs to roll again to determine the outcome of the game. The game continues until the player either rolls the "goal" number and wins or rolls a 7 and loses.

melikyanarmina commented 7 months ago

Thank you dear @areviksol , I updated, I hope it works appropriate now

areviksol commented 7 months ago

everything works, great work !)