import random go, b = 1, 1 winRate, fail, win,ping = 0, 0, 0,0 # 胜率 失败 胜利 平局 scissors, stone, cloth = 0, 0, 0 # 剪刀 石头 布 cheat = 0 # 作弊器 print("选择任意键开始游戏,退出游戏选择n/N") while go != 0: a = input() if a == "N" or a == "n": b = input("确定退出吗,如果是选择n/N") if b == "N" or b == "n": if fail == 0 and win == 0: break else: winRate = win / (win + fail) print("胜率为", winRate) break # computer = random.randint(0, 2) computer = 1 if cheat == 1: print("机器人将出",computer) player1 = input("请出拳 石头(0)/剪刀(1)/布(2):") if (player1 != "0") and (player1 != "1") and (player1 != "2"): print("选择错误,是否继续游戏,继续游戏请选择任意键,退出游戏选择n/N") continue if computer == 0: stone = stone + 1 elif computer == 1: scissors = scissors + 1 else: cloth = cloth + 1 player = int(player1) if (player == 0 and computer == 0) or (player == 1 and computer == 1) or (player == 2 and computer == 2): print("你出的是:%s" % player + ",计算机出的是%s" % computer) print("平局") ping=ping+1 elif (player == 0 and computer == 1) or (player == 1 and computer == 2) or (player == 2 and computer == 0): print("你出的是:%s" % player + ",计算机出的是%s" % computer) print("我赢了") win = win + 1 else: print("你出的是:%s" % player + ",计算机出的是%s" % computer) print("你输了") fail = fail + 1 if fail != 0 and win+fail+ping>3 and winRate < 0.5: if (win / (win + fail)) <= 0.001: print("你实在是太愚蠢了,已强行开启高级作弊器") cheat = 1 else : print("你太菜了,是否使用提示使用选择Y/y") prompt = input() if prompt == 'Y' or prompt == 'y': print("机器人的猜拳情况为剪刀=", scissors, "石头=", stone, "布=", cloth) if scissors > stone and scissors > cloth: print("我推荐你下一句使用石头") elif stone > scissors and stone > cloth: print("我推荐你下一句使用布") else: print("我推荐你下一句使用剪刀") print("是否继续游戏,退出游戏选择n/N,继续游戏请选择任意键")
剪刀石头布(胜率提示)
于 2022-10-20 13:10:35 首次发布