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("平局")
03-05
630
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-07
518
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-16
4929
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-04
3641
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交