我正在尝试构建一个石头、纸、剪刀游戏。我似乎无法让代码进行锻炼,因为无论我做出什么选择,赢家总是电脑!我的电脑有偏见吗?感谢您的帮助 !
import random
comp_list = ['Rock', 'Paper', 'Scissors']
computer = c = 0
command = p = 0
print("Scores: Computer " + str(c) + " player " + str(p))
while True:
comp = random.choice(comp_list)
command = input("rock , paper, scissors or quit :").lower()
if command == comp :
print("break even")
elif command == "rock":
if comp == "scissors":
print("player won")
p += 1
else:
print("computer won")
c +=1
elif command == "paper":
if comp == "rock":
print("player won")
p += 1
else :
print("computer won")
c += 1
elif command == "scissors":
if comp == "paper":
print("player won")
p += 1
else :
print("computer won")
c += 1
elif command == "quit":
break
else :
print("wrong command! ")
print("Player: " + command)
print("computer: " + comp)
print("")
print("Scores: Computer " + str(c) + " player " + str(p))
print("")
蝴蝶刀刀
相关分类