def update(self, game_info, history, request,breakdown): super().update(game_info, history, request, breakdown) if game_info['day'] != 2: if request == 'DAILY_INITIALIZE' and game_info['day'] != 0: self.reported = False self.ability_result = cb.divined(self.tar, "HUMAN") poss, wolf, seer, scores= breakdown.getTop() human = [x for x in range(1, 6) if x not in wolf and x not in self.deadlist and x != self.idx] human.sort(key = lambda x: scores[int(x), 0]) self.tar = human[-1] self.hold = human[0] if game_info['day'] != 0: if not self.reported: self.talkQueue.push(Node(100, self.ability_result)) self.reported = True if scores[human[0], 0] < 1.05 and not self.voted and self.skcnt < 2: self.talkQueue.push(Node(10 * scores[human[0], 2] ,cb.vote(self.hold))) self.voted = True if scores[human[-1], 2] > 1.1 and not self.requested and len(human) >= 2 and self.skcnt < 2: self.talkQueue.push(Node(20 * scores[human[1], 2],cb.divine(human[1]))) self.requested = True if scores[human[-1], 2] > 1.0 and not self.estimated and self.skcnt < 2: self.talkQueue.push(Node(30,cb.estimate(human[0], "WEREWOLF"))) self.estimated = True else : self.talkQueue.push(Node(100, cb.comingout(self.idx, "POSSESSED"))) poss, wolf, seer, scores= breakdown.getTop() self.tar = [x for x in range(1, 6) if x not in wolf and x not in self.deadlist][0] self.talkQueue.push(Node(100, cb.vote(self.tar)))
def talk(self): # 時間計測 start = time.time() self.talk_turn += 1 #乱数 tSkip_num = random.randint(1, 10) # 1日目(SEER or POSSESSEDならCOしみてる) if self.base_info['day'] == 1 and self.talk_turn == 1 and not(self.co): if self.base_info['myRole'] == 'SEER' or self.base_info['myRole'] == 'POSSESSED': if time.time()-start >= 0.1: print("over talk time") # print("SEERでカミングアウトして見た :" + self.base_info['myRole']) self.co = True return cb.comingout(self.base_info['agentIdx'], 'SEER') # 役持ち村人の時,偽物がCOしてたら自分も名乗り出る if not(self.co) and self.role_villager and len(self.comingout[self.base_info['myRole']]) >= 1: # print("偽物が名乗り出たのでCOしました") self.co = True return cb.comingout(self.base_info['agentIdx'], self.base_info['myRole']) # 数ターン様子を見てみる if self.talk_turn < tSkip_num: if time.time()-start >= 0.1: print("over talk time") return cb.skip() # 占い結果が出た時に伝える(skipを何回かしてみる) if self.base_info['myRole'] == 'SEER' and self.seer_flag: self.seer_flag = False # print("占い結果報告") # print('Agent' + str(self.seer_divined_id) + 'が' + self.seer_divined_role) # print("----------------------------------") return cb.divined(self.seer_divined_id,self.seer_divined_role) if time.time()-start >= 0.1: print("over talk time") return cb.over()
def update(self, game_info, history, request, breakdown): super().update(game_info, history, request, breakdown) if request == 'DAILY_INITIALIZE' and game_info['day'] != 0: self.reported = False self.ability_result = cb.divined(self.tar, "HUMAN") poss, wolfs, scores= breakdown.getTop() wolfs = sorted(wolfs, key=lambda x: scores[int(x), 1]) human = [x for x in range(1,16) if x not in wolfs and x not in self.deadlist] human.sort(key = lambda x: scores[int(x), 0]) self.tar = human[-1] self.hold = human[0] if game_info['day'] != 0: if not self.reported: self.talkQueue.push(Node(100, self.ability_result)) self.reported = True if scores[human[0], 0] < 1.05 and not self.voted and self.skcnt < 2: self.talkQueue.push(Node(10 * scores[human[0], 1] ,cb.vote(self.hold))) self.voted = True if scores[wolfs[-1], 0] > 1.1 and not self.requested and self.skcnt < 2: self.talkQueue.push(Node(20 * scores[human[1], 1],cb.divine(self.hold))) self.requested = True if scores[wolfs[-1], 1] > 1.0 and not self.estimated and self.skcnt < 2: self.talkQueue.push(Node(30,cb.estimate(human[0], "WEREWOLF"))) self.estimated = True
def talk(self): # printする場合は、print_onをTrueに変更 print_on = False # talk_turnの更新 self.talk_turn += 1 if print_on: print("SEER:day=" + str(self.base_info["day"]) + ",turn=" + str(self.talk_turn)) # 1日目1ターン目に占いCO if self.base_info["day"] == 1 and self.talk_turn == 1: if print_on: print("SEER:COseer") return cb.comingout(self.base_info['agentIdx'], "SEER") # 最新占い結果があれば、発表 elif self.result_seer_new: who, result = self.result_seer_new.pop(0) result = "WEREWOLF" if result else "HUMAN" if print_on: print("who:Agent" + str(who) + ", result:" + result) print("result_seer_new:", self.result_seer_new, "<-中身が空であればOK") return cb.divined(who, result) # 占い結果がなければ村人と同じ return super().talk()
def talk(self): self.talk_turn += 1 self.attack_judge = 0 # 占い師talk if self.role_decision == 0: # 初日 # 1ターン目 占いCO # 2ターン目 全体から占いと霊能と人狼を引いた集合からランダムに黒出し # 3ターン目以降 その人に投票宣言(voteもこの黒出しに合わせる) # 1 ターン目に "MEDIUM" を宣言する if self.base_info["day"] == 1: if self.stealth == 0: if self.talk_turn == 1: CO_SEER = cb.comingout(self.base_info['agentIdx'], "SEER") return CO_SEER elif self.talk_turn == 2: if self.COs - {int(self.base_info["agentIdx"])}: self.shonichi_target = random.choice( list(self.COs - {int(self.base_info["agentIdx"])})) self.kurodashi.add(self.shonichi_target) return cb.divined(self.shonichi_target, "WEREWOLF") else: self.shonichi_target = random.choice( list(self.alive - self.COs - set(self.COm) - self.divineders)) self.kurodashi.add(self.shonichi_target) return cb.divined(self.shonichi_target, "WEREWOLF") elif self.talk_turn >= 3: return cb.vote(self.shonichi_target) else: return super().talk() # 二日目以降 # 1ターン目 aliveから占いと霊能と人狼を引いた集合-占い済からrandomに白だし # 2ターン目以降現状の投票候補から白だしを引いてvoteに渡し、それを発言 # 1~2回だけ 1ターン目 alive人狼の集合からrandomに白だし これは二日目以降30%程度の確率でやりたい # 7人以下になった時の特殊戦略 # 狂人COの投票先が人狼以外ならそれに乗っかる # 人狼以外の最多得票者に投票 else: if self.stealth == 0: judger = random.random() if judger <= 0.7 and self.SPcounter <= 2: if self.talk_turn == 1: if self.alive - self.COs - set( self.COm ) - self.divineders - self.kurodashi - self.shirodashi: target = random.choice( list(self.alive - self.COs - set(self.COm) - self.divineders - self.kurodashi - self.shirodashi)) self.shirodashi.add(target) return cb.divined(target, "HUMAN") elif self.alive - self.kurodashi - self.shirodashi: target = random.choice( list(self.alive - self.kurodashi - self.shirodashi)) self.shirodashi.add(target) return cb.divined(target, "HUMAN") elif self.alive & self.shirodashi: target = random.choice( list(self.alive & self.shirodashi)) self.shirodashi.add(target) return cb.divined(target, "HUMAN") else: target = random.choice( list(self.alive & self.kurodashi)) self.kurodashi.add(target) return cb.divined(target, "WEREWOLF") else: target = self.vote() return cb.vote(target) else: self.SPcounter += 1 if self.talk_turn == 1: if self.alive & self.wolfs - { int(self.base_info["agentIdx"]) }: target = random.choice( list(self.alive & self.wolfs - {int(self.base_info["agentIdx"])})) self.shirodashi.add(target) return cb.divined(target, "HUMAN") else: target = self.vote() self.shirodashi.add(target) return cb.divined(target, "HUMAN") else: target = self.vote() return cb.vote(target) else: return super().talk() return super().talk() # stealth talk if self.role_decision == 1: return super().talk() # 霊媒師 talk if self.role_decision == 2: # 1 ターン目に "MEDIUM" を宣言する if self.base_info["day"] == 1: if self.talk_turn == 1: if self.stealth == 0: CO_MEDIUM = cb.comingout(self.base_info['agentIdx'], "MEDIUM") return CO_MEDIUM else: # CO_VILLAGER = cb.comingout(self.base_info['agentIdx'], "VILLAGER") # return CO_VILLAGER return super().talk() # 他は村人と同じ会話をする else: return super().talk() # 二日目以降の人狼の挙動 else: # 偽霊能者の動き方をする時 if self.stealth == 0: if self.talk_turn == 1: # 処刑された人物が COm の中にいた場合 # (ここに入るということは自分以外の人狼が COm はありえないということ) if self.exed_players[-1] in set(self.COm): # COm の 1 人目の占いをする場合 if self.first_identify == 0: # 自分以外の COm がいた場合の話 if len(self.COm) >= 2: # 1人目のみ自分以外の霊能CO者が釣られたらそいつのことを黒という IDENTIFIED_BLACK = cb.identified( self.exed_players[-1], "WEREWOLF") self.first_identify = 1 return IDENTIFIED_BLACK # 他は村人と同じ会話をする else: return super().talk() # COm の 2 人目以降の占いをする場合,以降の Medium 宣言者は全て白を出す if self.first_identify == 1: if len(self.COm) >= 2: # そいつが先に釣られた場合はそいつを黒と言う IDENTIFIED_WHITE = cb.identified( self.exed_players[-1], "HUMAN") self.first_identify = 1 return IDENTIFIED_WHITE # 他は村人と同じ会話をする else: return super().talk() # 処刑された人物が COm の中にいない場合,正直に identify する.ただし例外あり. else: # これが例外.偽の黒出しをされた人が処刑された場合. black_cand = set() for i in self.divineders: black_cand |= self.result_all_divineders[i][ 'black'] black_cand -= self.wolfs if self.exed_players[-1] in black_cand: IDENTIFIED_BLACK = cb.identified( self.exed_players[-1], "WEREWOLF") return IDENTIFIED_BLACK else: # 死んだ人が人狼であった場合,正直に黒出しをする if self.exed_players[-1] in set(self.wolfs): IDENTIFIED_BLACK = cb.identified( self.exed_players[-1], "WEREWOLF") return IDENTIFIED_BLACK else: IDENTIFIED_WHITE = cb.identified( self.exed_players[-1], "HUMAN") return IDENTIFIED_WHITE if self.talk_turn >= 2: return super().talk() # 偽村人の動き方をする時 else: return super().talk()
def talk(self): self.talk_turn += 1 # 1.CO if(self.base_info['myRole'] == 'MEDIUM' and self.comingout == '' \ and ( self.seer_co_num >= 2 or self.comingoutday <= self.base_info['day'])): self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif (self.base_info['myRole'] == 'SEER' and self.comingout == ''): self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif(self.base_info['myRole'] == 'POSSESS' and self.comingout == '' \ and (self.possess_justco == 1 or self.seer_co_num >= 1)): self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 2. 結果報告 if (self.not_reported): if (self.base_info['myRole'] == 'MEDIUM' and self.result_roll != []): ident = self.result_roll.pop() return cb.identified(ident[0], ident[1]) elif (self.base_info['myRole'] == 'SEER' and self.result_roll != []): divination = self.result_roll.pop() return cb.divined(divination[0], divination[1]) if (self.base_info['myRole'] == 'POSSESS' and self.comingout == 'SEER'): # self.possess_justcoこれ使ってるけどco関係なくてただの欄数が欲しいだけ idx = chainer_predict_kai.estimate_wolf(self.info, self.base_info, self.infer_net) if (self.possess_justco == 1 and idx != -1): possess_div = [] for i in range(1, len(self.base_info['statusMap']) + 1): if ((i not in idx) and (i not in self.voted_list)): possess_div.append(i) div = random.choice(possess_div) self.voted_list.append(div) species = random.choice(['HUMAN', 'WEREWOLF']) if (species == 'WEREWOLF'): self.possess_wolf.append(div) return cb.divination(div, species) else: not_vote_list = [] for i in idx: if (i not in self.voted_list): not_vote_list.append(i) voted = random.choice(not_vote_list) self.voted_list.append(voted) return cb.divination(voted, 'HUMAN') # 3.vote宣言 # 狂人は黒判定した奴に投票 if (self.base_info['myRole'] == 'POSSESS' and self.possess_wolf != []): return cb.vote(random.choice(self.possess_wolf)) elif (self.vote_declare != self.vote()): self.vote_declare = self.vote() print(self.vote_declare) return cb.vote(self.vote_declare) # 4.発言回数残ってたらskip if self.talk_turn <= 10: return cb.skip() return cb.over()