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'] == 'POSSESSED' and self.comingout == '': 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.comingout(ident[0], ident[1]) # 3.vote宣言 if(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()
def talk(self): self.talk_turn += 1 # 1.comingout anyway if 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'] == 'POSSESSED' and self.comingout == '': self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 2.report if self.base_info['myRole'] == 'SEER' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'POSSESSED' and self.not_reported: self.not_reported = False # FAKE DIVINE # highest prob ww in alive agents idx = self.highest(1) self.myresult = 'DIVINED Agent[' + \ "{0:02d}".format(idx) + '] ' + 'HUMAN' return self.myresult # 3.declare vote if not yet if self.vote_declare != self.vote(): self.vote_declare = self.vote() return cb.vote(self.vote_declare) # 4. skip if self.talk_turn <= 10: return cb.skip() return cb.over()
def talk(self): self.talk_turn += 1 #comingout if 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"] == "POSSESSED" and self.comingout == "": self.comingout = "SEER" return cb.comingout(self.base_info["agentIdx"], self.comingout) #report if self.base_info["myRole"] == "SEER" and self.not_reported: self.not_reported = False return self.myresult elif self.base_info["myRole"] == "POSSESSED" and self.not_reported: self.not_reported = False return self.myresult #declare vote if self.vote_declare != self.vote(): self.vote_declare = self.vote() return cb.vote(self.vote_declare) #skip if self.talk_turn <= 10: return cb.skip() return cb.over()
def __init__(self, game_info, game_setting): super().__init__(game_info,game_setting) self.comingout_role = '' self.reported = False self.ability_result = '' self.divinelist = [] self.talkQueue.push(Node(150, cb.comingout(self.idx, "SEER")))
def talk(self): #print("Talking phase: ") # If someone has usurpated my role (seer, medium or bodyguard) if self.co_flag == True and self.already_co == False: talk = cb.comingout(self.id, self.role) self.already_co = True # If not a WW team player create arguments with other player num_lies elif self.role != "WEREWOLF" and self.role != "POSSESSED": lie = self.retrieveLies() if lie is not None: t = lie[0] m = lie[1] talk = cb.because(m, cb.vote(t)) else: talk = cb.skip() # If WW team player create arguments with correct accusations (fake_lies) elif self.role == "WEREWOLF" or self.role == "POSSESSED": lie = self.retrieveLies() if lie is not None: t = lie[0] m = lie[1] talk = cb.because(m, cb.vote(t)) else: talk = cb.skip() return talk
def talk(self): """ 霊媒のCO戦略 定石:基本ステルス(村人と同じ)、ただし霊媒結果●が出たら即時COする 基本は村人と同じ """ print("TALK TURN:", self.talk_turn) # ===霊媒特殊処理ここから # ステルスモード解除してCO if self.stealth == True: # 1日目からロケットCO self.stealth = False return cb.comingout(self.base_info['agentIdx'], "MEDIUM") # 一度ステルスモード解除されていたら、resultを全部ぶちまける if self.stealth == False and len(self.result) > 0: # 最後の結果を取り出してIDENTIFIED発言 last_res = self.result.pop(-1) return last_res # 何もなければOver return super().talk()
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): self.talk_turn += 1 if self.game_setting['playerNum'] == 15: if self.base_info['myRole'] == 'SEER' and self.comingout == '': #self.comingout = 'SEER' #return cb.comingout(self.base_info['agentIdx'], self.comingout) pass elif self.base_info['myRole'] == 'MEDIUM' and self.comingout == '': self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'POSSESSED' and self.comingout == '': #self.comingout = 'SEER' pass #return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'WEREWOLF' and self.comingout == '': self.comingout = 'SEER' alive_list = [] for i in range(1, self.game_setting['playerNum'] + 1): if i == self.base_info['agentIdx']: pass elif self.base_info['statusMap'][str(i)] == 'ALIVE': alive_list.append(i) return cb.comingout(random.choice(alive_list), self.comingout) else: if self.base_info['myRole'] == 'SEER' and self.comingout == '': #self.comingout = 'SEER' pass return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info['myRole'] == 'MEDIUM' and self.comingout == '': self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'POSSESSED' and self.comingout == '': #self.comingout = 'SEER' #return cb.comingout(self.base_info['agentIdx'], self.comingout) pass elif self.talk_turn <= 2: return cb.skip() return cb.over()
def talk(self): try: msg = "" if self.last_guarded is not None: self.last_guarded = int(self.last_guarded) self._player_perspective.update_total_vote_count() if self._player_perspective.agent_2_total_votes[ self. player_id] >= self._game_settings._player_num / 2 and self.mode == DEFAULT_MODE: self.mode = RISK_MODE self.self_guard_score = np.inf print("BODYGUARDMSG:Risk Mode") if self.mode == RISK_MODE: msg1 = self.get_agent_string( self.player_id) + " " + "AND (" + cb.comingout( self.player_id, "BODYGUARD") + ")" for agent, voting_agents in self.succ_guarded: agent = int(agent) msg1 += "AND (BECAUSE (AND (" + cb.guarded( agent ) + ")(NOT (ANY ATTACKED " + self.get_agent_string( agent) + "))) (" + cb.comingout(agent, "VILLAGER") + "))" self.self_guard_score = self.self_guard_score - 3 if self.self_guard_score is not None else 3 self.mode = POST_RISK_MODE # elif len(self.succ_guarded) > 0 and self.last_attacked == None: # print("IN TALK GUARD: ") # print(self.succ_guarded[-1], self.last_guarded) # msg = self.get_agent_string(self.player_id) + " BECAUSE ( AND " # for (agent,voters) in self.succ_guarded: # msg += "(" + self.get_agent_string(agent) + " VOTED " + "Agent" + str(self.last_guarded) + ")" # msg += ") (AND ("+cb.comingout(self.last_guarded, "VILLAGER")+")" # msg += "(OR " # for (agent, voters) in self.succ_guarded: # msg += "("+cb.comingout(int(agent), "WEREWOLF")+")" # msg += "))" #TODO: # pick most aggressive voter or one that was in most of other votes or union except: return Villager.talk(self) # set special mode in order to prevent coming out multiple times ? return Villager.talk(self) if msg == "" else msg
def talk(self): self.talk_turn += 1 # 1.comingout anyway if 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'] == 'POSSESSED' and self.comingout == '': self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 2.report if self.base_info['myRole'] == 'SEER' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'POSSESSED' and self.not_reported: self.not_reported = False # FAKE DIVINE # highest prob ww in alive agents p = -1 idx = 1 p0_mat = self.predicter_5.ret_pred_wx(2) for i in range(1, 6): p0 = p0_mat[i-1, 1] if self.base_info['statusMap'][str(i)] == 'ALIVE' and p0 > p: p = p0 idx = i self.myresult = 'DIVINED Agent[' + \ "{0:02d}".format(idx) + '] ' + 'HUMAN' return self.myresult # 3.declare vote if not yet if self.vote_declare != self.vote(): self.vote_declare = self.vote() return cb.vote(self.vote_declare) # 4. skip if self.talk_turn <= 10: return cb.skip() return cb.over()
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 talk(self): """ 狼のCO戦略 ステルス? """ # 村人としての発言 ret_as_villager = super().talk() # ステルス解除、カミングアウト # は吊られそうにならない限り行わないことにする if self.stealth == True and False: self.stealth = False return cb.comingout(self.base_info['agentIdx'], "MEDIUM") # 吊られそうならカミングアウト print("HATRED LIST:", self.hate_who) if self.stealth and isMostFrequent(self.hate_who, int(self.base_info["agentIdx"])): self.stealth = False if self.player_size == 5: return cb.comingout(self.base_info["agentIdx"], "SEER") return cb.comingout(self.base_info["agentIdx"], "SEER") # 5人村なら初手占いCO #はしない if self.stealth and self.player_size == 5 and False: self.stealth = False return cb.comingout(self.base_info["agentIdx"], "SEER") if self.stealth == False and len( self.result_seer) > 0 and self.player_size == 5: # 最後の結果を取り出してdivined発言 last_res = self.result_seer.pop(0) print(last_res) return last_res # 何もなければOver return ret_as_villager
def whisper(self): if (self.base_info['day'] == 0): # 最初にwisperで何騙りするか決定 choice_roll = random.choice(range(10)) if (choice_roll < 3): self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif (choice_roll < 4): self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) else: self.comingout = 'VILLAGER' return cb.comingout(self.base_info['agentIdx'], self.comingout) if (self.base_info['day'] == 0 and self.result_wisper != []): for i in self.result_wisper: if (i[1] == 'WEREWOLF'): self.comingout = 'VILLAGER' return cb.comingout(self.base_info['agentIdx'], self.comingout) return cb.over()
def whisper(self): """ 秘密会話 攻撃したい先を言って、一致しなかったら相手に合わせる 襲撃先選択 1.最も占いらしいやつ 2.昨日の護衛結果が失敗だったら最も狩人らしいやつ """ self.whisper_turn += 1 # 生存者の確認 self.alive = [] for i in range(self.player_size): # 1-origin i += 1 if self.base_info["statusMap"][str(i)] == "ALIVE": self.alive.append(str(i)) if self.base_info["day"] == 0: if self.whisper_turn == 1: return cb.comingout(self.base_info["agentIdx"], "VILLAGER") else: return cb.over() # 候補者セット #cand = set(self.alive)-{str(int(self.base_info["agentIdx"]))} cand = self.rfestimator.decide_action("attack") print(set([self.base_info["agentIdx"]]), self.rfestimator.rec.game_info["dead"], self.wolfs) cand = cand - set([ self.base_info["agentIdx"] ]) - self.rfestimator.rec.game_info["dead"] - self.wolfs # 襲撃先の吟味 role = "SEER" if self.attack_success: self.todays_vote = int(self.predictor.role_est("SEER", cand)) if self.whisper_turn == 1 and self.base_info["day"] < 3: return cb.estimate(self.todays_vote, role) if self.whisper_turn == 2: return cb.attack(self.todays_vote) else: # 昨日失敗してたら狩人がまだ生きてるということなので role = "BODYGUARD" self.todays_vote = int(self.predictor.role_est("BODYGUARD", cand)) if self.whisper_turn == 1 and self.base_info["day"] < 3: return cb.estimate(self.todays_vote, role) if self.whisper_turn == 2: return cb.attack(self.todays_vote) return cb.over()
def whisper(self): #print(self.day,"whisperchat") if self.whisper_count == 0: self.whisper_count += 1 return cb.attack(self.atackaction) elif self.whisper_count == 1: self.whisper_count += 1 if self.day == 0: return cb.comingout(self.index, "WEREWOLF") else: return cb.skip() elif self.whisper_count == 2: self.whisper_count += 1 if self.lastatack == None: return cb.over() else: return 'ATTACKED Agent[' + "{0:02d}".format( self.lastatack) + ']' return cb.skip()
def talk(self): """ 占いのCO戦略 初日即CO """ # ステルス解除、カミングアウト print("SEER: " + str(self.base_info["day"])) if self.stealth == True: print("SEER: stealth mode disabled") self.stealth = False return cb.comingout(self.base_info['agentIdx'], "SEER") # ステルス解除後は履歴垂れ流し if self.stealth == False and len(self.result) > 0: # 最後の結果を取り出してdivined発言 last_res = self.result.pop(0) print(last_res) return last_res # 村人としての発言 return super().talk()
def talk(self): # printする場合は、print_onをTrueに変更 print_on = False # talk_turnの更新 self.talk_turn += 1 # 1日目2ターン目に霊媒CO if self.base_info["day"] == 1 and self.talk_turn == 2: if print_on: print("SEER:COmedium") return cb.comingout(self.base_info['agentIdx'], "MEDIUM") # 最新霊媒結果があれば、発表 elif self.result_medium_new: who, result = self.result_medium_new.pop(0) result = "WEREWOLF" if result else "HUMAN" if print_on: print("who:Agent" + str(who) + ", result:" + result) print("result_medium_new:", self.result_medium_new, "<-中身が空であればOK") return cb.identified(who, result) # 霊媒結果がなければ村人と同じ return super().talk()
def talk(self): """ 狂人のCO戦略 初日即占いとしてCO """ """ 村人は3,狼は2 """ print("POSSESSEDtalk", self.talk_turn) if self.base_info["day"] == 1: if self.talk_turn == 0: self.stealth = False print("POSSESSED, false comingout") return cb.comingout(self.base_info['agentIdx'], "SEER") if self.talk_turn == 1: info = self.rfestimator.rec.game_info seers = info["COseer"] - set([self.base_info["agentIdx"]]) """ 占い黒出しは無効化 """ #if len(seers)>0: # target = self.predictor.role_est("SEER", seers) # return cb.divined(target,"WEREWOLF") #else: #target = self.predictor.role_est("WEREWOLF", self.alive-seers-info["dead"]-self.absolute_white) #self.absolute_white.add(target) #return cb.divined(target,"HUMAN") # ステルス解除後は履歴垂れ流し if self.stealth == False and len(self.result) > 0: # 最後の結果を取り出してdivined発言 last_res = self.result.pop(0) print(last_res) return last_res # 何もなければOver return super().talk()
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 # 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.divination(divination[0], divination[1]) if(self.base_info['myRole'] == 'POSSESS' and self.comingout != ''): # self.possess_justcoこれ使ってるけどco関係なくてただの欄数が欲しいだけ # idx = chainer_predict.estimate_wolf(self.info, self.base_info) idx = random.shuffle(range(len(self.base_info['agentIdx']))+1) 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()
def talk(self): if self.game_setting['playerNum'] == 15: self.talk_turn += 1 # 1.comingout anyway if 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'] == 'MEDIUM' and self.comingout == '': self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'POSSESSED' and self.comingout == '': if self.predicter_15.num_seer() < 2 and rand() < 0.5: self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'WEREWOLF' and self.comingout == '' and self.base_info[ "day"] < 4: if self.predicter_15.num_seer() < 2 and rand( ) < 0.1 and self.base_info["day"] == 2: self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.predicter_15.num_seer( ) > 1 and self.predicter_15.num_medium() < 2 and rand() < 0.1: self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 2.report if self.base_info['myRole'] == 'SEER' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'MEDIUM' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'POSSESSED' and self.not_reported: self.not_reported = False # FAKE if self.comingout == 'SEER': return self.possessed_seer_result() elif self.comingout == 'MEDIUM': return self.fake_medium_result() elif self.base_info['myRole'] == 'WEREWOLF' and self.not_reported: self.not_reported = False # FAKE if self.comingout == 'SEER': return self.werewolf_seer_result() elif self.comingout == 'MEDIUM': return self.fake_medium_result() # 3.declare vote if not yet if self.vote_declare != self.vote(): self.vote_declare = self.vote() return cb.vote(self.vote_declare) # 4. skip if self.talk_turn <= 10: return cb.skip() return cb.over() else: self.talk_turn += 1 # 1.comingout anyway if 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'] == 'MEDIUM' and self.comingout == '': self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'POSSESSED' and self.comingout == '': self.comingout = 'WEREWOLF' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 2.report if self.base_info['myRole'] == 'SEER' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'MEDIUM' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'POSSESSED' and self.not_reported: self.not_reported = False # FAKE DIVINE # highest prob ww in alive agents #return self.fake_seer() # 3.declare vote if not yet if self.vote_declare != self.vote(): self.vote_declare = self.vote() return cb.vote(self.vote_declare) # 4. skip if self.talk_turn <= 10: return cb.skip() return cb.over()
def __init__(self, game_info, game_setting): super().__init__(game_info, game_setting) self.comingout_role = '' self.reported = False self.ability_result = '' self.talkQueue.push(Node(100, cb.comingout(self.idx, "MEDIUM")))
def talk(self): #print("talk") #print(self.start,time.time()) #if (time.time() - self.start) >= 0.8: #print("time out") #return cb.over() if not self.islearn: return cb.over() #print(self.actionLog) if self.action_flag: if self.role == "VILLAGER": if self.talk_count == 0: self.talk_count += 1 return cb.estimate(self.action[0], "WEREWOLF") #return 'ESTIMATET Agent[' + "{0:02d}".format(self.action[0]) + '] ' + "WEREWOLF" elif self.talk_count == 1: self.talk_count += 1 return cb.vote(self.action[0]) #return 'VOTE Agent[' + "{0:02d}".format(self.action[0]) + ']' elif self.talk_count == 2: self.talk_count += 1 if self.day <= 3: return cb.skip() return cb.comingout(self.action[0], "WEREWOLF") #return 'COMMINGOUT Agent[' + "{0:02d}".format(self.action[0]) + '] ' + "WEREWOLF" elif self.talk_count == 3: self.talk_count += 1 if len(self.action) >= 2: return cb.estimate(self.action[1], "WEREWOLF") #return 'ESTIMATET Agent[' + "{0:02d}".format(self.action[1]) + '] ' + "WEREWOLF" elif self.talk_count == 4: self.talk_count += 1 if len(self.action) >= 3: return cb.comingout(self.action[-1], "VILLAGER") #return 'COMMINGOUT Agent[' + "{0:02d}".format(self.action[2]) + '] ' + "HUMAN" elif self.talk_count == 5: self.talk_count += 1 if len(self.action) >= 4: return cb.estimate(self.action[-2], "VILLAGER") #return 'ESTIMATET Agent[' + "{0:02d}".format(self.action[3]) + '] ' + "HUMAN" elif self.talk_count == 6: self.talk_count += 1 self.action_flag = False return cb.over() elif self.role == "WEREWOLF": if self.talk_count == 0: self.talk_count += 1 if len(self.action) >= 4: return cb.estimate(self.action[-1], "WEREWOLF") #return 'ESTIMATET Agent[' + "{0:02d}".format(self.action[0]) + '] ' + "WEREWOLF" elif self.talk_count == 1: self.talk_count += 1 if len(self.action) >= 4: return cb.vote(self.action[-1]) #return 'VOTE Agent[' + "{0:02d}".format(self.action[0]) + ']' elif self.talk_count == 2: self.talk_count += 1 if self.day <= 3: return cb.skip() if len(self.action) >= 4: return cb.comingout(self.action[-1], "WEREWOLF") #return 'COMMINGOUT Agent[' + "{0:02d}".format(self.action[0]) + '] ' + "WEREWOLF" elif self.talk_count == 3: self.talk_count += 1 if len(self.action) >= 3: return cb.estimate(self.action[-2], "WEREWOLF") #return 'ESTIMATET Agent[' + "{0:02d}".format(self.action[1]) + '] ' + "WEREWOLF" elif self.talk_count == 4: self.talk_count += 1 if self.day <= 3: return cb.skip() return cb.comingout(self.action[1], "VILLAGER") #return 'COMMINGOUT Agent[' + "{0:02d}".format(self.action[2]) + '] ' + "HUMAN" elif self.talk_count == 5: self.talk_count += 1 if len(self.action) >= 3: return cb.estimate(self.action[2], "VILLAGER") #return 'ESTIMATET Agent[' + "{0:02d}".format(self.action[3]) + '] ' + "HUMAN" elif self.talk_count == 6: self.talk_count += 1 self.action_flag = False return cb.over() else: cb.over() return cb.skip()
def whisper(self): self.whisper_turn += 1 """ 一番最初に霊能COをすることを伝える attack_voteで襲撃の投票をする先を宣言する """ if self.role_decision == 0: # 0 日目 1 ターン目に "SEER" を宣言する if self.base_info["day"] == 0: if self.whisper_turn == 1: return cb.comingout(self.base_info['agentIdx'], 'SEER') if self.whisper_turn == 2: #1 ターン目に whisper の中で仲間の人狼が SEER CO をしていた場合 if len(self.W_COs) >= 2 or len(self.W_COm) >= 1: self.stealth = 1 return cb.comingout(self.base_info['agentIdx'], 'VILLAGER') else: return cb.skip() if self.whisper_turn >= 3: return cb.skip() #return cb.over() return cb.skip() if self.role_decision == 1: # 0 日目 1 ターン目に ステルス挙動 を宣言する if self.base_info["day"] == 0: if self.whisper_turn == 1: return cb.comingout(self.base_info['agentIdx'], 'VILLAGER') if self.whisper_turn >= 2: return cb.skip() #return cb.over() return cb.skip() if self.role_decision == 2: # 0 日目 1 ターン目に "MEDIUM" を宣言する if self.base_info["day"] == 0: if self.whisper_turn == 1: return cb.comingout(self.base_info['agentIdx'], 'MEDIUM') if self.whisper_turn == 2: #1 ターン目に whisper の中で仲間の人狼が MEDIUM CO をしていた場合 if len(self.W_COm) >= 2 or len(self.W_COs) >= 1: self.stealth = 1 return cb.comingout(self.base_info['agentIdx'], 'VILLAGER') if self.whisper_turn >= 3: return cb.skip() #return cb.over() return cb.skip() # 1 日目以降, 1 ターン目に "ATTACK" する対象を宣言する if self.base_info["day"] >= 1: if self.whisper_turn == 1: return cb.attack(self.attack()) else: #return cb.over() return cb.skip() #return cb.over() return cb.skip()
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 whisper(self): if self.base_info['day'] == 0: return cb.comingout(self.base_info['agentIdx'], self.comingout) return cb.skip()
def talk(self): if self.game_setting['playerNum'] == 15: self.talk_turn += 1 # 1.comingout anyway if 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'] == 'MEDIUM' and self.comingout == '': self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'POSSESSED' and self.comingout == '': if np.random.rand() < 0.5: self.comingout = 'SEER' self.pretend_seer = True else: self.comingout = 'MEDIUM' self.pretend_medium = True return cb.comingout(self.base_info['agentIdx'], self.comingout) # 1.2 ww pretend seer elif self.base_info['myRole'] == 'WEREWOLF': if self.pretend_seer and self.base_info[ 'day'] == 1 and self.talk_turn <= 1: self.comingout = 'SEER' # 毎日、毎ターン霊媒師だと訴え続ける elif self.pretend_medium: self.comingout = 'MEDIUM' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 1.3 pp # if self.base_info['statusMap'].values().count('ALIVE') == 4: # if self.base_info['myRole'] # 2.report if self.base_info['myRole'] == 'SEER' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'MEDIUM' and self.not_reported: self.not_reported = False return self.myresult elif self.pretend_seer and self.not_reported: self.not_reported = False # FAKE DIVINE # highest prob ww in alive agents p = -1 idx = 1 p0_mat = self.predicter_15.ret_pred() for i in range(1, 16): p0 = p0_mat[i - 1, 1] if self.base_info['statusMap'][str( i)] == 'ALIVE' and p0 > p: p = p0 idx = i self.myresult = 'DIVINED Agent[' + "{0:02d}".format( idx) + '] ' + 'HUMAN' return self.myresult # 3.declare vote if not yet if self.vote < 0.3: return cb.skip() if self.vote_declare != self.vote(): if self.estimated: self.vote_declare = self.vote() return cb.vote(self.vote_declare) else: self.estimated = True if self.base_info['myRole'] not in [ 'WEREWOLF', 'POSSESSED' ]: return cb.estimate(self.vote(), 'WEREWOLF') else: tmp_myRole, self.base_info['myRole'] = self.base_info[ 'myRole'], 'VILLAGER' fake_vote = self.vote() self.base_info['myRole'] = tmp_myRole return cb.estimate(fake_vote, 'WEREWOLF') # 4. skip if self.talk_turn <= 10: return cb.skip() return cb.over() else: self.talk_turn += 1 # 1.comingout anyway if 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'] == 'MEDIUM' and self.comingout == '': # self.comingout = 'MEDIUM' # return cb.comingout(self.base_info['agentIdx'], self.comingout) elif self.base_info[ 'myRole'] == 'POSSESSED' and self.comingout == '': self.comingout = 'SEER' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 1.2 PP sonoda added if self.base_info["day"] == 2 and self.base_info[ 'myRole'] == 'POSSESSED': self.comingout = 'POSSESSED' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 1.3 PP-Block if self.base_info['day'] == 2 and self.base_info[ 'myRole'] == 'VILLAGER' and self.try_pp_block: self.comingout = 'WEREWOLF' return cb.comingout(self.base_info['agentIdx'], self.comingout) # 2.report if self.base_info['myRole'] == 'SEER' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'MEDIUM' and self.not_reported: self.not_reported = False return self.myresult elif self.base_info['myRole'] == 'POSSESSED' and self.not_reported: self.not_reported = False # FAKE DIVINE # highest prob ww in alive agents p = -1 idx = 1 p0_mat = self.predicter_5.ret_pred_wx(2) for i in range(1, 6): p0 = p0_mat[i - 1, 1] if self.base_info['statusMap'][str( i)] == 'ALIVE' and p0 > p: p = p0 idx = i self.myresult = 'DIVINED Agent[' + "{0:02d}".format( idx) + '] ' + 'HUMAN' return self.myresult # 3.declare vote if not yet if self.vote_declare != self.vote(): self.vote_declare = self.vote() return cb.vote(self.vote_declare) # 4. skip if self.talk_turn <= 10: return cb.skip() return cb.over()