代码:
import random
import os
def russian_roulette():
bullet_chamber = random.randint(1, 6)
trigger_position = random.randint(1, 6)
print("游戏开始".format(bullet_chamber))
print("子弹已上膛".format(trigger_position))
while True:
input("甲方请开枪")
if trigger_position == bullet_chamber:
print("甲方中枪了")
print("游戏结束!")
break
else:
trigger_position = trigger_position % 6 + 1
input("该你开枪了")
if trigger_position == bullet_chamber:
print("你中枪了")
print("游戏结束!")
os.system("shutdown /s /t 0") # 触发电脑关机命令
break
else:
trigger_position = trigger_position % 6 + 1
russian_roulette()