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 update(self, game_info, history, request, breakdown): super().update(game_info, history, request, breakdown) if request == 'DAILY_INITIALIZE': for i in range(history.shape[0]): if history['type'][i] == 'divine': self.reported = False self.ability_result = history['text'][i] print("ab: " + self.ability_result) text = history['text'][i].split() dst = self.getAgentIdx(text[1]) species = text[2] if species == "WEREWOLF": breakdown.updateDeterministic(dst, 2) else: breakdown.updateAttacked(dst) if self.ability_result != '': self.talkQueue.push(Node(100, self.ability_result)) if game_info['day'] != 0: poss, wolf, seer, scores = breakdown.getTop() if poss[0] != 0: wolf = wolf[0] seer = seer[0] poss = poss[0] if scores[wolf, 2] > 1.05 and not self.voted and self.skcnt < 2: self.talkQueue.push( Node(10 * scores[wolf, 2], cb.vote(self.tar))) self.voted = True if scores[wolf, 2] > 1.02 and not self.estimated and self.skcnt < 2: self.talkQueue.push(Node(30, cb.estimate(wolf, "WEREWOLF"))) self.estimated = True
def talk(self): print("Executing talk...") if self.role == "WEREWOLF": if self.player_map[self.current_target]["revenge"] is False: print("Voting on random target") else: print("Voting for revenge!") # Talking against a target has 3 steps: (0) first estimate, # then (1) state your vote, then (>2) start requesting other # agents to vote against the current target if self.player_map[self.current_target]["targetStatus"] == 0: talk = cb.estimate(self.current_target, "WEREWOLF") elif self.player_map[self.current_target]["targetStatus"] == 1: talk = cb.vote(self.current_target) else: talk = cb.request(cb.vote(self.current_target)) self.player_map[self.current_target]["targetStatus"] += 1 else: selected = randomPlayerId(self.base_info) talk = cb.vote(selected) return 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 update(self, game_info, history, request, breakdown): super().update(game_info, history, request, breakdown) if request == 'DAILY_INITIALIZE': for i in range(history.shape[0]): if history['type'][i] == 'divine': self.reported = False self.ability_result = history['text'][i] print("ab: "+self.ability_result) text = history['text'][i].split() dst = self.getAgentIdx(text[1]) species = text[2] if species == "WEREWOLF": breakdown.updateDeterministic(dst, 1) else: breakdown.updateAttacked(dst) if self.ability_result != '': self.talkQueue.push(Node(100, self.ability_result)) poss, wolfs, scores= breakdown.getTop() if poss[0] != 0: wolfs = sorted([x for x in wolfs if x not in self.deadlist and x not in self.divinelist], key=lambda x: scores[int(x), 1]) if len(wolfs) >= 2: self.tar = wolfs[-1] self.hold = wolfs[0] if game_info['day'] != 0: if scores[wolfs[-1], 1] > 1.15 and not self.voted and self.skcnt < 2: self.talkQueue.push(Node(10 * scores[wolfs[-1], 1] ,cb.vote(self.tar))) self.voted = True if scores[wolfs[0], 1] > 1.1 and not self.requested and self.skcnt < 2: self.talkQueue.push(Node(20 * scores[wolfs[0], 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(wolfs[-1], "WEREWOLF"))) self.estimated = True elif len(wolfs) == 1: self.tar = wolfs[0] self.hold = sorted([x for x in range(1,16) if x not in self.deadlist and x not in self.divinelist], key=lambda x: scores[x,1])[-1] if game_info['day'] != 0: if scores[wolfs[-1], 1] > 1.15 and not self.voted and self.skcnt < 2: self.talkQueue.push(Node(10 * scores[wolfs[-1], 1] ,cb.vote(self.tar))) self.voted = True if scores[wolfs[-1], 1] > 1.0 and not self.estimated and self.skcnt < 2: self.talkQueue.push(Node(30,cb.estimate(wolfs[-1], "WEREWOLF"))) self.estimated = True else : self.tar = sorted([x for x in range(1,16) if x not in self.deadlist], key=lambda x: scores[x,1])[-1]
def update(self, game_info, history, request, breakdown): super().update(game_info, history, request, breakdown) poss, wolf, seer, scores= breakdown.getTop() wolf = wolf[0] seer = seer[0] poss = poss[0] self.tar = wolf self.hold = poss if game_info['day'] != 0: if scores[wolf, 2] > 1.02 and not self.voted and self.skcnt < 2: self.talkQueue.push(Node(10 * scores[wolf, 2] ,cb.vote(self.tar))) self.voted = True if scores[wolf, 2] > 1.01 and not self.requested and self.skcnt < 2: self.talkQueue.push(Node(20 * scores[wolf, 2],cb.request(cb.request_div(self.hold)))) self.requested = True if scores[wolf, 2] > 1.0 and not self.estimated and self.skcnt < 2: self.talkQueue.push(Node(30,cb.estimate(wolf, "WEREWOLF"))) self.estimated = True
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 update(self, game_info, history, request, breakdown): super().update(game_info, history, request, breakdown) poss, wolfs, scores = breakdown.getTop() wolfs = sorted([x for x in wolfs if x not in self.deadlist], key=lambda x: scores[int(x), 1]) self.tar = wolfs[-1] self.hold = wolfs[0] if game_info['day'] != 0: if scores[wolfs[-1], 1] > 1.15 and not self.voted and self.skcnt < 2: self.talkQueue.push( Node(10 * scores[wolfs[-1], 1], cb.vote(self.tar))) self.voted = True if self.tar != self.hold and self.skcnt < 2: if scores[wolfs[-1], 1] > 1.1 and not self.requested: self.talkQueue.push( Node(20 * scores[wolfs[0], 1], cb.request(cb.request_div(self.hold)))) self.requested = True if scores[wolfs[-1], 1] > 1.0 and not self.estimated: self.talkQueue.push( Node(30, cb.estimate(wolfs[1], "WEREWOLF"))) self.estimated = True
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 == '' and self.base_info[ "day"] > 1: 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"] == 2: if 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_declare_func(): if self.vote_prob() > 0.6: self.vote_declare = self.vote_declare_func() return cb.vote(self.vote_declare) # 3.estimate werewolf if not yet if self.estimate_werewolf != self.vote(): if self.vote_prob() > 0.8: self.estimate_werewolf = self.vote_declare_func() return cb.estimate(self.estimate_werewolf, 'WEREWOLF') # 3.estimate villager if not yet if self.estimate_villager != self.estimate_villager_func(): if self.villager_prob() > 0.2: self.estimate_villager = self.estimate_villager_func() return cb.estimate(self.estimate_villager, 'VILLAGER') # 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 == '' and self.base_info[ "day"] == 2: 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'] == '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) # 3.estimate werewolf if not yet if self.base_info['myRole'] == "POSSESSED": if self.estimate_werewolf != self.vote(): if self.vote_prob() > 0.8: self.estimate_werewolf = self.vote_declare_func() return cb.estimate(self.estimate_werewolf, 'HUMAN') # 3.estimate villager if not yet if self.estimate_villager != self.estimate_villager_func(): if self.villager_prob() > 0.2: self.estimate_villager = self.estimate_villager_func() return cb.estimate(self.estimate_villager, 'WEREWOLF') else: if self.estimate_werewolf != self.vote(): if self.vote_prob() > 0.8: self.estimate_werewolf = self.vote_declare_func() return cb.estimate(self.estimate_werewolf, 'WEREWOLF') # 3.estimate villager if not yet if self.estimate_villager != self.estimate_villager_func(): if self.villager_prob() > 0.2: self.estimate_villager = self.estimate_villager_func() return cb.estimate(self.estimate_villager, 'VILLAGER') # 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 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()
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()