这是我第一次发布和使用这个网站,如果这不是最好的提问方式,很抱歉。我曾尝试自己研究并在此论坛上寻找答案,但我发现的每个显示器要么与我自己的语言不同,要么有不同的问题。我遇到的问题是游戏在终端中运行,就像我想要的一样,除了当涉及平局时,它不会注册平局,只是开始一个新游戏“选择你的选项或键入退出退出”在下一个线。我使用 Thonny 作为我的编辑器,并遵循了调试过程,它似乎只是“跳过”了 tie 命令。我该如何解决这个问题,或者是否有一些信息或文档可以指点我以帮助我理解我的问题。谢谢
#rock, paper, scissors
import random, sys
wins = 0
losses = 0
ties = 0
print('Let\'s play a game')
print('rock. paper. scissors')
while True:
print('choose your option or type quit to exit')
print('%s wins, %s losses, %s ties'%(wins, losses, ties))
while True:
playeroption = input()
if playeroption == 'quit':
sys.exit() # Quit the program.
if playeroption == 'rock' or playeroption == 'paper' or playeroption == 'scissors':
break # Break out of the player input loop.
randomNumber = random.randint(0,2) #selecting computer options
if randomNumber == 0:
AIoption = 'Rock'
elif randomNumber == 1:
AIoption = 'Scissors'
elif randomNumber == 2:
AIoption = 'Paper'
if playeroption == AIoption: #player vs computer outcomes
print('draw, i choose ' + str( AIoption) +'!')
ties = ties + 1
continue
elif AIoption == 'Paper' and playeroption == 'rock':
print('better luck next time i choose ' + ( AIoption))
losses = losses + 1
continue
elif AIoption == 'Rock' and playeroption == 'scissors':
print('better luck next time i choose ' + str(AIoption))
losses = losses + 1
continue
elif AIoption == 'Scissors' and playeroption == 'paper':
print('better luck next time i choose ' + str(AIoption))
losses = losses + 1
continue
elif AIoption == 'Paper' and playeroption == 'scissors':
print('you win human. I choose ' + ( AIoption))
wins = wins + 1
continue
elif AIoption == 'Rock' and playeroption == 'paper':
print('you win human. I choose ' + str(AIoption))
wins = wins + 1
continue
elif AIoption == 'Scissors' and playeroption == 'rock':
print('you win human. I choose ' + str(AIoption))
wins = wins + 1
continue