import random
ju = 0
our = input("请出拳 石头=1布=2剪刀=3 ")
# 电脑随机出拳
com = random.randint(1, 3)
try:
n = int(our[ju])
a = int(our[ju]) - com
if n == 3 and com == 3:
print("剪刀VS剪刀")
elif n == 3 and com == 2:
print("剪刀VS布")
elif n == 3 and com == 1:
print("剪刀VS石头")
elif n == 2 and com == 1:
print("布VS石头")
elif n == 2 and com == 2:
print("布VS布")
elif n == 2 and com == 3:
print("布VS剪刀")
elif n == 1 and com == 1:
print("石头VS石头")
elif n == 1 and com == 2:
print("石头VS布")
elif n == 1 and com == 3:
print("石头VS剪刀")
if n > 3:
print("你在用膝盖玩吗")
elif n < 1:
print("你在用脚丫子玩吗")
else:
if a == 1 or a == -2:
print("you win")
elif str(our[ju]) == str(com):
print("平局")
else:
print("you lost")
except:
print("你在干什么,好好输入数字")
# 这是第二局
ju = ju+1
# 电脑随机出拳
com = random.randint(1, 3)
try:
n = int(our[ju])
a = int(our[ju]) - com
if n == 3 and com == 3:
print("剪刀VS剪刀")
elif n == 3 and com == 2:
print("剪刀VS布")
elif n == 3 and com == 1:
print("剪刀VS石头")
elif n == 2 and com == 1:
print("布VS石头")
elif n == 2 and com == 2:
print("布VS布")
elif n == 2 and com == 3:
print("布VS剪刀")
elif n == 1 and com == 1:
print("石头VS石头")
elif n == 1 and com == 2:
print("石头VS布")
elif n == 1 and com == 3:
print("石头VS剪刀")
if n > 3:
print("你在用膝盖玩吗")
elif n < 1:
print("你在用脚丫子玩吗")
else:
if a == 1 or a == -2:
print("you win")
elif str(our[ju]) == str(com):
print("平局")
else:
print("you lost")
except:
print("你在干什么,好好输入数字")
# 这是第三局
ju = ju +1
# 电脑随机出拳
com = random.randint(1, 3)
try:
n = int(our[ju])
a = int(our[ju]) - com
if n == 3 and com == 3:
print("剪刀VS剪刀")
elif n == 3 and com == 2:
print("剪刀VS布")
elif n == 3 and com == 1:
print("剪刀VS石头")
elif n == 2 and com == 1:
print("布VS石头")
elif n == 2 and com == 2:
print("布VS布")
elif n == 2 and com == 3:
print("布VS剪刀")
elif n == 1 and com == 1:
print("石头VS石头")
elif n == 1 and com == 2:
print("石头VS布")
elif n == 1 and com == 3:
print("石头VS剪刀")
if n > 3:
print("你在用膝盖玩吗")
elif n < 1:
print("你在用脚丫子玩吗")
else:
if a == 1 or a == -2:
print("you win")
elif str(our[ju]) == str(com):
print("平局")
else:
print("you lost")
except:
print("你在干什么,好好输入数字")
sunAlex -猜拳游戏4.0
最新推荐文章于 2024-09-05 11:10:46 发布