0
I’m making a game Stone, paper, scissors, lizard and Spock.
The intention of the game is to create a function that asks me which option I will choose, while the computer randomly chooses one of these 5. A third function should compare the result of the two moves (mine and the computer) and check whether I won, lost or tied. At the beginning, I put a command so that the computer asks me how many rounds I want to play. The problem is that apparently it "locks" the values of the first round, for example, if I choose scissors and the computer picks paper, it always computes the result of that round (which I won) in the next rounds, even if I choose other things in the next rounds. Thanks in advance.
legenda = '''
[0] pedra
[1] spock
[2] papel
[3] lagarto
[4] tesoura
'''
n = randint(0,4)
print(n)
lista = [[0,'pedra'],[1,'spock'],[2,'papel'],[3,'lagarto'],[4,'tesoura']]
def jogador():
while True:
print(legenda)
esc = int(input(f'Escolha uma jogada: '))
if esc == 0 or esc == 1 or esc == 2 or esc == 3 or esc == 4:
print(f'-> Você escolheu {lista[esc][1]} ')
break
else:
print(f'Opção inválida, digite novamente')
return esc
def computador():
print()
print(f'-> O computador jogou {lista[n][1]}')
return n
def dif():
dife = jogador() - computador()
return dife
def jogada():
voce = 0
comp = 0
print(f'''\t\tPLACAR
VOCÊ\t\t\tCOMPUTADOR
{voce}\t\t\t\t{comp}''')
num = int(input(f'Quant. de rodadas? '))
for i in range(0,num):
jogador()
computador()
if dif() == 2 or dif() == 1 or dif() == -3 or dif() == -4 :
voce += 1
print('Você ganhou')
print(f'''\t\tPLACAR
VOCÊ\t\t\tCOMPUTADOR
{voce}\t\t\t\t{comp}''')
elif dif() == 0:
print('Empate')
print(f'''\t\tPLACAR
VOCÊ\t\t\tCOMPUTADOR
{voce}\t\t\t\t{comp}''')
else:
print('Você perdeu')
comp += 1
print(f'''\t\tPLACAR
VOCÊ\t\t\tCOMPUTADOR
{voce}\t\t\t\t{comp}''')
jogada()```
Thanks! I managed to solve the problem of not updating the random number. However, the score only appears every 6 rounds, I do not know why.
– Guilherme Matos Passarini