#RockPS
import random
Choices=['R','P','S']
UserScore=0
CpuScore=0
Games=0
while Games<6:
UserChoice=input('Rock, paper or scissors? (Type R, P or S respectively)')
if UserChoice in Choices:
Games+=1
CpuChoice = random.choice(Choices)
if UserChoice == 'S' and CpuChoice == 'P':
UserScore+=1
if UserChoice == 'P' and CpuChoice == 'R':
UserScore+=1
if UserChoice == 'R' and CpuChoice == 'S':
UserScore+=1
if UserChoice == 'S' and CpuChoice == 'R':
CpuScore+=1
if UserChoice == 'P' and CpuChoice == 'S':
CpuScore+=1
if UserChoice == 'R' and CpuChoice == 'P':
CpuScore+=1
print(UserScore, CpuScore)
if UserScore>CpuScore:
print('Well done, you won!')
if UserScore==CpuScore:
print('You tied!')
if UserScore<CpuScore:
('Unlucky, you lost.')
我是 Python 新手,所以很可能我错过了一些明显的东西。程序运行良好。这是一个摇滚,纸或剪刀游戏。进行 5 场比赛,比赛结束时列出分数。目前,无论哪种方式,它都只说 1 0、0 0 或 0 1,只计算 1 场比赛。我不确定这是为什么。我认为这与我的缩进有关,因为我没有看到我的循环有问题。