コード例 #1
0
ファイル: Werewolf.py プロジェクト: yoshinobc/wolf-strategy
 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()
コード例 #2
0
    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()
コード例 #3
0
ファイル: Villager.py プロジェクト: yoshinobc/wolf-strategy
    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()
コード例 #4
0
ファイル: Seer.py プロジェクト: yoshinobc/wolf-strategy
 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()
コード例 #5
0
ファイル: Seer.py プロジェクト: yoshinobc/wolf-strategy
 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()