国产精品夜色视频一级区_hh99m福利毛片_国产一区二区成人久久免费影院_伊人久久大香线蕉综合影院75_国产精品久久果冻传媒

您的位置:首頁 >聚焦 >

Python實(shí)現(xiàn)一個(gè)羊人殺小游戲,祝愿看到文章的小伙伴都不是小羊人

2022-12-17 19:48:05    來源:程序員客棧
Python實(shí)現(xiàn)一個(gè)羊人殺小游戲,祝愿看到文章的小伙伴都不是小羊人前言

halo,包子們下午好

最近疫情越來越嚴(yán)重了,很多小伙伴現(xiàn)在應(yīng)該都是小羊人了吧

不要慌,小編的這個(gè)文章是經(jīng)過消毒處理的,所以大家不要擔(dān)心


【資料圖】

今天給大家?guī)淼氖且粋€(gè) 羊人殺

說實(shí)話操作起來還是有那么一點(diǎn)點(diǎn)的難度的,但是大家不用擔(dān)心

作為一個(gè)寵粉狂魔的小編,肯定都給大家準(zhǔn)備好了的

直接上才藝

相關(guān)文件

關(guān)注小編,私信小編領(lǐng)取喲!

當(dāng)然別忘了一件三連喲~~

公眾號(hào):Python日志

源碼領(lǐng)取QQ群:494958217

開發(fā)工具

Python版本:3.7.8

相關(guān)模塊:

random模塊;

json模塊;

time模塊;

以及一些python自帶的模塊。

效果展示我是一個(gè)小羊人

我們的代號(hào)是 0 獲得勝利的話就要去感染1 2 3 號(hào)小伙伴

任務(wù)

任務(wù)就是感染那些不是陽性小伙伴

代碼展示

導(dǎo)入模塊

from random import randint, choicefrom time import sleepimport json

介紹

print("4個(gè)好朋友一起混管,然后羊了,白天大家投票選出小羊人,選擇把他拉走隔離??!")print("歡迎來到羊人殺!")try:    fs = open("shengli.dat")    fs.close()except FileNotFoundError:    lll = {"l": 0,      "p": 0,      "114514": 0,      "all": 0,      "jsfs": 0,      "ch": [],      "yy": 0      }    with open("shengli.dat", "w") as f_obj:        json.dump(lll, f_obj)else:    with open("shengli.dat") as f_obj:        lll = json.load(f_obj)print("小羊人勝場:", lll["l"])print("陰性勝場:", lll["p"])print("你死的次數(shù):", lll["114514"])print("總場次:", lll["all"])print("識(shí)破的小羊人人數(shù)量:", lll["yy"])

電腦玩家名字隨機(jī)

if len(lll["ch"]) != 0:    print("稱號(hào):" + ",".join(lll["ch"]))sleep(0.3)a = ["陰性 ", "陰性", "小羊人", "女巫"]  # 身份,用列表表示(用元組也行)xing = ("王", "李", "張", "劉", "徐", "馮", "袁", "鄧", "韓", "杜", "樸", "金", "逄")zhongjian = ("既", "海", "若", "樹", "麗", "虎", "涵")zuihou = ("羽", "生", "茵", "芹", "喬", "智", "麗")disi = ("璽", "霍", "獲", "嵐", "吾", "樂", "空", "陣")p1 = choice(xing) + choice(zhongjian)p2 = choice(xing) + choice(zhongjian) + choice(zuihou)p3 = choice(xing) + choice(zhongjian) + choice(zuihou) + choice(disi)

開始游戲

wanjianame = [p1, p2, p3]pl = ["0", "1", "2", "3"]  # 玩家player0 = choice(a)  # 設(shè)置玩家身份ar = a.index(player0)print("等待玩家進(jìn)入游戲中...")sleep(randint(0, 3))print("玩家1" + "(" + p1 + ")加入游戲")sleep(randint(0, 3))print("玩家2" + "(" + p2 + ")加入游戲")sleep(randint(0, 3))print("玩家3" + "(" + p3 + ")加入游戲")print("玩家已全齊,開始游戲倒計(jì)時(shí)")timer = 3for i in range(3):    print(timer, end=" ")    timer -= 1  sleep(1)player1 = choice(a)ae = a.index(player1)player2 = choice(a)ac = a.index(player2)player3 = choice(a)ad = a.index(player3)while ae == ar or ae == ac or ae == ad or ad == ac or ad == ar or ac == ar:    player1 = choice(a)    ae = a.index(player1)    player2 = choice(a)    ac = a.index(player2)    player3 = choice(a)    ad = a.index(player3)ap = [player0, player1, player2, player3]langren = ap.index("小羊人")nvwu = ap.index("女巫")print("\n你的身份是" + player0)nvwuhuozhe = Truenvwuyouduyao = Truenvwujiuming = Truedays = 0

總結(jié)

因?yàn)榇a量稍微有一點(diǎn)點(diǎn)大,所以就沒有全部都放在這里給大家展示

如果有小伙伴需要源碼的可以看下方聯(lián)系方式哈

源碼領(lǐng)取

【領(lǐng)取方式】

QQ掃碼添加

【依次發(fā)放,請勿重復(fù)添加】

添加時(shí)備注“公眾號(hào)”

即可免費(fèi)領(lǐng)取學(xué)習(xí)資料和課程

或者直接搜索QQ群:494958217 領(lǐng)取

Python日志資料領(lǐng)取加群QQ群:494958217

關(guān)鍵詞: 開始游戲 準(zhǔn)備好了

相關(guān)閱讀