def divine(self): idx = chainer_predict_kai.estimate_wolf(self.info, self.base_info, self.infer_net) if (idx != -1): return random.choice(idx) vote_list = [] for i, status in enumerate(self.base_info['statusMap'].values(), 1): if (status == 'ALIVE' and i != self.base_info['agentIdx'] and (i not in self.voted_list)): vote_list.append(i) idx = random.choice(vote_list) self.voted_list.append(idx) return idx
def vote(self): # 霊媒師の場合、自分黒判定or偽霊媒師が現れた時は投票 if (self.base_info['myRole'] == 'MEDIUM'): for i in self.called_divined: if (i[1] == self.base_info['agentIdx'] and i[2] == 'WEREWOLF'): idx = i[0] return idx for i in self.called_comingout: if (i[1] == 'MEDIUM'): idx = i[0] return idx # 裏切者場合、seerに投票 if (self.base_info['myRole'] == 'POSSESS'): for i in self.called_comingout: if (i[1] == 'MEDIUM'): idx = i[0] return idx # 1. 殺された人or自分を人狼とdivineした占い師が生きてたら無条件で投票 for i in self.called_divined: if (i[2] == 'WEREWOLF' and (i[1] == self.base_info['agentIdx'] or i[1] in self.dead)): if (self.base_info['statusMap'][str(i[0])] == 'ALIVE'): idx = i[0] return idx # 2. 2日目以降で霊媒師COが2以上の場合ローラー if (self.base_info['day'] >= 2 and self.medium_co_num >= 2): for i in self.called_comingout: if (i[1] == 'MEDIUM' and self.base_info['statusMap'][str(i[0])] == 'ALIVE'): idx = i[0] return idx # 3. NN使って投票 #x = tuple(np.array(self.info)) idx = chainer_predict_kai.estimate_wolf(self.info, self.base_info, self.infer_net) if (idx != -1): return random.choice(idx) # 4. わかんねえからランダム投票 vote_list = [] for i, status in enumerate(self.base_info['statusMap'].values(), 1): if (status == 'ALIVE' and i != self.base_info['agentIdx']): vote_list.append(i) idx = random.choice(vote_list) return idx
def attack(self): if (self.menber_num == 5): not_attack_list = [] attack_list = [] seer_killed = False for i in self.called_divined: if (self.base_info['statusMap'][str(i[0])] == 'ALIVE'): if (i[1] == self.base_info['agentIdx'] and i[2] == 'WEREWOLF'): seer_killed = True return i[0] if (seer_killed): self.like_possess.append(i[0]) not_attack_list.append(i[0]) not_attack_list.append(i[1]) for i in range(1, self.menber_num + 1): if (i not in not_attack_list and self.base_info['statusMap'][str(i)] == 'ALIVE'): attack_list.append(i) if (attack_list != []): return random.choice(attack_list) else: # リストが空だったらnot_attack_listの制約無くす for i in range(1, self.menber_num + 1): if (self.base_info['statusMap'][str(i)] == 'ALIVE'): attack_list.append(i) return random.choice(attack_list) idx = chainer_predict_kai.estimate_wolf(self.info, self.base_info, self.infer_net) if (idx != -1): wolf_attack = [] for i in range(1, len(self.base_info['statusMap']) + 1): if ((i not in idx) and (i not in self.voted_list)): wolf_attack.append(i) if (wolf_attack != []): return random.choice(wolf_attack) # 4. わかんねえからランダムattack attack_list = [] for i, status in enumerate(self.base_info['statusMap'].values(), 1): if (status == 'ALIVE' and i != self.base_info['agentIdx'] and (str(i) not in self.base_info['roleMap'].keys())): attack_list.append(i) idx = random.choice(attack_list) return idx
def attack(self): idx = chainer_predict_kai.estimate_wolf(self.info, self.base_info, self.infer_net) if (idx != -1): wolf_attack = [] for i in range(1, len(self.base_info['statusMap']) + 1): if ((i not in idx) and (i not in self.voted_list)): wolf_attack.append(i) if (wolf_attack != []): return random.choice(wolf_attack) # 4. わかんねえからランダムattack attack_list = [] for i, status in enumerate(self.base_info['statusMap'].values(), 1): if (status == 'ALIVE' and i != self.base_info['agentIdx'] and (str(i) not in self.base_info['roleMap'].keys())): attack_list.append(i) idx = random.choice(attack_list) return idx
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()