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): if not self.isCo and self.day == 1 and random.uniform(0, 1) <= 0.5: self.isCo = True return cb.COMINGOUT(self.agentIdx, "VILLAGER") elif not self.isVote: if self.mode == -1: return cb.skip() else: self.isVote = True return cb.VOTE(self.mode) elif not self.isBecause: self.isBecause = True if self.mode == -1: return cb.skip() else: self.isBecause = True return cb.BECAUSE(cb.ESTIMATE(self.mode, "WEREWOLF"), cb.VOTE(self.mode)) elif len(self.AGREESentenceQue) >= 1: AGREEText = self.AGREESentenceQue.pop() return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2]) elif len(self.DISAGREESentenceQue) >= 1: DISAGREEText = self.DISAGREESentenceQue.pop() return cb.DISAGREE(DISAGREEText[0], DISAGREEText[1], DISAGREEText[2]) elif self.isRequest: self.isRequest = True if self.mode == -1: return cb.skip() else: return cb.REQUEST("ANY", cb.VOTE(self.mode)) else: return cb.skip()
def talk(self): self.talk_turn += 1 if self.isCo: self.isCo = True return cb.AND(cb.AGREE(self.agree_co[0], self.agree_co[1], self.agree_co[2]), cb.COMINGOUT(self.agentIdx, self.myrole)) elif not self.isVote and self.voteop != None: self.isVote = True return cb.AND(cb.AGREE(self.request_vote_agree[0], self.request_vote_agree[1], self.request_vote_agree[2]), cb.VOTE(self.voteop)) elif len(self.Agreeque) >= 1: AGREEText = self.Agreeque.pop() return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2]) elif not self.request_vote and self.talk_turn >= 3: for d in self.base_info["statusMap"].items(): if d[1] == "ALIVE" and d[0] != str(self.agentIdx + 1): return cb.REQUEST(int(d[0]) - 1, cb.REQUEST(self.agentIdx, cb.VOTE("ANY"))) index = 0 while True: if self.talk_turn <= 3: return cb.skip() if index == self.playerNum: return cb.skip() if not self.istalk_vote[index] and self.base_info["statusMap"][str(index + 1)] == "ALIVE": self.istalk_vote[index] = True return cb.INQUIRE(index, cb.VOTE("ANY")) else: index += 1 else: return cb.skip()
def talk(self): self.talk_step += 1 if self.co_rate != 2: self.co_rate = random.uniform(0, 1) if not self.isCo and self.day == 1 and self.co_rate >= 0.3: self.isCo = True if self.co_rate == 2: return cb.AND( cb.AGREE(self.agree_co[0], self.agree_co[1], self.agree_co[2]), cb.COMINGOUT(self.agentIdx, "VILLAGER")) else: return cb.COMINGOUT(self.agentIdx, "VILLAGER") elif not self.isVote and self.talk_step >= 5: lists = [] for i in range(len(self.vote_list)): if self.vote_list[i] != -1: lists.append(self.vote_list[i]) self.isVote = True try: self.talk_voteop = mode(lists) except: for d in self.base_info["statusMap"].items(): if d[1] == "ALIVE": self.talk_voteop = int(d[0]) - 1 break for i in range(len(self.vote_list)): if self.vote_list[i] == self.talk_voteop: self.because_list.append(i) return cb.VOTE(self.talk_voteop) elif len(self.because_list) > 0 and self.isVote: agent = self.because_list[0] del self.because_list[0] return cb.BECAUSE(cb.VOTE2(agent, self.talk_voteop), cb.VOTE(self.talk_voteop)) elif len(self.AGREESentenceQue) >= 1: AGREEText = self.AGREESentenceQue.pop() return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2]) elif len(self.DISAGREESentenceQue) >= 1: DISAGREEText = self.DISAGREESentenceQue.pop() return cb.DISAGREE(DISAGREEText[0], DISAGREEText[1], DISAGREEText[2]) index = 0 if self.talk_step >= 5: while True: if index == self.playerNum: return cb.skip() if not self.istalk_vote[ index] and index != self.agentIdx and self.base_info[ "statusMap"][str(index + 1)] == "ALIVE": self.istalk_vote[index] = True return cb.INQUIRE(index, cb.VOTE("ANY")) else: index += 1 return cb.skip()
def talk(self): if self.co_rate != 2: self.co_rate = random.uniform(0, 1) if not self.isCo and self.day == 1 and self.co_rate >= 0.5: self.isCo = True if self.co_rate == 2: return cb.AND( cb.AGREE(self.agree_co[0], self.agree_co[1], self.agree_co[2]), cb.COMINGOUT(self.agentIdx, "VILLAGER")) else: return cb.COMINGOUT(self.agentIdx, "VILLAGER") elif not self.isVote: if int(sorted(self.suspicion.items(), key=lambda x: x[1])[-1][1]) == 0: return cb.skip() self.voteop = int( sorted(self.suspicion.items(), key=lambda x: x[1])[-1][0]) if self.old_voteop != self.voteop and self.old_voteop != None: return cb.DISAGREE(self.myESTIMATE[0], self.myESTIMATE[1], self.myESTIMATE[2]) self.isVote = True self.old_voteop = self.voteop return cb.VOTE(self.voteop) elif not self.isBecause: if int(sorted(self.suspicion.items(), key=lambda x: x[1])[-1][1]) == 0: return cb.skip() self.isBecause = True return cb.BECAUSE(cb.ESTIMATE(self.voteop, "WEREWOLF"), cb.VOTE(self.voteop)) elif not self.isRequestVote: if int(sorted(self.suspicion.items(), key=lambda x: x[1])[-1][1]) == 0: return cb.skip() self.isRequestVote = True return cb.REQUEST("ANY", cb.VOTE(self.voteop)) elif len(self.AGREESentenceQue) >= 1: AGREEText = self.AGREESentenceQue.pop() return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2]) elif len(self.DISAGREESentenceQue) >= 2: DISAGREEText = self.DISAGREESentenceQue.pop() return cb.DISAGREE(DISAGREEText[0], DISAGREEText[1], DISAGREEText[2]) index = 0 while True: if index == self.playerNum: return cb.skip() if not self.CoFlag[index]: self.CoFlag[index] = True return cb.REQUEST(index, cb.COMINGOUT(index, "ANY")) else: index += 1 return cb.skip()
def __init__(self, game_info, game_setting): self.game_info = game_info self.idx = game_info["agentIdx"] self.game_setting = game_setting self.voted = False self.requested = False self.estimated = False self.tar = 1 if self.idx != 1 else 2 self.hold = 1 if self.idx != 1 else 2 self.skcnt = 0 self.talk_cnt = 0 self.talkQueue = PriorityQueue() self.talkQueue.push(Node(0, cb.skip())) self.talkQueue.push(Node(0, cb.skip())) self.deadlist = []
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 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 # 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): if len(self.talkQueue) == 0: # print("queue is empty") self.skcnt += 1 return cb.skip() txt = self.talkQueue.pop().text self.skcnt = 0 print("txt: " + txt) return txt
def talk(self): if not self.isCo and self.day == 1: self.isCo = True if self.co_rate == 2: return cb.AND( cb.AGREE(self.agree_co[0], self.agree_co[1], self.agree_co[2]), cb.COMINGOUT(self.agentIdx, "SEER")) else: return cb.COMINGOUT(self.agentIdx, "SEER") elif len(self.AGREESentenceQue) >= 1: AGREEText = self.AGREESentenceQue.pop() return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2]) elif len(self.DISAGREESentenceQue) >= 2: DISAGREEText = self.DISAGREESentenceQue.pop() return cb.DISAGREE(DISAGREEText[0], DISAGREEText[1], DISAGREEText[2]) elif not self.isVote: self.isVote = True self.voteop = int( sorted(self.suspicion.items(), key=lambda x: x[1])[-1][0]) return cb.VOTE(self.voteop) elif not self.isBecause: self.isBecause = True return cb.BECAUSE(cb.ESTIMATE(self.voteop, "WEREWOLF"), cb.VOTE(self.voteop)) elif not self.isRequestVote: self.isRequestVote = True return cb.REQUEST("ANY", cb.VOTE(self.voteop)) elif not self.isDivine: self.isDivine = True agent, role = self.divineans[0], self.divineans[1] self.divineans = None return cb.DIVINED(agent, role) index = 0 while True: if index == self.playerNum: return cb.skip() if not self.CoFlag[index]: self.CoFlag[index] = True return cb.REQUEST(index, cb.COMINGOUT(index, "ANY")) else: index += 1 return cb.skip()
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): self.talk_turn += 1 # vote宣言 if (self.vote_declare != self.vote()): self.vote_declare = self.vote() print(self.vote_declare) return cb.vote(self.vote_declare) # 発言回数残ってたらskip if self.talk_turn <= 10: return cb.skip() return cb.over()
def talk(self): if not self.isCo and self.day == 1: self.isCo = True return cb.COMINGOUT(self.agentIdx, "SEER") elif not self.isVote: if self.mode == -1: return cb.skip() else: self.isVote = True return cb.VOTE(self.mode) elif not self.isBecause: if self.mode == -1: return cb.skip() else: self.isBecause = True return cb.BECAUSE(cb.ESTIMATE(self.mode, "WEREWOLF"), cb.VOTE(self.mode)) elif len(self.AGREESentenceQue) >= 1: AGREEText = self.AGREESentenceQue.pop() return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2]) elif len(self.DISAGREESentenceQue) >= 1: DISAGREEText = self.DISAGREESentenceQue.pop() return cb.DISAGREE(DISAGREEText[0], DISAGREEText[1], DISAGREEText[2]) elif not self.isRequest: if self.mode == -1: return cb.skip() else: self.isRequest = True return cb.REQUEST("ANY", cb.VOTE(self.mode)) elif not self.isDivined: if self.mode != -1: self.isDivined = True return cb.DIVINED(self.mode, "WEREWOLF") else: return cb.skip() else: return cb.skip()
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): """ 村人は原則カミングアウトしない。 1.その日までの結果を基に一番怪しいやつにVote宣言をする 2.カミングアウトなどで一番怪しいやつが変化したら改めてvote宣言をする 3.最後にVote宣言した相手に実際の投票をする """ #各日4ターン目で投票先宣言 if self.talk_turn == 5: cand = self.rfestimator.decide_action("vote") #print("TURN",self.talk_turn) print(cand) return util.list2protocol(cand, "VOTE OR") # 何もなければOver if self.talk_turn < 5: 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 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): 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): self.talkCount += 1 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 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 whisper(self): return cb.skip()
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 update(self, game_info, history, request, breakdown): self.game_info = game_info print(request) if request == "DAILY_INITIALIZE": self.talkQueue.push(Node(0, cb.skip())) self.talkQueue.push(Node(0, cb.skip())) self.voted = False self.estimated = False self.requested = False self.talk_cnt = 0 self.skcnt = 0 # print("reset flags") for i in range(history.shape[0]): if history.type[i] == "talk": text = history.text[i].split() if text[0] == "COMINGOUT": # Coming out時の処理 idx = self.getAgentIdx(text[1]) role = text[2] breakdown.updateCo(idx, role) print("co " + str(idx) + " " + text[2]) elif text[0] == "DIVINED": # 占い結果の処理 src = int(history.agent[i]) dst = self.getAgentIdx(text[1]) species = text[2] breakdown.updateDivined(src, dst, species) print("divine " + str(src) + " " + text[2] + " " + str(dst)) elif text[0] == "ESTIMATE": # 推測時の処理 src = int(history.agent[i]) dst = self.getAgentIdx(text[1]) species = text[2] print("estimate " + str(src) + " " + text[2] + " " + str(dst)) elif text[0] == "VOTE": # 投票宣言の処理 src = int(history.agent[i]) dst = self.getAgentIdx(text[1]) print("vote " + str(src) + " -> " + str(dst)) elif re.match("REQUEST", text[0]): # リクエストの処理 print("request...") elif history.type[i] == "vote": # 投票時の処理 src = int(history.idx[i]) dst = int(history.agent[i]) print("agent " + str(src) + " voted agent " + str(dst)) breakdown.updateVote(src, dst) elif history.type[i] == "execute": # 処刑時の処理 idx = int(history.agent[i]) breakdown.updateExecuted(idx) print("agent " + str(idx) + " executed") self.deadlist.append(idx) elif history.type[i] == "dead": # 人狼襲撃時の処理 idx = int(history.agent[i]) print("agent " + str(idx) + " attacked") self.deadlist.append(idx) breakdown.updateAttacked(idx) if request != "DAILY_INITIALIZE": breakdown.compress() breakdown.update()
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 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 whisper(self): if self.base_info['day'] == 0: return cb.comingout(self.base_info['agentIdx'], self.comingout) return cb.skip()