コード例 #1
0
 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)))
コード例 #2
0
    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
コード例 #3
0
ファイル: conan.py プロジェクト: raruidol/MIARFID
    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
コード例 #4
0
 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()
コード例 #5
0
 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
コード例 #6
0
    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()
コード例 #7
0
    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()
コード例 #8
0
ファイル: bodyguard15.py プロジェクト: KL-Lru/aiwolf-Hack
 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] == 'guard':
                 self.reported = False
                 self.ability_result = history['text'][i]
                 print("ab: " + self.ability_result)
         if self.ability_result != '':
             self.talkQueue.push(Node(100, self.ability_result))
             self.comingout = True
     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])
     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 = wolfs[-1]
     self.hold = wolfs[0]
     self.guardtar = human[-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 self.comingout and not self.guard_say and self.skcnt < 2:
             self.talkQueue.push(
                 Node(10 * scores[human[-1], 0], cb.guard(self.guardtar)))
             self.guard_say = True
コード例 #9
0
ファイル: werewolf15.py プロジェクト: KL-Lru/aiwolf-Hack
 def update(self, game_info, history, request, breakdown):
     super().update(game_info, history, request, breakdown)
     poss, wolfs, scores = breakdown.getTop()
     if poss[0] != 0:
         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[x][0])
         self.tar = human[-1]
         self.hold = human[0]
         if game_info['day'] != 0:
             if scores[human[0],
                       1] > 1.2 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 len(human) >= 2 and scores[
                     human[1],
                     1] > 1.1 and not self.requested and self.skcnt < 2:
                 self.talkQueue.push(
                     Node(20 * scores[human[1], 1],
                          cb.request(cb.request_div(human[1]))))
                 self.requested = True
             if scores[human[0],
                       1] > 1.0 and not self.estimated and self.skcnt < 2:
                 self.talkQueue.push(
                     Node(30, cb.estimate(human[0], "WEREWOLF")))
                 self.estimated = True
コード例 #10
0
 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]
コード例 #11
0
ファイル: HeVillager_15.py プロジェクト: Oue-n/new-repository
    def talk(self):  # 発話内容をサーバーに送るメソッド
        if self.base_info["myRole"] == 'VILLAGER':
            self.talk_turn += 1
        # print("villagerのtalk_turn", self.base_info["day"], self.talk_turn)

        if self.talk_turn < 10:
            return cb.vote(self.vote())
            # return cb.skip()
        return cb.over()
コード例 #12
0
    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()
コード例 #13
0
 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
コード例 #14
0
ファイル: agent_ebifly.py プロジェクト: ebifly78/ebiwolf
    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()
コード例 #15
0
 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
コード例 #16
0
    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
コード例 #17
0
 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()
コード例 #18
0
    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()
コード例 #19
0
ファイル: DQN.py プロジェクト: yoshinobc/aiwolf
    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()
コード例 #20
0
 def talk(self):
     #print(getTimeStamp()+" inside Talk")
     selected = randomPlayerId(self.base_info)
     #print("Selected ID for talk: "+str(selected))
     return cb.vote(selected)
コード例 #21
0
ファイル: HeWerewolf_15.py プロジェクト: Oue-n/new-repository
    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()
コード例 #22
0
ファイル: sonoda_sample.py プロジェクト: saihara-k/aiwolf
    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()