mercredi 18 novembre 2020

players roll 2 dice till one reaches 100

Each player roll two dice in a row on one turn. The amount of dice obtained is added to the player's total points. The game ends when one of the players the first has achieved at least 100 points.

from random import randint

dicesum2 = 0
dicesum1 = 0
while (dicesum1 < 100): 
    dice1 = [randint(1, 6) for i in range(2)]
    dicesum1 += sum(dice1)
    print('player 1',dice1,'|',dicesum1)
    dice2 = [randint(1, 6) for i in range(2)]
    dicesum2 += sum(dice2)
    print('player 2',dice2,'|',dicesum2) 

i need it to end when one reaches 100. how do i check both?

if a player throws exactly one single, he loses the points obtained in the turn;

how do i check when one of the generated numbers is 1?




Aucun commentaire:

Enregistrer un commentaire