python石头剪刀布

import random

print("*"*15+"欢迎来到闲来无事游戏平台"+"*"*15)
print(" "*17+"石头    剪刀  布")
print("*"*51)

play_score = 0
computer_score = 0

play_name = input("请输入玩家姓名:")
print("1.TheShy 2.小虎 3.Faker")
select = input("请选择对战的电脑角色(默认小虎):")

computer_name = ""
if(select == "1"):
    computer_name = "Theshy"
elif(select == "2"):
    computer_name = "小虎"
elif(select == "3"):
    computer_name = "Faker"
else:
    computer_name = "小虎"

round = eval(input("请选择胜利条件(1.一胜 2.二胜 3.三胜)ps:平局不计入胜利 :"))
print(f"{play_name} VS {computer_name}")


while(True):
    computer = random.randint(1,3)
    print("-" * 8,"请出拳:1.石头    2.剪刀    3.布","-"*8)
    num = eval(input())
    if(num == 1):
        print(f"{play_name} 出拳:石头")
    elif(num == 2):
        print(f"{play_name} 出拳:剪刀")
    elif(num == 3):
        print(f"{play_name} 出拳:布")
    else:
        print(f"{play_name} 出拳:石头")

    if(computer == 1):
        print(f"{computer_name} 出拳:石头")
    elif(computer == 2):
        print(f"{computer_name} 出拳:剪刀")
    elif(computer == 3):
        print(f"{computer_name} 出拳:布")
    else:
        print(f"{computer_name} 出拳:石头")

    if(num == computer):
        print("平局")
        continue
    elif(num==1 and computer ==2 or num ==2 and computer ==3 or num ==3 and computer ==1):
        print(f"玩家:{play_name} 胜")
        play_score += 1
    else:
        print(f"电脑:{computer_name} 胜")
        computer_score += 1

    if(play_score == round or computer_score == round):
        break
print("-"*20)
print(f"{play_name}的积分为:{play_score}")
print(f"{computer_name}的积分为:{computer_score}")
print("-"*20)
if(play_score > computer_score):
    print(f"{play_name} 胜利")
elif(play_score < computer_score):
    print(f"{computer_name} 胜利")
else:
    print("平局")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值