from math import floor, log2 from random import randint biglie = randint(10, 100) giocaComputer = randint(0, 1) == 1 intelligente = randint(0, 1) == 1 while biglie > 0: if giocaComputer: if intelligente: if biglie in [3, 7, 15, 31, 63]: biglie -= randint(1, floor(biglie/2)) else: biglie -= 3 else: biglie -= randint(1, floor(biglie/2)) else: mbiglie = int(input("Quante biglie vuoi togliere? ")) if mbiglie > floor(biglie/2): print("Non puoi togliere così tante biglie") continue biglie -= mbiglie giocaComputer = not giocaComputer if giocaComputer: print("Ha vinto il computer") else: print("Ha vinto il giocatore")