我正在制作一个摇滚纸剪刀游戏,并遇到了问题decisioncycle().我要做的是要求用户输入一个选项usercycle(),让计算机生成一个随机选择gamecycle(),然后确定谁赢得了回合并跟踪每个结果的输赢数.似乎决定何时随机工作.
import random
class rpsgame:
rps= ["rock", "paper","scissors"]
wincount=0
losecount=0
def usercycle(self):
userchoice = input("rock, paper, scissor.....")
print("SHOOT")
return userchoice
def gamecycle(self):
computerchoice = random.choice(rpsgame.rps)
return computerchoice
def decisioncycle(self):
if rpsgame.usercycle(self) == rpsgame.rps[0] and rpsgame.gamecycle(self) == rpsgame.rps[1]:
print("paper beats rock, you lose!")
rpsgame.losecount +=1
elif rpsgame.usercycle(self) == rpsgame.rps[1] and rpsgame.gamecycle(self) == rpsgame.rps[0]:
print("paper beats rock, you win!")
rpsgame.wincount+=1
elif rpsgame.usercycle(self) == rpsgame.rps[0] and rpsgame.gamecycle(self) == rpsgame.rps[2]:
print("rock beats scissors, you win!")
rpsgame.wincount+=1
elif rpsgame.usercycle(self) …Run Code Online (Sandbox Code Playgroud)